Skip to content

Commit 09dfbc4

Browse files
authored
Merge pull request #865 from rswgnu/wip-hywiki-publish-dash-space-sections
Use hpath:find header link logic for HyWiki links
2 parents 1ef2593 + 562a9dd commit 09dfbc4

3 files changed

Lines changed: 49 additions & 4 deletions

File tree

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2026-02-15 Mats Lidell <matsl@gnu.org>
2+
3+
* hywiki.el (hywiki--org-link-html-format): Use
4+
`hpath:dashes-to-spaces-markup-anchor' to make header match target.
5+
* test/hywiki-tests.el (hywiki-tests--action-key-moves-to-word-and-section-using-dash-to-space-conversion):
6+
Add test for headers with dashes.
7+
(hywiki-tests--published-html-links-to-word-and-section): Update test to
8+
the dash to space conversion in headers.
9+
110
2026-02-15 Bob Weiner <rsw@gnu.org>
211

312
* hywiki.el (hywiki-word-highlight-in-current-buffer): Fix bug that added

hywiki.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3072,7 +3072,8 @@ If not found, set it up and return the new project properties."
30723072

30733073
(defun hywiki--org-link-html-format (path-stem suffix desc info)
30743074
"Format an html link using Org ids."
3075-
(let* ((heading (and suffix (not (string-empty-p suffix)) (substring suffix 1)))
3075+
(let* ((raw-heading (and suffix (not (string-empty-p suffix)) (substring suffix 1)))
3076+
(heading (and raw-heading (hpath:dashes-to-spaces-markup-anchor raw-heading)))
30763077
(link-obj (org-element-create
30773078
'link
30783079
(list

test/hywiki-tests.el

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ body B
877877
(condition-case err-msg
878878
(dolist (w words)
879879
(setq wiki-link (car w)
880-
expected-str-at-pos (cdr w))
880+
expected-str-at-pos (regexp-quote (cdr w)))
881881
(erase-buffer)
882882
(hywiki-tests--insert wiki-link)
883883
(goto-char 4)
@@ -887,6 +887,41 @@ body B
887887
(error (error "'%s', '%s' - Error: %s"
888888
wiki-link expected-str-at-pos err-msg))))))))
889889

890+
(ert-deftest hywiki-tests--action-key-moves-to-word-and-section-using-dash-to-space-conversion ()
891+
"Verify action key on a WikiWord with section, line and column works.
892+
Verify dash in the header matches a target with dash replaced by space."
893+
(hywiki-tests--preserve-hywiki-mode
894+
(let ((words '(("WikiWord#first" . "* first")
895+
("WikiWord#header-one" . "* header one")
896+
("WikiWord#first one" . "* first")
897+
("(WikiWord#header one)" . "* header one")
898+
("WikiWord#header--two" . "* header two")
899+
("(WikiWord#header--three)" . "* header three")
900+
("WikiWord#header---four" . "* header four"))))
901+
;; Setup target WikiWord
902+
(with-current-buffer (find-file-noselect wiki-page)
903+
(hywiki-tests--insert "\
904+
* first
905+
* header one
906+
* header two
907+
* header three
908+
* header four
909+
")
910+
(save-buffer))
911+
;; Create temp buffers with WikiWord links to the target
912+
;; WikiWord page and verify they work.
913+
(with-temp-buffer
914+
(dolist (w words)
915+
(let ((wiki-link (car w))
916+
(expected-str-at-pos (regexp-quote (cdr w))))
917+
(ert-info ((format "Link: %s Header: %s" wiki-link expected-str-at-pos))
918+
(erase-buffer)
919+
(hywiki-tests--insert wiki-link)
920+
(goto-char 4)
921+
(save-excursion
922+
(action-key)
923+
(should (looking-at-p expected-str-at-pos))))))))))
924+
890925
(defun hywiki-tests--search-section (section)
891926
"Find SECTION in current buffer and return the id string.
892927
Search for elements of type <h?>...</h?> for the id string. Example:
@@ -924,7 +959,7 @@ First line
924959
body A
925960
** Bsection subsection
926961
body B
927-
*** Csection-subsection
962+
*** Csection subsection
928963
body C
929964
")
930965
(save-buffer)
@@ -950,7 +985,7 @@ WikiWord#Csection-subsection
950985
(with-current-buffer (find-file-noselect wikiword-html)
951986
(setq idA (should (hywiki-tests--search-section "Asection")))
952987
(setq idB (should (hywiki-tests--search-section "Bsection subsection")))
953-
(setq idC (should (hywiki-tests--search-section "Csection-subsection"))))
988+
(setq idC (should (hywiki-tests--search-section "Csection subsection"))))
954989

955990
;; Verify links are generated
956991
(find-file wikipage-html)

0 commit comments

Comments
 (0)