branch: externals/hyperbole
commit 12043802da75cb4f06f895610f266cf6d94fa217
Author: bw <[email protected]>
Commit: bw <[email protected]>
Fix 2 hywiki tests for org links and org roam nodes
---
ChangeLog | 5 +++++
hywiki.el | 11 ++++++-----
test/hywiki-tests.el | 22 ++++++++++------------
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 85099acc42..2790f87fd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2025-02-23 Bob Weiner <[email protected]>
+* test/hywiki-tests.el (hywiki-tests--convert-words-to-org-link): Fix to not
+ expect 'hy:' prefix in HyWiki Org links.
+ (hywiki-tests--add-org-roam-node): Handle all calls to
+ 'org-roam-node-title'.
+
* hywiki.el (hywiki-get-referent): Fix suffix match to use group 3 and add
suffix to referent-value here.
(hywiki-display-referent): Remove adding suffix to referent-value
here.
diff --git a/hywiki.el b/hywiki.el
index ff3d69cf9c..2649b17b12 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Acpr-24 at 22:41:13
-;; Last-Mod: 23-Feb-25 at 02:21:03 by Bob Weiner
+;; Last-Mod: 23-Feb-25 at 11:05:28 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1457,7 +1457,7 @@ publish process."
(delete-region (overlay-start overlay)
(overlay-end overlay))
(delete-overlay overlay)
- (if (setq org-link (hywiki-word-to-org-link wikiword
nil))
+ (if (setq org-link (hywiki-word-to-org-link
wikiword-and-section nil))
(insert org-link)
(message
"(hywiki-convert-words-to-org-links): \"%s\" in
\"%s\" produced nil org link output"
@@ -1486,7 +1486,8 @@ publish process."
(unless (and suffix (not (string-empty-p suffix)))
(setq suffix nil))
(setq suffix-no-hashmark (when suffix (substring suffix 1)))
- (when (string-equal path (file-name-nondirectory buffer-file-name))
+ (when (or (not buffer-file-name)
+ (string-equal path (file-name-nondirectory buffer-file-name)))
(setq path nil))
(cond (desc
(if path
@@ -2625,11 +2626,11 @@ backend."
(hpath:spaces-to-dashes-markup-anchor
(or suffix ""))
desc))
- (`latex (format "\\href{%s}{%s}" (replace-regexp-in-string
"[\\{}$%&_#~^]" "\\\\\\&" path) desc))
+ (`latex (format "\\href{%s.latex}{%s}" (replace-regexp-in-string
"[\\{}$%&_#~^]" "\\\\\\&" path-stem) desc))
(`md (format "[%s](%s.md%s)" desc path-stem
(hpath:spaces-to-dashes-markup-anchor
(or suffix ""))))
- (`texinfo (format "@uref{%s,%s}" path desc))
+ (`texinfo (format "@uref{%s.texi,%s}" path-stem desc))
(_ path))
link)))
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 90180f4000..472876899b 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell
;;
;; Orig-Date: 18-May-24 at 23:59:48
-;; Last-Mod: 7-Feb-25 at 10:01:25 by Mats Lidell
+;; Last-Mod: 23-Feb-25 at 11:04:10 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -621,7 +621,7 @@ Both mod-time and checksum must be changed for a test to
return true."
(with-hywiki-buttonize-and-insert-hooks (insert "WikiWord "))
(goto-char 4)
(hywiki-convert-words-to-org-links)
- (should (string= "[[hy:WikiWord]] "
+ (should (string= "[[WikiWord]] "
(buffer-substring-no-properties (point-min)
(point-max)))))
(with-temp-buffer
(hywiki-mode 1)
@@ -630,7 +630,7 @@ Both mod-time and checksum must be changed for a test to
return true."
(newline nil t))
(goto-char 4)
(hywiki-convert-words-to-org-links)
- (should (string= "[[hy:WikiWord]]\n"
+ (should (string= "[[WikiWord]]\n"
(buffer-substring-no-properties (point-min)
(point-max))))))
(hywiki-tests--add-hywiki-hooks)
(hywiki-mode 0)
@@ -694,24 +694,24 @@ Both mod-time and checksum must be changed for a test to
return true."
"Verify `hywiki-org-link-export' output for different formats."
(let* ((hywiki-directory (make-temp-file "hywiki" t))
(wikipage (cdr (hywiki-add-page "WikiWord")))
- (filename (when wikipage (file-name-nondirectory wikipage))))
+ (filename (when wikipage (file-name-nondirectory wikipage)))
+ (filename-stem (when filename (file-name-sans-extension filename))))
(unwind-protect
(progn
(should (string-match-p
(format "\\[hy\\] <doc:.*%s>" filename)
(hywiki-org-link-export "WikiWord" "doc" 'ascii)))
(should (string-match-p
- (format "<a href=\".*%s\">doc</a>"
- (replace-regexp-in-string "\\.org" ".html"
filename))
+ (format "<a href=\".*%s.html\">doc</a>" filename-stem)
(hywiki-org-link-export "WikiWord" "doc" 'html)))
(should (string-match-p
- (format "\\[doc\\](.*%s)" filename)
+ (format "\\[doc\\](.*%s.md)" filename-stem)
(hywiki-org-link-export "WikiWord" "doc" 'md)))
(should (string-match-p
- (format "\\href{.*%s}{doc}" filename)
+ (format "\\href{.*%s.latex}{doc}" filename-stem)
(hywiki-org-link-export "WikiWord" "doc" 'latex)))
(should (string-match-p
- (format "@uref{.*%s,doc}" filename)
+ (format "@uref{.*%s.texi,doc}" filename-stem)
(hywiki-org-link-export "WikiWord" "doc" 'texinfo)))
(should (string-match-p
(format ".*%s" filename)
@@ -892,16 +892,14 @@ Note special meaning of `hywiki-allow-plurals-flag'."
(ert-deftest hywiki-tests--add-org-roam-node ()
"Verify `hywiki-add-org-roam-node'."
(let* ((hywiki-directory (make-temp-file "hywiki" t))
- (wiki-page (cdr (hywiki-add-page "FirstWord")))
(wikiword (hy-make-random-wikiword)))
(unwind-protect
(mocklet (((hypb:require-package 'org-roam) => t)
((org-roam-node-read) => "node")
- ((org-roam-node-title "node") => "node-title"))
+ (org-roam-node-title => "node-title"))
(hywiki-add-org-roam-node wikiword)
(should (equal '(org-roam-node . "node-title")
(hywiki-get-referent wikiword))))
- (hy-delete-file-and-buffer wiki-page)
(hy-delete-dir-and-buffer hywiki-directory))))
;;; FIXME