Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2026-02-15 Mats Lidell <matsl@gnu.org>

* hywiki.el (hywiki--org-link-html-format): Use
`hpath:dashes-to-spaces-markup-anchor' to make header match target.
* test/hywiki-tests.el (hywiki-tests--action-key-moves-to-word-and-section-using-dash-to-space-conversion):
Add test for headers with dashes.
(hywiki-tests--published-html-links-to-word-and-section): Update test to
the dash to space conversion in headers.

2026-02-15 Bob Weiner <rsw@gnu.org>

* hywiki.el (hywiki-word-highlight-in-current-buffer): Fix bug that added
Expand Down
3 changes: 2 additions & 1 deletion hywiki.el
Original file line number Diff line number Diff line change
Expand Up @@ -3072,7 +3072,8 @@ If not found, set it up and return the new project properties."

(defun hywiki--org-link-html-format (path-stem suffix desc info)
"Format an html link using Org ids."
(let* ((heading (and suffix (not (string-empty-p suffix)) (substring suffix 1)))
(let* ((raw-heading (and suffix (not (string-empty-p suffix)) (substring suffix 1)))
(heading (and raw-heading (hpath:dashes-to-spaces-markup-anchor raw-heading)))
(link-obj (org-element-create
'link
(list
Expand Down
41 changes: 38 additions & 3 deletions test/hywiki-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ body B
(condition-case err-msg
(dolist (w words)
(setq wiki-link (car w)
expected-str-at-pos (cdr w))
expected-str-at-pos (regexp-quote (cdr w)))
(erase-buffer)
(hywiki-tests--insert wiki-link)
(goto-char 4)
Expand All @@ -887,6 +887,41 @@ body B
(error (error "'%s', '%s' - Error: %s"
wiki-link expected-str-at-pos err-msg))))))))

(ert-deftest hywiki-tests--action-key-moves-to-word-and-section-using-dash-to-space-conversion ()
"Verify action key on a WikiWord with section, line and column works.
Verify dash in the header matches a target with dash replaced by space."
(hywiki-tests--preserve-hywiki-mode
(let ((words '(("WikiWord#first" . "* first")
("WikiWord#header-one" . "* header one")
("WikiWord#first one" . "* first")
("(WikiWord#header one)" . "* header one")
("WikiWord#header--two" . "* header two")
("(WikiWord#header--three)" . "* header three")
("WikiWord#header---four" . "* header four"))))
;; Setup target WikiWord
(with-current-buffer (find-file-noselect wiki-page)
(hywiki-tests--insert "\
* first
* header one
* header two
* header three
* header four
")
(save-buffer))
;; Create temp buffers with WikiWord links to the target
;; WikiWord page and verify they work.
(with-temp-buffer
(dolist (w words)
(let ((wiki-link (car w))
(expected-str-at-pos (regexp-quote (cdr w))))
(ert-info ((format "Link: %s Header: %s" wiki-link expected-str-at-pos))
(erase-buffer)
(hywiki-tests--insert wiki-link)
(goto-char 4)
(save-excursion
(action-key)
(should (looking-at-p expected-str-at-pos))))))))))

(defun hywiki-tests--search-section (section)
"Find SECTION in current buffer and return the id string.
Search for elements of type <h?>...</h?> for the id string. Example:
Expand Down Expand Up @@ -924,7 +959,7 @@ First line
body A
** Bsection subsection
body B
*** Csection-subsection
*** Csection subsection
body C
")
(save-buffer)
Expand All @@ -950,7 +985,7 @@ WikiWord#Csection-subsection
(with-current-buffer (find-file-noselect wikiword-html)
(setq idA (should (hywiki-tests--search-section "Asection")))
(setq idB (should (hywiki-tests--search-section "Bsection subsection")))
(setq idC (should (hywiki-tests--search-section "Csection-subsection"))))
(setq idC (should (hywiki-tests--search-section "Csection subsection"))))

;; Verify links are generated
(find-file wikipage-html)
Expand Down