Export back-ends: Use `org-export-get-reference'

* lisp/ox-beamer.el (org-beamer-link):
(org-beamer-plain-list):
(org-beamer-target):
(org-beamer-radio-target):

* lisp/ox-html.el (org-html--wrap-image):
(org-html--format-toc-headline):
(org-html-list-of-listings):
(org-html-list-of-tables):
(org-html-headline):
(org-html-inline-src-block):
(org-html-link):
(org-html-paragraph):
(org-html-section):
(org-html-radio-target):
(org-html-src-block):
(org-html-table):
(org-html-target):

* lisp/ox-latex.el (org-latex--caption/label-string):
(org-latex--wrap-label):
(org-latex-center-block):
(org-latex-drawer):
(org-latex-dynamic-block):
(org-latex-example-block):
(org-latex-fixed-width):
(org-latex-headline):
(org-latex-horizontal-rule):
(org-latex-latex-environment):
(org-latex-link):
(org-latex-plain-list):
(org-latex-quote-block):
(org-latex-radio-target):
(org-latex-target):
(org-latex-verse-block):

* lisp/ox-man.el (org-man-target):

* lisp/ox-md.el (org-md-headline):

* lisp/ox-odt.el (org-odt-format-headline--wrap):
(org-odt-headline):
(org-odt-format-label):
(org-odt-link--infer-description):
(org-odt-link):
(org-odt-radio-target):
(org-odt-target):

* lisp/ox-texinfo.el (org-texinfo--get-node):
(org-texinfo-radio-target):
(org-texinfo-target):

* contrib/lisp/ox-groff.el (org-groff-link):
(org-groff-radio-target):
(org-groff-target):

* contrib/lisp/ox-rss.el (org-rss-headline): Use
  `org-export-get-reference'.
This commit is contained in:
Nicolas Goaziou 2015-04-13 11:24:42 +02:00
parent 186bae42a4
commit 4590332652
9 changed files with 164 additions and 212 deletions

View File

@ -1269,8 +1269,7 @@ INFO is a plist holding contextual information. See
(let ((destination (org-export-resolve-radio-link link info))) (let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc (if (not destination) desc
(format "\\fI [%s] \\fP" (format "\\fI [%s] \\fP"
(org-export-solidify-link-text (org-export-get-reference destination info)))))
(org-element-property :value destination))))))
;; Links pointing to a headline: find destination and build ;; Links pointing to a headline: find destination and build
;; appropriate referencing command. ;; appropriate referencing command.
@ -1302,9 +1301,9 @@ INFO is a plist holding contextual information. See
(org-element-property :title destination) info)))))) (org-element-property :title destination) info))))))
;; Fuzzy link points to a target. Do as above. ;; Fuzzy link points to a target. Do as above.
(otherwise (otherwise
(let ((path (org-export-solidify-link-text path))) (let ((ref (org-export-get-reference destination info)))
(if (not desc) (format "\\fI%s\\fP" path) (if (not desc) (format "\\fI%s\\fP" ref)
(format "%s \\fBat\\fP \\fI%s\\fP" desc path))))))) (format "%s \\fBat\\fP \\fI%s\\fP" desc ref)))))))
;; External link with a description part. ;; External link with a description part.
((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc)) ((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc))
;; External link without a description part. ;; External link without a description part.
@ -1458,10 +1457,7 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to Groff. "Transcode a RADIO-TARGET object from Org to Groff.
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(format "%s - %s" (format "%s - %s" (org-export-get-reference radio-target info) text))
(org-export-solidify-link-text
(org-element-property :value radio-target))
text))
;;; Section ;;; Section
@ -1791,8 +1787,7 @@ a communication channel."
"Transcode a TARGET object from Org to Groff. "Transcode a TARGET object from Org to Groff.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "\\fI%s\\fP" (format "\\fI%s\\fP" (org-export-get-reference target info)))
(org-export-solidify-link-text (org-element-property :value target))))
;;; Timestamp ;;; Timestamp

View File

@ -237,10 +237,7 @@ communication channel."
(hl-home (file-name-as-directory (plist-get info :html-link-home))) (hl-home (file-name-as-directory (plist-get info :html-link-home)))
(hl-pdir (plist-get info :publishing-directory)) (hl-pdir (plist-get info :publishing-directory))
(hl-perm (org-element-property :RSS_PERMALINK headline)) (hl-perm (org-element-property :RSS_PERMALINK headline))
(anchor (anchor (org-export-get-reference headline info))
(org-export-solidify-link-text
(or (org-element-property :CUSTOM_ID headline)
(concat "sec-" (mapconcat 'number-to-string hl-number "-")))))
(category (org-rss-plain-text (category (org-rss-plain-text
(or (org-element-property :CATEGORY headline) "") info)) (or (org-element-property :CATEGORY headline) "") info))
(pubdate0 (org-element-property :PUBDATE headline)) (pubdate0 (org-element-property :PUBDATE headline))

View File

@ -720,8 +720,7 @@ used as a communication channel."
(if (not destination) contents (if (not destination) contents
(format "\\hyperlink%s{%s}{%s}" (format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "") (or (org-beamer--element-has-overlay-p link) "")
(org-export-solidify-link-text (org-export-get-reference destination info)
(org-element-property :value destination))
contents)))) contents))))
((and (member type '("custom-id" "fuzzy" "id")) ((and (member type '("custom-id" "fuzzy" "id"))
(let ((destination (if (string= type "fuzzy") (let ((destination (if (string= type "fuzzy")
@ -743,11 +742,11 @@ used as a communication channel."
label label
contents)))) contents))))
(target (target
(let ((path (org-export-solidify-link-text path))) (let ((ref (org-export-get-reference destination info)))
(if (not contents) (format "\\ref{%s}" path) (if (not contents) (format "\\ref{%s}" ref)
(format "\\hyperlink%s{%s}{%s}" (format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "") (or (org-beamer--element-has-overlay-p link) "")
path ref
contents)))))))) contents))))))))
;; Otherwise, use `latex' back-end. ;; Otherwise, use `latex' back-end.
(t (org-export-with-backend 'latex link contents info))))) (t (org-export-with-backend 'latex link contents info)))))
@ -785,7 +784,8 @@ contextual information."
'option) 'option)
;; Eventually insert contents and close environment. ;; Eventually insert contents and close environment.
contents contents
latex-type)))) latex-type)
info)))
;;;; Radio Target ;;;; Radio Target
@ -796,8 +796,7 @@ TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(format "\\hypertarget%s{%s}{%s}" (format "\\hypertarget%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p radio-target) "") (or (org-beamer--element-has-overlay-p radio-target) "")
(org-export-solidify-link-text (org-export-get-reference radio-target info)
(org-element-property :value radio-target))
text)) text))
@ -807,8 +806,7 @@ contextual information."
"Transcode a TARGET object into Beamer code. "Transcode a TARGET object into Beamer code.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "\\label{%s}" (format "\\label{%s}" (org-export-get-reference target info)))
(org-export-solidify-link-text (org-element-property :value target))))
;;;; Template ;;;; Template

