forked from mirrors/org-mode
ox-texinfo: Fix fuzzy links to headlines
* lisp/ox-texinfo.el (org-texinfo--get-node): New function. (org-texinfo-headline, org-texinfo-link): Use new function. The same function is used to create @node entries and links to nodes, to avoid any discrepancy between them
This commit is contained in:
parent
2bd97a5ae6
commit
1efac41f03
|
@ -430,6 +430,17 @@ See `org-texinfo-text-markup-alist' for details."
|
||||||
;; Else use format string.
|
;; Else use format string.
|
||||||
(t (format fmt text)))))
|
(t (format fmt text)))))
|
||||||
|
|
||||||
|
(defun org-texinfo--get-node (headline info)
|
||||||
|
"Return node entry associated to HEADLINE.
|
||||||
|
INFO is a plist used as a communication channel."
|
||||||
|
(let ((menu-title (org-element-property :texinfo-menu-title headline)))
|
||||||
|
(org-texinfo--sanitize-menu
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"%" "%%"
|
||||||
|
(if menu-title (org-export-data menu-title info)
|
||||||
|
(org-texinfo--sanitize-headline
|
||||||
|
(org-element-property :title headline) info))))))
|
||||||
|
|
||||||
;;; Headline sanitizing
|
;;; Headline sanitizing
|
||||||
|
|
||||||
(defun org-texinfo--sanitize-headline (headline info)
|
(defun org-texinfo--sanitize-headline (headline info)
|
||||||
|
@ -896,22 +907,12 @@ holding contextual information."
|
||||||
(class-sectionning (assoc class org-texinfo-classes))
|
(class-sectionning (assoc class org-texinfo-classes))
|
||||||
;; Find the index type, if any
|
;; Find the index type, if any
|
||||||
(index (org-element-property :index headline))
|
(index (org-element-property :index headline))
|
||||||
;; Retrieve custom menu title (if any)
|
|
||||||
(menu-title (org-texinfo--sanitize-menu
|
|
||||||
(org-export-data
|
|
||||||
(org-element-property :TEXINFO_MENU_TITLE headline)
|
|
||||||
info)))
|
|
||||||
;; Retrieve headline text
|
;; Retrieve headline text
|
||||||
(text (org-texinfo--sanitize-headline
|
(text (org-texinfo--sanitize-headline
|
||||||
(org-element-property :title headline) info))
|
(org-element-property :title headline) info))
|
||||||
;; Create node info, to insert it before section formatting.
|
;; Create node info, to insert it before section formatting.
|
||||||
;; Use custom menu title if present
|
;; Use custom menu title if present
|
||||||
(node (format "@node %s\n"
|
(node (format "@node %s\n" (org-texinfo--get-node headline info)))
|
||||||
(org-texinfo--sanitize-menu
|
|
||||||
(replace-regexp-in-string "%" "%%"
|
|
||||||
(if (not (string= "" menu-title))
|
|
||||||
menu-title
|
|
||||||
text)))))
|
|
||||||
;; Menus must be generated with first child, otherwise they
|
;; Menus must be generated with first child, otherwise they
|
||||||
;; will not nest properly
|
;; will not nest properly
|
||||||
(menu (let* ((first (org-export-first-sibling-p headline info))
|
(menu (let* ((first (org-export-first-sibling-p headline info))
|
||||||
|
@ -1180,8 +1181,7 @@ INFO is a plist holding contextual information. See
|
||||||
;; LINK points to an headline. Use the headline as the NODE target
|
;; LINK points to an headline. Use the headline as the NODE target
|
||||||
(headline
|
(headline
|
||||||
(format "@ref{%s,%s}"
|
(format "@ref{%s,%s}"
|
||||||
(or (org-element-property :TEXINFO_MENU_TITLE destination)
|
(org-texinfo--get-node destination info)
|
||||||
(org-element-property :title destination))
|
|
||||||
(or desc "")))
|
(or desc "")))
|
||||||
(otherwise
|
(otherwise
|
||||||
(let ((path (org-export-solidify-link-text path)))
|
(let ((path (org-export-solidify-link-text path)))
|
||||||
|
@ -1203,8 +1203,7 @@ INFO is a plist holding contextual information. See
|
||||||
;; LINK points to an headline. Use the headline as the NODE target
|
;; LINK points to an headline. Use the headline as the NODE target
|
||||||
(headline
|
(headline
|
||||||
(format "@ref{%s,%s}"
|
(format "@ref{%s,%s}"
|
||||||
(or (org-element-property :TEXINFO_MENU_TITLE destination)
|
(org-texinfo--get-node destination info)
|
||||||
(org-element-property :title destination))
|
|
||||||
(or desc "")))
|
(or desc "")))
|
||||||
(otherwise
|
(otherwise
|
||||||
(let ((path (org-export-solidify-link-text path)))
|
(let ((path (org-export-solidify-link-text path)))
|
||||||
|
|
Loading…
Reference in a new issue