diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-04 21:48:09 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-04 21:50:00 +0100 |
commit | db16370c0bc112a1193c0f49233bec999528bf2d (patch) | |
tree | d13c897841ec17fbe0b118388e60bd729694a3ff | |
parent | 08c9de2a74082e693034ab2494df7de2931ea028 (diff) | |
download | org-mode-db16370c0bc112a1193c0f49233bec999528bf2d.tar.gz |
ox-texinfo: Fix @ref without description
* lisp/ox-texinfo.el (org-texinfo--@ref): Prefer @ref{} with a single
argument when no description is provided.
-rw-r--r-- | lisp/ox-texinfo.el | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 3df4ced..60618c1 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1035,15 +1035,17 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-texinfo--@ref (datum description info) "Return @ref command for element or object DATUM. -DESCRIPTION is the name of the section to print, as a string." +DESCRIPTION is the printed name of the section, as a string, or +nil." (let ((node-name (org-texinfo--get-node datum info)) ;; Sanitize DESCRIPTION for cross-reference use. In - ;; particular, remove colons as they seem to cause (even - ;; within @asis{...} to the Texinfo reader. - (title (replace-regexp-in-string - "[ \t]*:+" "" - (replace-regexp-in-string "," "@comma{}" description)))) - (if (equal title node-name) + ;; particular, remove colons as they seem to cause pain (even + ;; within @asis{...}) to the Texinfo reader. + (title (and description + (replace-regexp-in-string + "[ \t]*:+" "" + (replace-regexp-in-string "," "@comma{}" description))))) + (if (or (not title) (equal title node-name)) (format "@ref{%s}" node-name) (format "@ref{%s, , %s}" node-name title)))) @@ -1091,20 +1093,8 @@ INFO is a plist holding contextual information. See (org-element-type (org-element-property :parent destination)))))) (let ((headline (org-element-lineage destination '(headline) t))) - (org-texinfo--@ref - headline - (or desc (org-texinfo--sanitize-title - (org-element-property :title headline) info)) - info))) - (_ - (org-texinfo--@ref - destination - (or desc - (pcase (org-export-get-ordinal destination info) - ((and (pred integerp) n) (number-to-string n)) - ((and (pred consp) n) (mapconcat #'number-to-string n ".")) - (_ "???"))) ;cannot guess the description - info))))) + (org-texinfo--@ref headline desc info))) + (_ (org-texinfo--@ref destination desc info))))) ((string= type "mailto") (format "@email{%s}" (concat (org-texinfo--sanitize-content path) |