View File

@ -1516,8 +1516,7 @@ arguments CAPTION and LABEL are given, use them for caption and
(format (if html5-fancy "\n<figure%s>%s%s\n</figure>" (format (if html5-fancy "\n<figure%s>%s%s\n</figure>"
"\n<div%s class=\"figure\">%s%s\n</div>") "\n<div%s class=\"figure\">%s%s\n</div>")
;; ID. ;; ID.
(if (not (org-string-nw-p label)) "" (if (org-string-nw-p label) (format " id=\"%s\"" label) "")
(format " id=\"%s\"" (org-export-solidify-link-text label)))
;; Contents. ;; Contents.
(format "\n<p>%s</p>" contents) (format "\n<p>%s</p>" contents)
;; Caption. ;; Caption.
@ -2205,9 +2204,7 @@ INFO is a plist used as a communication channel."
(org-export-get-tags headline info)))) (org-export-get-tags headline info))))
(format "<a href=\"#%s\">%s</a>" (format "<a href=\"#%s\">%s</a>"
;; Label. ;; Label.
(org-export-solidify-link-text (org-export-get-reference headline info)
(or (org-element-property :CUSTOM_ID headline)
(org-export-get-headline-id headline info)))
;; Body. ;; Body.
(concat (concat
(and (not (org-export-low-level-p headline info)) (and (not (org-export-low-level-p headline info))
@ -2235,7 +2232,8 @@ of listings as a string, or nil if it is empty."
(org-html--translate "Listing %d:" info)))) (org-html--translate "Listing %d:" info))))
(mapconcat (mapconcat
(lambda (entry) (lambda (entry)
(let ((label (org-element-property :name entry)) (let ((label (and (org-element-property :name entry)
(org-export-get-reference entry info)))
(title (org-trim (title (org-trim
(org-export-data (org-export-data
(or (org-export-get-caption entry t) (or (org-export-get-caption entry t)
@ -2246,7 +2244,7 @@ of listings as a string, or nil if it is empty."
(if (not label) (if (not label)
(concat (format initial-fmt (incf count)) " " title) (concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>" (format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label) label
(format initial-fmt (incf count)) (format initial-fmt (incf count))
title)) title))
"</li>"))) "</li>")))
@ -2271,7 +2269,8 @@ of tables as a string, or nil if it is empty."
(org-html--translate "Table %d:" info)))) (org-html--translate "Table %d:" info))))
(mapconcat (mapconcat
(lambda (entry) (lambda (entry)
(let ((label (org-element-property :name entry)) (let ((label (and (org-element-property :name entry)
(org-export-get-reference entry info)))
(title (org-trim (title (org-trim
(org-export-data (org-export-data
(or (org-export-get-caption entry t) (or (org-export-get-caption entry t)
@ -2282,7 +2281,7 @@ of tables as a string, or nil if it is empty."
(if (not label) (if (not label)
(concat (format initial-fmt (incf count)) " " title) (concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>" (format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label) label
(format initial-fmt (incf count)) (format initial-fmt (incf count))
title)) title))
"</li>"))) "</li>")))
@ -2445,26 +2444,18 @@ holding contextual information."
(full-text (funcall (plist-get info :html-format-headline-function) (full-text (funcall (plist-get info :html-format-headline-function)
todo todo-type priority text tags info)) todo todo-type priority text tags info))
(contents (or contents "")) (contents (or contents ""))
(ids (delq nil (reference (org-export-get-reference headline info))
(list (org-element-property :CUSTOM_ID headline) (extra-id (let ((id (org-element-property :ID headline)))
(org-export-get-headline-id headline info) (if (not id) ""
(org-element-property :ID headline)))) (org-html--anchor (concat "ID-" id) nil nil info)))))
(preferred-id (car ids))
(extra-ids (mapconcat
(lambda (id)
(org-html--anchor
(org-export-solidify-link-text
(if (org-uuidgen-p id) (concat "ID-" id) id))
nil nil info))
(cdr ids) "")))
(if (org-export-low-level-p headline info) (if (org-export-low-level-p headline info)
;; This is a deep sub-tree: export it as a list item. ;; This is a deep sub-tree: export it as a list item.
(let* ((type (if numberedp 'ordered 'unordered)) (let* ((type (if numberedp 'ordered 'unordered))
(itemized-body (itemized-body
(org-html-format-list-item (org-html-format-list-item
contents type nil info nil contents type nil info nil
(concat (org-html--anchor preferred-id nil nil info) (concat (org-html--anchor reference nil nil info)
extra-ids extra-id
full-text)))) full-text))))
(concat (and (org-export-first-sibling-p headline info) (concat (and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type)) (org-html-begin-plain-list type))
@ -2476,16 +2467,15 @@ holding contextual information."
;; Standard headline. Export it as a section. ;; Standard headline. Export it as a section.
(format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n" (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
(org-html--container headline info) (org-html--container headline info)
(format "outline-container-%s" (concat "outline-container-"
(or (org-element-property :CUSTOM_ID headline) (org-export-get-reference headline info))
(org-export-get-headline-id headline info)))
(concat (format "outline-%d" level) (concat (format "outline-%d" level)
(and extra-class " ") (and extra-class " ")
extra-class) extra-class)
(format "\n<h%d id=\"%s\">%s%s</h%d>\n" (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
level level
preferred-id reference
extra-ids extra-id
(concat (concat
(and numberedp (and numberedp
(format (format
@ -2533,15 +2523,13 @@ CONTENTS is nil. INFO is a plist holding contextual information."
"Transcode an INLINE-SRC-BLOCK element from Org to HTML. "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding CONTENTS holds the contents of the item. INFO is a plist holding
contextual information." contextual information."
(let* ((org-lang (org-element-property :language inline-src-block)) (let ((lang (org-element-property :language inline-src-block))
(code (org-element-property :value inline-src-block))) (code (org-html-format-code inline-src-block info))
(let ((lang (org-element-property :language inline-src-block)) (label
(code (org-html-format-code inline-src-block info)) (let ((lbl (and (org-element-property :name inline-src-block)
(label (let ((lbl (org-element-property :name inline-src-block))) (org-export-get-reference inline-src-block info))))
(if (not lbl) "" (if (not lbl) "" (format " id=\"%s\"" lbl)))))
(format " id=\"%s\"" (format "<code class=\"src src-%s\"%s>%s</code>" lang label code)))
(org-export-solidify-link-text lbl))))))
(format "<code class=\"src src-%s\"%s>%s</code>" lang label code))))
;;;; Inlinetask ;;;; Inlinetask
@ -2896,9 +2884,9 @@ INFO is a plist holding contextual information. See
(let ((destination (org-export-resolve-radio-link link info))) (let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc (if (not destination) desc
(format "<a href=\"#%s\"%s>%s</a>" (format "<a href=\"#%s\"%s>%s</a>"
(org-export-solidify-link-text (org-export-get-reference destination info)
(org-element-property :value destination)) attributes
attributes desc)))) desc))))
;; Links pointing to a headline: Find destination and build ;; Links pointing to a headline: Find destination and build
;; appropriate referencing command. ;; appropriate referencing command.
((member type '("custom-id" "fuzzy" "id")) ((member type '("custom-id" "fuzzy" "id"))
@ -2922,43 +2910,42 @@ INFO is a plist holding contextual information. See
(org-element-property :raw-link link) info)))) (org-element-property :raw-link link) info))))
;; Link points to a headline. ;; Link points to a headline.
(headline (headline
(let ((href (or (and (string= type "custom-id") (let ((href (org-export-get-reference destination info))
(org-element-property :CUSTOM_ID destination))
(org-export-get-headline-id destination info)))
;; What description to use? ;; What description to use?
(desc (desc
;; Case 1: Headline is numbered and LINK has no ;; Case 1: Headline is numbered and LINK has no
;; description. Display section number. ;; description. Display section number.
(if (and (org-export-numbered-headline-p destination info) (if (and (org-export-numbered-headline-p destination info)
(not desc)) (not desc))
(mapconcat 'number-to-string (mapconcat #'number-to-string
(org-export-get-headline-number (org-export-get-headline-number
destination info) ".") destination info) ".")
;; Case 2: Either the headline is un-numbered or ;; Case 2: Either the headline is un-numbered or
;; LINK has a custom description. Display LINK's ;; LINK has a custom description. Display LINK's
;; description or headline's title. ;; description or headline's title.
(or desc (org-export-data (org-element-property (or desc
:title destination) info))))) (org-export-data
(format "<a href=\"#%s\"%s>%s</a>" (org-element-property :title destination) info)))))
(org-export-solidify-link-text href) attributes desc))) (format "<a href=\"#%s\"%s>%s</a>" href attributes desc)))
;; Fuzzy link points to a target or an element. ;; Fuzzy link points to a target or an element.
(t (t
(let* ((path (org-export-solidify-link-text path)) (let* ((ref (org-export-get-reference destination info))
(org-html-standalone-image-predicate 'org-html--has-caption-p) (org-html-standalone-image-predicate
#'org-html--has-caption-p)
(number (cond (number (cond
(desc nil) (desc nil)
((org-html-standalone-image-p destination info) ((org-html-standalone-image-p destination info)
(org-export-get-ordinal (org-export-get-ordinal
(org-element-map destination 'link (org-element-map destination 'link
'identity info t) #'identity info t)
info 'link 'org-html-standalone-image-p)) info 'link 'org-html-standalone-image-p))
(t (org-export-get-ordinal (t (org-export-get-ordinal
destination info nil 'org-html--has-caption-p)))) destination info nil 'org-html--has-caption-p))))
(desc (cond (desc) (desc (cond (desc)
((not number) "No description for this link") ((not number) "No description for this link")
((numberp number) (number-to-string number)) ((numberp number) (number-to-string number))
(t (mapconcat 'number-to-string number "."))))) (t (mapconcat #'number-to-string number ".")))))
(format "<a href=\"#%s\"%s>%s</a>" path attributes desc)))))) (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc))))))
;; Coderef: replace link with the reference name or the ;; Coderef: replace link with the reference name or the
;; equivalent line number. ;; equivalent line number.
((string= type "coderef") ((string= type "coderef")
@ -3028,7 +3015,8 @@ the plist used as a communication channel."
'identity info t) 'identity info t)
info nil 'org-html-standalone-image-p)) info nil 'org-html-standalone-image-p))
"</span> " raw)))) "</span> " raw))))
(label (org-element-property :name paragraph))) (label (and (org-element-property :name paragraph)
(org-export-get-reference paragraph info))))
(org-html--wrap-image contents info caption label))) (org-html--wrap-image contents info caption label)))
;; Regular paragraph. ;; Regular paragraph.
(t (format "<p%s%s>\n%s</p>" (t (format "<p%s%s>\n%s</p>"
@ -3176,7 +3164,7 @@ holding contextual information."
class-num class-num
(or (org-element-property :CUSTOM_ID parent) (or (org-element-property :CUSTOM_ID parent)
section-number section-number
(org-export-get-headline-id parent info)) (org-export-get-reference parent info))
(or contents "")))))) (or contents ""))))))
;;;; Radio Target ;;;; Radio Target
@ -3185,9 +3173,8 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to HTML. "Transcode a RADIO-TARGET object from Org to HTML.
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(let ((id (org-export-solidify-link-text (let ((ref (org-export-get-reference radio-target info)))
(org-element-property :value radio-target)))) (org-html--anchor ref text nil info)))
(org-html--anchor id text nil info)))
;;;; Special Block ;;;; Special Block
@ -3225,10 +3212,9 @@ contextual information."
(let ((lang (org-element-property :language src-block)) (let ((lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block)) (caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info)) (code (org-html-format-code src-block info))
(label (let ((lbl (org-element-property :name src-block))) (label (let ((lbl (and (org-element-property :name src-block)
(if (not lbl) "" (org-export-get-reference src-block info))))
(format " id=\"%s\"" (if lbl (format " id=\"%s\"" lbl) ""))))
(org-export-solidify-link-text lbl))))))
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code) (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
(format (format
"<div class=\"org-src-container\">\n%s%s\n</div>" "<div class=\"org-src-container\">\n%s%s\n</div>"
@ -3390,14 +3376,14 @@ contextual information."
(table.el (org-html-table--table.el-table table info)) (table.el (org-html-table--table.el-table table info))
;; Case 2: Standard table. ;; Case 2: Standard table.
(t (t
(let* ((label (org-element-property :name table)) (let* ((caption (org-export-get-caption table))
(caption (org-export-get-caption table))
(number (org-export-get-ordinal (number (org-export-get-ordinal
table info nil 'org-html--has-caption-p)) table info nil #'org-html--has-caption-p))
(attributes (attributes
(org-html--make-attribute-string (org-html--make-attribute-string
(org-combine-plists (org-combine-plists
(and label (list :id (org-export-solidify-link-text label))) (and (org-element-property :name table)
(list :id (org-export-get-reference table info)))
(and (not (org-html-html5-p info)) (and (not (org-html-html5-p info))
(plist-get info :html-table-attributes)) (plist-get info :html-table-attributes))
(org-export-read-attribute :attr_html table)))) (org-export-read-attribute :attr_html table))))
@ -3445,9 +3431,8 @@ contextual information."
"Transcode a TARGET object from Org to HTML. "Transcode a TARGET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(let ((id (org-export-solidify-link-text (let ((ref (org-export-get-reference target info)))
(org-element-property :value target)))) (org-html--anchor ref nil nil info)))
(org-html--anchor id nil nil info)))
;;;; Timestamp ;;;; Timestamp

View File

@ -1050,25 +1050,25 @@ INFO is a plist holding contextual information. If there's no
caption nor label, return the empty string. caption nor label, return the empty string.
For non-floats, see `org-latex--wrap-label'." For non-floats, see `org-latex--wrap-label'."
(let* ((label (org-element-property :name element)) (let* ((label
(label-str (if (not (org-string-nw-p label)) "" (if (not (org-element-property :name element)) ""
(format "\\label{%s}" (format "\\label{%s}" (org-export-get-reference element info))))
(org-export-solidify-link-text label))))
(main (org-export-get-caption element)) (main (org-export-get-caption element))
(short (org-export-get-caption element t)) (short (org-export-get-caption element t))
(caption-from-attr-latex (org-export-read-attribute :attr_latex element :caption))) (caption-from-attr-latex
(org-export-read-attribute :attr_latex element :caption)))
(cond (cond
((org-string-nw-p caption-from-attr-latex) ((org-string-nw-p caption-from-attr-latex)
(concat caption-from-attr-latex "\n")) (concat caption-from-attr-latex "\n"))
((and (not main) (equal label-str "")) "") ((and (not main) (equal label "")) "")
((not main) (concat label-str "\n")) ((not main) (concat label "\n"))
;; Option caption format with short name. ;; Option caption format with short name.
(short (format "\\caption[%s]{%s%s}\n" (short (format "\\caption[%s]{%s%s}\n"
(org-export-data short info) (org-export-data short info)
label-str label
(org-export-data main info))) (org-export-data main info)))
;; Standard caption format. ;; Standard caption format.
(t (format "\\caption{%s%s}\n" label-str (org-export-data main info)))))) (t (format "\\caption{%s%s}\n" label (org-export-data main info))))))
(defun org-latex-guess-inputenc (header) (defun org-latex-guess-inputenc (header)
"Set the coding system in inputenc to what the buffer is. "Set the coding system in inputenc to what the buffer is.
@ -1144,15 +1144,16 @@ nil."
options options
",")) ","))
(defun org-latex--wrap-label (element output) (defun org-latex--wrap-label (element output info)
"Wrap label associated to ELEMENT around OUTPUT, if appropriate. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
This function shouldn't be used for floats. See INFO is the current export state, as a plist. This function
should not be used for floats. See
`org-latex--caption/label-string'." `org-latex--caption/label-string'."
(let ((label (org-element-property :name element))) (if (not (and (org-string-nw-p output) (org-element-property :name element)))
(if (not (and (org-string-nw-p output) (org-string-nw-p label))) output output
(concat (format "\\phantomsection\n\\label{%s}\n" (concat (format "\\phantomsection\n\\label{%s}\n"
(org-export-solidify-link-text label)) (org-export-get-reference element info))
output)))) output)))
(defun org-latex--text-markup (text markup info) (defun org-latex--text-markup (text markup info)
"Format TEXT depending on MARKUP text markup. "Format TEXT depending on MARKUP text markup.
@ -1372,8 +1373,7 @@ contextual information."
CONTENTS holds the contents of the center block. INFO is a plist CONTENTS holds the contents of the center block. INFO is a plist
holding contextual information." holding contextual information."
(org-latex--wrap-label (org-latex--wrap-label
center-block center-block (format "\\begin{center}\n%s\\end{center}" contents) info))
(format "\\begin{center}\n%s\\end{center}" contents)))
;;;; Clock ;;;; Clock
@ -1410,7 +1410,7 @@ holding contextual information."
(let* ((name (org-element-property :drawer-name drawer)) (let* ((name (org-element-property :drawer-name drawer))
(output (funcall (plist-get info :latex-format-drawer-function) (output (funcall (plist-get info :latex-format-drawer-function)
name contents))) name contents)))
(org-latex--wrap-label drawer output))) (org-latex--wrap-label drawer output info)))
;;;; Dynamic Block ;;;; Dynamic Block
@ -1419,7 +1419,7 @@ holding contextual information."
"Transcode a DYNAMIC-BLOCK element from Org to LaTeX. "Transcode a DYNAMIC-BLOCK element from Org to LaTeX.
CONTENTS holds the contents of the block. INFO is a plist CONTENTS holds the contents of the block. INFO is a plist
holding contextual information. See `org-export-data'." holding contextual information. See `org-export-data'."
(org-latex--wrap-label dynamic-block contents)) (org-latex--wrap-label dynamic-block contents info))
;;;; Entity ;;;; Entity
@ -1441,7 +1441,8 @@ information."
(org-latex--wrap-label (org-latex--wrap-label
example-block example-block
(format "\\begin{verbatim}\n%s\\end{verbatim}" (format "\\begin{verbatim}\n%s\\end{verbatim}"
(org-export-format-code-default example-block info))))) (org-export-format-code-default example-block info))
info)))
;;;; Export Block ;;;; Export Block
@ -1471,7 +1472,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
fixed-width fixed-width
(format "\\begin{verbatim}\n%s\\end{verbatim}" (format "\\begin{verbatim}\n%s\\end{verbatim}"
(org-remove-indentation (org-remove-indentation
(org-element-property :value fixed-width))))) (org-element-property :value fixed-width)))
info))
;;;; Footnote Reference ;;;; Footnote Reference
@ -1566,7 +1568,7 @@ holding contextual information."
(format "\\label{%s}\n" (format "\\label{%s}\n"
(or (and (plist-get info :latex-custom-id-labels) (or (and (plist-get info :latex-custom-id-labels)
(org-element-property :CUSTOM_ID headline)) (org-element-property :CUSTOM_ID headline))
(org-export-get-headline-id headline info)))) (org-export-get-reference headline info))))
(pre-blanks (pre-blanks
(make-string (org-element-property :pre-blank headline) 10))) (make-string (org-element-property :pre-blank headline) 10)))
(if (or (not section-fmt) (org-export-low-level-p headline info)) (if (or (not section-fmt) (org-export-low-level-p headline info))
@ -1669,7 +1671,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
horizontal-rule horizontal-rule
(format "\\rule{%s}{%s}" (format "\\rule{%s}{%s}"
(or (plist-get attr :width) "\\linewidth") (or (plist-get attr :width) "\\linewidth")
(or (plist-get attr :thickness) "0.5pt")))))) (or (plist-get attr :thickness) "0.5pt"))
info))))
;;;; Inline Src Block ;;;; Inline Src Block
@ -1871,10 +1874,9 @@ CONTENTS is nil. INFO is a plist holding contextual information."
"Transcode a LATEX-ENVIRONMENT element from Org to LaTeX. "Transcode a LATEX-ENVIRONMENT element from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual information." CONTENTS is nil. INFO is a plist holding contextual information."
(when (plist-get info :with-latex) (when (plist-get info :with-latex)
(let ((label (org-element-property :name latex-environment)) (let ((value (org-remove-indentation
(value (org-remove-indentation
(org-element-property :value latex-environment)))) (org-element-property :value latex-environment))))
(if (not (org-string-nw-p label)) value (if (not (org-element-property :name latex-environment)) value
;; Environment is labeled: label must be within the environment ;; Environment is labeled: label must be within the environment
;; (otherwise, a reference pointing to that element will count ;; (otherwise, a reference pointing to that element will count
;; the section instead). ;; the section instead).
@ -1883,7 +1885,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(goto-char (point-min)) (goto-char (point-min))
(forward-line) (forward-line)
(insert (insert
(format "\\label{%s}\n" (org-export-solidify-link-text label))) (format "\\label{%s}\n"
(org-export-get-reference latex-environment info)))
(buffer-string)))))) (buffer-string))))))
@ -2070,8 +2073,7 @@ INFO is a plist holding contextual information. See
(let ((destination (org-export-resolve-radio-link link info))) (let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc (if (not destination) desc
(format "\\hyperref[%s]{%s}" (format "\\hyperref[%s]{%s}"
(org-export-solidify-link-text (org-export-get-reference destination info)
(org-element-property :value destination))
desc)))) desc))))
;; Links pointing to a headline: Find destination and build ;; Links pointing to a headline: Find destination and build
;; appropriate referencing command. ;; appropriate referencing command.
@ -2099,7 +2101,7 @@ INFO is a plist holding contextual information. See
(and (plist-get info :latex-custom-id-labels) (and (plist-get info :latex-custom-id-labels)
(org-element-property :CUSTOM_ID destination))) (org-element-property :CUSTOM_ID destination)))
(label (or custom-label (label (or custom-label
(org-export-get-headline-id destination info)))) (org-export-get-reference destination info))))
(if (and (not desc) (if (and (not desc)
(org-export-numbered-headline-p destination info)) (org-export-numbered-headline-p destination info))
(format "\\ref{%s}" label) (format "\\ref{%s}" label)
@ -2109,9 +2111,9 @@ INFO is a plist holding contextual information. See
(org-element-property :title destination) info)))))) (org-element-property :title destination) info))))))
;; Fuzzy link points to a target. Do as above. ;; Fuzzy link points to a target. Do as above.
(otherwise (otherwise
(let ((path (org-export-solidify-link-text path))) (let ((ref (org-export-get-reference destination info)))
(if (not desc) (format "\\ref{%s}" path) (if (not desc) (format "\\ref{%s}" ref)
(format "\\hyperref[%s]{%s}" path desc))))))) (format "\\hyperref[%s]{%s}" ref desc)))))))
;; Coderef: replace link with the reference name or the ;; Coderef: replace link with the reference name or the
;; equivalent line number. ;; equivalent line number.
((string= type "coderef") ((string= type "coderef")
@ -2165,7 +2167,8 @@ contextual information."
latex-type latex-type
(or (plist-get attr :options) "") (or (plist-get attr :options) "")
contents contents
latex-type)))) latex-type)
info)))
;;;; Plain Text ;;;; Plain Text
@ -2393,8 +2396,7 @@ channel."
CONTENTS holds the contents of the block. INFO is a plist CONTENTS holds the contents of the block. INFO is a plist
holding contextual information." holding contextual information."
(org-latex--wrap-label (org-latex--wrap-label
quote-block quote-block (format "\\begin{quote}\n%s\\end{quote}" contents) info))
(format "\\begin{quote}\n%s\\end{quote}" contents)))
;;;; Radio Target ;;;; Radio Target
@ -2403,10 +2405,7 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to LaTeX. "Transcode a RADIO-TARGET object from Org to LaTeX.
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(format "\\label{%s}%s" (format "\\label{%s}%s" (org-export-get-reference radio-target info) text))
(org-export-solidify-link-text
(org-element-property :value radio-target))
text))
;;;; Section ;;;; Section
@ -3019,8 +3018,7 @@ a communication channel."
"Transcode a TARGET object from Org to LaTeX. "Transcode a TARGET object from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "\\label{%s}" (format "\\label{%s}" (org-export-get-reference target info)))
(org-export-solidify-link-text (org-element-property :value target))))
;;;; Timestamp ;;;; Timestamp
@ -3077,7 +3075,8 @@ contextual information."
"^[ \t]*\\\\\\\\$" "\\vspace*{1em}" "^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
(replace-regexp-in-string (replace-regexp-in-string
"\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n" "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n"
contents nil t) nil t) nil t)))) contents nil t) nil t) nil t))
info))

