summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-06 02:05:09 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-06 02:18:40 +0200
commitd44cadbe3eabfaeb52089fdd313e75e8926ff7d2 (patch)
treebcd69dbc266ac5c5c3668d25c5b5bfe1f13edc74
parentc822329faf7edb7cd37077a923f0cc6fda785b1b (diff)
downloadorg-mode-d44cadbe3eabfaeb52089fdd313e75e8926ff7d2.tar.gz
ox-texinfo: Fix conflicts between @node and @anchor names
* lisp/ox-texinfo.el (org-texinfo--get-node): Prevent using reserved "Top" node. (org-texinfo-radio-target): (org-texinfo-src-block): (org-texinfo-table): (org-texinfo-target): Use `org-texinfo--get-node' instead of `org-export-get-reference'.
-rw-r--r--lisp/ox-texinfo.el29
1 files changed, 15 insertions, 14 deletions
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 9e69147..463fb30 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -448,21 +448,22 @@ INFO is a plist used as a communication channel. See
;; Else use format string.
(fmt (format fmt text))))
-(defun org-texinfo--get-node (blob info)
- "Return node or anchor associated to BLOB.
-BLOB is an element or object. INFO is a plist used as
+(defun org-texinfo--get-node (datum info)
+ "Return node or anchor associated to DATUM.
+DATUM is an element or object. INFO is a plist used as
a communication channel. The function guarantees the node or
anchor name is unique."
(let ((cache (plist-get info :texinfo-node-cache)))
- (or (cdr (assq blob cache))
+ (or (cdr (assq datum cache))
(let ((name
(org-texinfo--sanitize-node
- (if (eq (org-element-type blob) 'headline)
- (org-export-data (org-export-get-alt-title blob info) info)
- (org-export-get-reference blob info)))))
- ;; Ensure NAME is unique.
- (while (rassoc name cache) (setq name (concat name "x")))
- (plist-put info :texinfo-node-cache (cons (cons blob name) cache))
+ (if (eq (org-element-type datum) 'headline)
+ (org-export-data (org-export-get-alt-title datum info) info)
+ (org-export-get-reference datum info)))))
+ ;; Ensure NAME is unique and not reserved node name "Top".
+ (while (or (equal name "Top") (rassoc name cache))
+ (setq name (concat name "x")))
+ (plist-put info :texinfo-node-cache (cons (cons datum name) cache))
name))))
(defun org-texinfo--sanitize-node (title)
@@ -1266,7 +1267,7 @@ holding contextual information."
TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "@anchor{%s}%s"
- (org-export-get-reference radio-target info)
+ (org-texinfo--get-node radio-target info)
text))
;;;; Section
@@ -1314,7 +1315,7 @@ contextual information."
(org-texinfo--wrap-float value
info
(org-export-translate "Listing" :utf-8 info)
- (org-export-get-reference src-block info)
+ (org-texinfo--get-node src-block info)
caption
shortcaption))))
@@ -1373,7 +1374,7 @@ contextual information."
(org-texinfo--wrap-float table-str
info
(org-export-translate "Table" :utf-8 info)
- (org-export-get-reference table info)
+ (org-texinfo--get-node table info)
caption
shortcaption)))))
@@ -1441,7 +1442,7 @@ a communication channel."
"Transcode a TARGET object from Org to Texinfo.
CONTENTS is nil. INFO is a plist holding contextual
information."
- (format "@anchor{%s}" (org-export-get-reference target info)))
+ (format "@anchor{%s}" (org-texinfo--get-node target info)))
;;;; Timestamp