diff options
author | Rudolf Adamkovič <rudolf@adamkovic.org> | 2024-09-12 00:19:55 +0200 |
---|---|---|
committer | Ihor Radchenko <yantar92@posteo.net> | 2024-09-15 14:08:19 +0200 |
commit | 4829bacffec394f127f0697def2fff4bbb66ad7e (patch) | |
tree | 0e7dff732cadf2c22deb4502e20579d07f686cc6 | |
parent | 07dd3bcae6b7b5e0692fc40dd307a7e841179b52 (diff) |
ox-texinfo: Fix automatic @ref titles
* lisp/ox-texinfo.el (org-texinfo--@ref): Fix an incorrect assumption
that Texinfo uses node names for automatic link text. It does not.
Instead, it uses the corresponding section title. For example, if a
node is named `a' its section is named `A', the Org link to the node
`a' written as `[[...][xxx]]' ends up being rendered as "A", which
means the link description the Org user provided is ignored.
-rw-r--r-- | lisp/ox-texinfo.el | 2 | ||||
-rw-r--r-- | testing/lisp/test-ox-texinfo.el | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 6adee9fca..2da90ca0f 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1311,7 +1311,7 @@ nil." (replace-regexp-in-string "[ \t]*:+" "" (replace-regexp-in-string "," "@comma{}" description))))) - (if (or (not title) (equal title node-name)) + (if (not title) (format "@ref{%s}" node-name) (format "@ref{%s, , %s}" node-name title)))) diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index b16a344e7..d4552459d 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,34 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) + +;;; References + +(ert-deftest test-ox-texinfo/references () + "Test references with manual and automatic descriptions." + (should + (org-test-with-temp-text + (string-join + (list "* A" + ":PROPERTIES:" + ":ALT_TITLE: B" + ":END:" + "[[A]]" + "[[A][B]]" + "[[A][C]]" + " ....") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "@ref{B}") + (re-search-forward "@ref{B, , B}") + (re-search-forward "@ref{B, , C}"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here |