View File

@ -1073,8 +1073,7 @@ a communication channel."
"Transcode a TARGET object from Org to Man. "Transcode a TARGET object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "\\fI%s\\fP" (format "\\fI%s\\fP" (org-export-get-reference target info)))
(org-export-solidify-link-text (org-element-property :value target))))
;;; Timestamp ;;; Timestamp

View File

@ -195,11 +195,9 @@ a communication channel."
(let ((char (org-element-property :priority headline))) (let ((char (org-element-property :priority headline)))
(and char (format "[#%c] " char))))) (and char (format "[#%c] " char)))))
(anchor (anchor
(when (plist-get info :with-toc) (and (plist-get info :with-toc)
(org-html--anchor (org-html--anchor
(or (org-element-property :CUSTOM_ID headline) (org-export-get-reference headline info) nil nil info)))
(org-export-get-headline-id headline info))
nil nil info)))
;; Headline text without tags. ;; Headline text without tags.
(heading (concat todo priority title)) (heading (concat todo priority title))
(style (plist-get info :md-headline-style))) (style (plist-get info :md-headline-style)))

View File

@ -1813,7 +1813,7 @@ INFO is a plist holding contextual information."
(org-element-property :title headline) backend info)) (org-element-property :title headline) backend info))
(tags (and (plist-get info :with-tags) (tags (and (plist-get info :with-tags)
(org-export-get-tags headline info))) (org-export-get-tags headline info)))
(headline-label (org-export-get-headline-id headline info)) (headline-label (org-export-get-reference headline info))
(format-function (format-function
(if (functionp format-function) format-function (if (functionp format-function) format-function
(function* (function*
@ -1840,18 +1840,11 @@ holding contextual information."
(level (org-export-get-relative-level headline info)) (level (org-export-get-relative-level headline info))
(numbered (org-export-numbered-headline-p headline info)) (numbered (org-export-numbered-headline-p headline info))
;; Get canonical label for the headline. ;; Get canonical label for the headline.
(id (org-export-get-headline-id headline info)) (id (org-export-get-reference headline info))
;; Get user-specified labels for the headline.
(extra-ids (list (org-element-property :CUSTOM_ID headline)
(org-element-property :ID headline)))
;; Extra targets. ;; Extra targets.
(extra-targets (extra-targets
(mapconcat (lambda (x) (let ((id (org-element-property :ID headline)))
(when x (if id (org-odt--target "" (concat "ID-" id)) "")))
(let ((x (if (org-uuidgen-p x) (concat "ID-" x) x)))
(org-odt--target
"" (org-export-solidify-link-text x)))))
extra-ids ""))
;; Title. ;; Title.
(anchored-title (org-odt--target full-text id))) (anchored-title (org-odt--target full-text id)))
(cond (cond
@ -2164,9 +2157,9 @@ SHORT-CAPTION are strings."
(link (org-export-get-parent-element element)) (link (org-export-get-parent-element element))
(t element))) (t element)))
;; Get label and caption. ;; Get label and caption.
(label (org-element-property :name caption-from)) (label (org-export-get-reference element info))
(caption (org-export-get-caption caption-from)) (caption (let ((c (org-export-get-caption caption-from)))
(caption (and caption (org-export-data caption info))) (and c (org-export-data c info))))
;; FIXME: We don't use short-caption for now ;; FIXME: We don't use short-caption for now
(short-caption nil)) (short-caption nil))
(when (or label caption) (when (or label caption)
@ -2197,9 +2190,6 @@ SHORT-CAPTION are strings."
(case op (case op
;; Case 1: Handle Label definition. ;; Case 1: Handle Label definition.
(definition (definition
;; Assign an internal label, if user has not provided one
(setq label (org-export-solidify-link-text
(or label (format "%s-%s" default-category seqno))))
(cons (cons
(concat (concat
;; Sneak in a bookmark. The bookmark is used when the ;; Sneak in a bookmark. The bookmark is used when the
@ -2221,14 +2211,13 @@ SHORT-CAPTION are strings."
short-caption)) short-caption))
;; Case 2: Handle Label reference. ;; Case 2: Handle Label reference.
(reference (reference
(assert label)
(setq label (org-export-solidify-link-text label))
(let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t))) (let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
(fmt1 (car fmt)) (fmt1 (car fmt))
(fmt2 (cadr fmt))) (fmt2 (cadr fmt)))
(format "<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:sequence-ref>" (format "<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:sequence-ref>"
fmt1 label (format-spec fmt2 `((?e . ,category) fmt1
(?n . ,seqno)))))) label
(format-spec fmt2 `((?e . ,category) (?n . ,seqno))))))
(t (error "Unknown %S on label" op)))))))) (t (error "Unknown %S on label" op))))))))
@ -2668,11 +2657,10 @@ Return nil, otherwise."
;; FIXME: Handle footnote-definition footnote-reference? ;; FIXME: Handle footnote-definition footnote-reference?
(let* ((genealogy (org-element-lineage destination)) (let* ((genealogy (org-element-lineage destination))
(data (reverse genealogy)) (data (reverse genealogy))
(label (case (org-element-type destination) (label (let ((type (org-element-type destination)))
(headline (org-export-get-headline-id destination info)) (if (memq type '(headline target))
(target (org-export-get-reference destination info)
(org-element-property :value destination)) (error "FIXME: Unable to resolve %S" destination)))))
(t (error "FIXME: Resolve %S" destination)))))
(or (or
(let* ( ;; Locate top-level list. (let* ( ;; Locate top-level list.
(top-level-list (top-level-list
@ -2709,7 +2697,7 @@ Return nil, otherwise."
(let ((item-numbers (append listified-headline-nos item-numbers))) (let ((item-numbers (append listified-headline-nos item-numbers)))
(when (and item-numbers (not (memq nil item-numbers))) (when (and item-numbers (not (memq nil item-numbers)))
(format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>" (format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text label) label
(mapconcat (lambda (n) (if (not n) " " (mapconcat (lambda (n) (if (not n) " "
(concat (number-to-string n) "."))) (concat (number-to-string n) ".")))
item-numbers ""))))) item-numbers "")))))
@ -2727,7 +2715,7 @@ Return nil, otherwise."
;; We found one. ;; We found one.
(when headline (when headline
(format "<text:bookmark-ref text:reference-format=\"chapter\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>" (format "<text:bookmark-ref text:reference-format=\"chapter\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text label) label
(mapconcat 'number-to-string (org-export-get-headline-number (mapconcat 'number-to-string (org-export-get-headline-number
headline info) ".")))) headline info) "."))))
;; Case 4: Locate a regular headline in the hierarchy. Display ;; Case 4: Locate a regular headline in the hierarchy. Display
@ -2739,7 +2727,7 @@ Return nil, otherwise."
;; We found one. ;; We found one.
(when headline (when headline
(format "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>" (format "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text label) label
(let ((title (org-element-property :title headline))) (let ((title (org-element-property :title headline)))
(org-export-data title info))))) (org-export-data title info)))))
(error "FIXME?")))) (error "FIXME?"))))
@ -2782,8 +2770,7 @@ INFO is a plist holding contextual information. See
(if (not destination) desc (if (not destination) desc
(format (format
"<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>" "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
(org-export-solidify-link-text (org-export-get-reference destination info)
(org-element-property :value destination))
desc)))) desc))))
;; Links pointing to a headline: Find destination and build ;; Links pointing to a headline: Find destination and build
;; appropriate referencing command. ;; appropriate referencing command.
@ -2804,9 +2791,10 @@ INFO is a plist holding contextual information. See
;; If there's a description, create a hyperlink. ;; If there's a description, create a hyperlink.
;; Otherwise, try to provide a meaningful description. ;; Otherwise, try to provide a meaningful description.
(if (not desc) (org-odt-link--infer-description destination info) (if (not desc) (org-odt-link--infer-description destination info)
(let ((label (or (and (string= type "custom-id") (let ((label
(org-element-property :CUSTOM_ID destination)) (or (and (string= type "custom-id")
(org-export-get-headline-id destination info)))) (org-element-property :CUSTOM_ID destination))
(org-export-get-reference destination info))))
(format (format
"<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>" "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
label desc)))) label desc))))
@ -2814,29 +2802,29 @@ INFO is a plist holding contextual information. See
(target (target
;; If there's a description, create a hyperlink. ;; If there's a description, create a hyperlink.
;; Otherwise, try to provide a meaningful description. ;; Otherwise, try to provide a meaningful description.
(let ((label (org-element-property :value destination))) (format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
(format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>" (org-export-get-reference destination info)
(org-export-solidify-link-text label) (or desc (org-export-get-ordinal destination info))))
(or desc (org-export-get-ordinal destination info)))))
;; Case 4: Fuzzy link points to some element (e.g., an ;; Case 4: Fuzzy link points to some element (e.g., an
;; inline image, a math formula or a table). ;; inline image, a math formula or a table).
(otherwise (otherwise
(let ((label-reference (let ((label-reference
(ignore-errors (org-odt-format-label (ignore-errors
destination info 'reference)))) (org-odt-format-label destination info 'reference))))
(cond ((not label-reference) (cond
(org-odt-link--infer-description destination info)) ((not label-reference)
;; LINK has no description. Create (org-odt-link--infer-description destination info))
;; a cross-reference showing entity's sequence ;; LINK has no description. Create
;; number. ;; a cross-reference showing entity's sequence
((not desc) label-reference) ;; number.
;; LINK has description. Insert a hyperlink with ((not desc) label-reference)
;; user-provided description. ;; LINK has description. Insert a hyperlink with
(t ;; user-provided description.
(let ((label (org-element-property :name destination))) (t
(format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>" (format
(org-export-solidify-link-text label) "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
desc))))))))) (org-export-get-reference destination info)
desc))))))))
;; Coderef: replace link with the reference name or the ;; Coderef: replace link with the reference name or the
;; equivalent line number. ;; equivalent line number.
((string= type "coderef") ((string= type "coderef")
@ -3070,9 +3058,7 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to ODT. "Transcode a RADIO-TARGET object from Org to ODT.
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(org-odt--target (org-odt--target text (org-export-get-reference radio-target info)))
text (org-export-solidify-link-text
(org-element-property :value radio-target))))
;;;; Special Block ;;;; Special Block
@ -3681,8 +3667,7 @@ pertaining to indentation here."
"Transcode a TARGET object from Org to ODT. "Transcode a TARGET object from Org to ODT.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(let ((value (org-element-property :value target))) (org-odt--target "" (org-export-get-reference target info)))
(org-odt--target "" (org-export-solidify-link-text value))))
;;;; Timestamp ;;;; Timestamp

