branch: externals/hyperbole commit f95130297760fa28e1a2be828bc3dd751696595d Author: Mats Lidell <mats.lid...@lidells.se> Commit: Mats Lidell <mats.lid...@lidells.se>
Verify space in #section while WikiWord is in a delimited string. --- ChangeLog | 4 +++- test/hywiki-tests.el | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9d9bbb1497..65770f2abe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2025-05-26 Mats Lidell <ma...@gnu.org> +2025-05-27 Mats Lidell <ma...@gnu.org> * test/hywiki-tests.el (hywiki-tests--sections-with-dash-space): Add test for section with # character. @@ -7,6 +7,8 @@ test. It is supported now. (hywiki-tests--nonexistent-wikiword-with-section-should-create-wikiword): Add test for a new WikiWord when initially given with a section. + (hywiki-tests--sections-with-space-and-delimited-string): Add test of + space in #section while delimited string. 2025-05-26 Bob Weiner <r...@gnu.org> diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index 1b973ee1f8..88e7626e21 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -336,6 +336,31 @@ line 2 (should-not (hywiki-word-at)))) (hy-delete-dir-and-buffer hywiki-directory))))) +(ert-deftest hywiki-tests--sections-with-space-and-delimited-string () + "Verify `hywiki-word-at' with space and delimited string. +Only allow spaces in #section if the delimited string is a single +HyWikiWord reference." + (hywiki-tests--preserve-hywiki-mode + (let ((hywiki-directory (make-temp-file "hywiki" t))) + (unwind-protect + (progn + (hywiki-mode 1) + (with-temp-buffer ; Delimited string allow space + (insert "\"WikiWord#section rest\"") + (goto-char 4) + (should (string= "WikiWord#section rest" (hywiki-word-at)))) + (with-temp-buffer ; Not a single WikiWord reference so no space + (insert "\"WikiPage WikiWord#section rest\"") + (goto-char 4) + (should (string= "WikiPage" (hywiki-word-at))) + (goto-char 20) + (should (string= "WikiWord#section" (hywiki-word-at)))) + (with-temp-buffer ; Single WikiWord reference (WikiPage is part of section) + (insert "\"WikiWord#section rest WikiPage\"") + (goto-char 4) + (should (string= "WikiWord#section rest WikiPage" (hywiki-word-at))))) + (hy-delete-dir-and-buffer hywiki-directory))))) + (ert-deftest hywiki-tests--word-is-p () "Verify `hywiki-word-is-p' identifies WikiWords." (should (hywiki-word-is-p "WikiWord"))