@@ -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.
892927Search for elements of type <h?>...</h?> for the id string. Example:
@@ -924,7 +959,7 @@ First line
924959body A
925960** Bsection subsection
926961body B
927- *** Csection- subsection
962+ *** Csection subsection
928963body 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