View File

@ -459,11 +459,9 @@ anchor name is unique."
(or (cdr (assq blob cache)) (or (cdr (assq blob cache))
(let ((name (let ((name
(org-texinfo--sanitize-node (org-texinfo--sanitize-node
(case (org-element-type blob) (if (eq (org-element-type blob) 'headline)
(headline (org-export-data (org-export-get-alt-title blob info) info)
(org-export-data (org-export-get-alt-title blob info) info)) (org-export-get-reference blob info)))))
((radio-target target) (org-element-property :value blob))
(otherwise (or (org-element-property :name blob) ""))))))
;; Ensure NAME is unique. ;; Ensure NAME is unique.
(while (rassoc name cache) (setq name (concat name "x"))) (while (rassoc name cache) (setq name (concat name "x")))
(plist-put info :texinfo-node-cache (cons (cons blob name) cache)) (plist-put info :texinfo-node-cache (cons (cons blob name) cache))
@ -1205,8 +1203,7 @@ holding contextual information."
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(format "@anchor{%s}%s" (format "@anchor{%s}%s"
(org-export-solidify-link-text (org-export-get-reference radio-target info)
(org-element-property :value radio-target))
text)) text))
;;;; Section ;;;; Section
@ -1345,8 +1342,7 @@ a communication channel."
"Transcode a TARGET object from Org to Texinfo. "Transcode a TARGET object from Org to Texinfo.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "@anchor{%s}" (format "@anchor{%s}" (org-export-get-reference target info)))
(org-export-solidify-link-text (org-element-property :value target))))
;;;; Timestamp ;;;; Timestamp