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

View File

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

View File

@ -720,8 +720,7 @@ used as a communication channel."
(if (not destination) contents
(format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "")
(org-export-solidify-link-text
(org-element-property :value destination))
(org-export-get-reference destination info)
contents))))
((and (member type '("custom-id" "fuzzy" "id"))
(let ((destination (if (string= type "fuzzy")
@ -743,11 +742,11 @@ used as a communication channel."
label
contents))))
(target
(let ((path (org-export-solidify-link-text path)))
(if (not contents) (format "\\ref{%s}" path)
(let ((ref (org-export-get-reference destination info)))
(if (not contents) (format "\\ref{%s}" ref)
(format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "")
path
ref
contents))))))))
;; Otherwise, use `latex' back-end.
(t (org-export-with-backend 'latex link contents info)))))
@ -785,7 +784,8 @@ contextual information."
'option)
;; Eventually insert contents and close environment.
contents
latex-type))))
latex-type)
info)))
;;;; Radio Target
@ -796,8 +796,7 @@ TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "\\hypertarget%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p radio-target) "")
(org-export-solidify-link-text
(org-element-property :value radio-target))
(org-export-get-reference radio-target info)
text))
@ -807,8 +806,7 @@ contextual information."
"Transcode a TARGET object into Beamer code.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format "\\label{%s}"
(org-export-solidify-link-text (org-element-property :value target))))
(format "\\label{%s}" (org-export-get-reference target info)))
;;;; 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>"
"\n<div%s class=\"figure\">%s%s\n</div>")
;; ID.
(if (not (org-string-nw-p label)) ""
(format " id=\"%s\"" (org-export-solidify-link-text label)))
(if (org-string-nw-p label) (format " id=\"%s\"" label) "")
;; Contents.
(format "\n<p>%s</p>" contents)
;; Caption.
@ -2205,9 +2204,7 @@ INFO is a plist used as a communication channel."
(org-export-get-tags headline info))))
(format "<a href=\"#%s\">%s</a>"
;; Label.
(org-export-solidify-link-text
(or (org-element-property :CUSTOM_ID headline)
(org-export-get-headline-id headline info)))
(org-export-get-reference headline info)
;; Body.
(concat
(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))))
(mapconcat
(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
(org-export-data
(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)
(concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label)
label
(format initial-fmt (incf count))
title))
"</li>")))
@ -2271,7 +2269,8 @@ of tables as a string, or nil if it is empty."
(org-html--translate "Table %d:" info))))
(mapconcat
(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
(org-export-data
(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)
(concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label)
label
(format initial-fmt (incf count))
title))
"</li>")))
@ -2445,26 +2444,18 @@ holding contextual information."
(full-text (funcall (plist-get info :html-format-headline-function)
todo todo-type priority text tags info))
(contents (or contents ""))
(ids (delq nil
(list (org-element-property :CUSTOM_ID headline)
(org-export-get-headline-id headline info)
(org-element-property :ID headline))))
(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) "")))
(reference (org-export-get-reference headline info))
(extra-id (let ((id (org-element-property :ID headline)))
(if (not id) ""
(org-html--anchor (concat "ID-" id) nil nil info)))))
(if (org-export-low-level-p headline info)
;; This is a deep sub-tree: export it as a list item.
(let* ((type (if numberedp 'ordered 'unordered))
(itemized-body
(org-html-format-list-item
contents type nil info nil
(concat (org-html--anchor preferred-id nil nil info)
extra-ids
(concat (org-html--anchor reference nil nil info)
extra-id
full-text))))
(concat (and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type))
@ -2476,16 +2467,15 @@ holding contextual information."
;; Standard headline. Export it as a section.
(format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
(org-html--container headline info)
(format "outline-container-%s"
(or (org-element-property :CUSTOM_ID headline)
(org-export-get-headline-id headline info)))
(concat "outline-container-"
(org-export-get-reference headline info))
(concat (format "outline-%d" level)
(and extra-class " ")
extra-class)
(format "\n<h%d id=\"%s\">%s%s</h%d>\n"
level
preferred-id
extra-ids
reference
extra-id
(concat
(and numberedp
(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.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((org-lang (org-element-property :language inline-src-block))
(code (org-element-property :value inline-src-block)))
(let ((lang (org-element-property :language inline-src-block))
(code (org-html-format-code inline-src-block info))
(label (let ((lbl (org-element-property :name inline-src-block)))
(if (not lbl) ""
(format " id=\"%s\""
(org-export-solidify-link-text lbl))))))
(format "<code class=\"src src-%s\"%s>%s</code>" lang label code))))
(let ((lang (org-element-property :language inline-src-block))
(code (org-html-format-code inline-src-block info))
(label
(let ((lbl (and (org-element-property :name inline-src-block)
(org-export-get-reference inline-src-block info))))
(if (not lbl) "" (format " id=\"%s\"" lbl)))))
(format "<code class=\"src src-%s\"%s>%s</code>" lang label code)))
;;;; Inlinetask
@ -2896,9 +2884,9 @@ INFO is a plist holding contextual information. See
(let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc
(format "<a href=\"#%s\"%s>%s</a>"
(org-export-solidify-link-text
(org-element-property :value destination))
attributes desc))))
(org-export-get-reference destination info)
attributes
desc))))
;; Links pointing to a headline: Find destination and build
;; appropriate referencing command.
((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))))
;; Link points to a headline.
(headline
(let ((href (or (and (string= type "custom-id")
(org-element-property :CUSTOM_ID destination))
(org-export-get-headline-id destination info)))
(let ((href (org-export-get-reference destination info))
;; What description to use?
(desc
;; Case 1: Headline is numbered and LINK has no
;; description. Display section number.
(if (and (org-export-numbered-headline-p destination info)
(not desc))
(mapconcat 'number-to-string
(mapconcat #'number-to-string
(org-export-get-headline-number
destination info) ".")
;; Case 2: Either the headline is un-numbered or
;; LINK has a custom description. Display LINK's
;; description or headline's title.
(or desc (org-export-data (org-element-property
:title destination) info)))))
(format "<a href=\"#%s\"%s>%s</a>"
(org-export-solidify-link-text href) attributes desc)))
(or desc
(org-export-data
(org-element-property :title destination) info)))))
(format "<a href=\"#%s\"%s>%s</a>" href attributes desc)))
;; Fuzzy link points to a target or an element.
(t
(let* ((path (org-export-solidify-link-text path))
(org-html-standalone-image-predicate 'org-html--has-caption-p)
(let* ((ref (org-export-get-reference destination info))
(org-html-standalone-image-predicate
#'org-html--has-caption-p)
(number (cond
(desc nil)
((org-html-standalone-image-p destination info)
(org-export-get-ordinal
(org-element-map destination 'link
'identity info t)
#'identity info t)
info 'link 'org-html-standalone-image-p))
(t (org-export-get-ordinal
destination info nil 'org-html--has-caption-p))))
(desc (cond (desc)
((not number) "No description for this link")
((numberp number) (number-to-string number))
(t (mapconcat 'number-to-string number ".")))))
(format "<a href=\"#%s\"%s>%s</a>" path attributes desc))))))
(t (mapconcat #'number-to-string number ".")))))
(format "<a href=\"#%s\"%s>%s</a>" ref attributes desc))))))
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
@ -3028,7 +3015,8 @@ the plist used as a communication channel."
'identity info t)
info nil 'org-html-standalone-image-p))
"</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)))
;; Regular paragraph.
(t (format "<p%s%s>\n%s</p>"
@ -3176,7 +3164,7 @@ holding contextual information."
class-num
(or (org-element-property :CUSTOM_ID parent)
section-number
(org-export-get-headline-id parent info))
(org-export-get-reference parent info))
(or contents ""))))))
;;;; Radio Target
@ -3185,9 +3173,8 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to HTML.
TEXT is the text of the target. INFO is a plist holding
contextual information."
(let ((id (org-export-solidify-link-text
(org-element-property :value radio-target))))
(org-html--anchor id text nil info)))
(let ((ref (org-export-get-reference radio-target info)))
(org-html--anchor ref text nil info)))
;;;; Special Block
@ -3225,10 +3212,9 @@ contextual information."
(let ((lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info))
(label (let ((lbl (org-element-property :name src-block)))
(if (not lbl) ""
(format " id=\"%s\""
(org-export-solidify-link-text lbl))))))
(label (let ((lbl (and (org-element-property :name src-block)
(org-export-get-reference src-block info))))
(if lbl (format " id=\"%s\"" lbl) ""))))
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
(format
"<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))
;; Case 2: Standard table.
(t
(let* ((label (org-element-property :name table))
(caption (org-export-get-caption table))
(let* ((caption (org-export-get-caption table))
(number (org-export-get-ordinal
table info nil 'org-html--has-caption-p))
table info nil #'org-html--has-caption-p))
(attributes
(org-html--make-attribute-string
(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))
(plist-get info :html-table-attributes))
(org-export-read-attribute :attr_html table))))
@ -3445,9 +3431,8 @@ contextual information."
"Transcode a TARGET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((id (org-export-solidify-link-text
(org-element-property :value target))))
(org-html--anchor id nil nil info)))
(let ((ref (org-export-get-reference target info)))
(org-html--anchor ref nil nil info)))
;;;; 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.
For non-floats, see `org-latex--wrap-label'."
(let* ((label (org-element-property :name element))
(label-str (if (not (org-string-nw-p label)) ""
(format "\\label{%s}"
(org-export-solidify-link-text label))))
(let* ((label
(if (not (org-element-property :name element)) ""
(format "\\label{%s}" (org-export-get-reference element info))))
(main (org-export-get-caption element))
(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
((org-string-nw-p caption-from-attr-latex)
(concat caption-from-attr-latex "\n"))
((and (not main) (equal label-str "")) "")
((not main) (concat label-str "\n"))
((and (not main) (equal label "")) "")
((not main) (concat label "\n"))
;; Option caption format with short name.
(short (format "\\caption[%s]{%s%s}\n"
(org-export-data short info)
label-str
label
(org-export-data main info)))
;; 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)
"Set the coding system in inputenc to what the buffer is.
@ -1144,15 +1144,16 @@ nil."
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.
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'."
(let ((label (org-element-property :name element)))
(if (not (and (org-string-nw-p output) (org-string-nw-p label))) output
(concat (format "\\phantomsection\n\\label{%s}\n"
(org-export-solidify-link-text label))
output))))
(if (not (and (org-string-nw-p output) (org-element-property :name element)))
output
(concat (format "\\phantomsection\n\\label{%s}\n"
(org-export-get-reference element info))
output)))
(defun org-latex--text-markup (text markup info)
"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
holding contextual information."
(org-latex--wrap-label
center-block
(format "\\begin{center}\n%s\\end{center}" contents)))
center-block (format "\\begin{center}\n%s\\end{center}" contents) info))
;;;; Clock
@ -1410,7 +1410,7 @@ holding contextual information."
(let* ((name (org-element-property :drawer-name drawer))
(output (funcall (plist-get info :latex-format-drawer-function)
name contents)))
(org-latex--wrap-label drawer output)))
(org-latex--wrap-label drawer output info)))
;;;; Dynamic Block
@ -1419,7 +1419,7 @@ holding contextual information."
"Transcode a DYNAMIC-BLOCK element from Org to LaTeX.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information. See `org-export-data'."
(org-latex--wrap-label dynamic-block contents))
(org-latex--wrap-label dynamic-block contents info))
;;;; Entity
@ -1441,7 +1441,8 @@ information."
(org-latex--wrap-label
example-block
(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
@ -1471,7 +1472,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
fixed-width
(format "\\begin{verbatim}\n%s\\end{verbatim}"
(org-remove-indentation
(org-element-property :value fixed-width)))))
(org-element-property :value fixed-width)))
info))
;;;; Footnote Reference
@ -1566,7 +1568,7 @@ holding contextual information."
(format "\\label{%s}\n"
(or (and (plist-get info :latex-custom-id-labels)
(org-element-property :CUSTOM_ID headline))
(org-export-get-headline-id headline info))))
(org-export-get-reference headline info))))
(pre-blanks
(make-string (org-element-property :pre-blank headline) 10)))
(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
(format "\\rule{%s}{%s}"
(or (plist-get attr :width) "\\linewidth")
(or (plist-get attr :thickness) "0.5pt"))))))
(or (plist-get attr :thickness) "0.5pt"))
info))))
;;;; 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.
CONTENTS is nil. INFO is a plist holding contextual information."
(when (plist-get info :with-latex)
(let ((label (org-element-property :name latex-environment))
(value (org-remove-indentation
(let ((value (org-remove-indentation
(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
;; (otherwise, a reference pointing to that element will count
;; the section instead).
@ -1883,7 +1885,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(goto-char (point-min))
(forward-line)
(insert
(format "\\label{%s}\n" (org-export-solidify-link-text label)))
(format "\\label{%s}\n"
(org-export-get-reference latex-environment info)))
(buffer-string))))))
@ -2070,8 +2073,7 @@ INFO is a plist holding contextual information. See
(let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc
(format "\\hyperref[%s]{%s}"
(org-export-solidify-link-text
(org-element-property :value destination))
(org-export-get-reference destination info)
desc))))
;; Links pointing to a headline: Find destination and build
;; appropriate referencing command.
@ -2099,7 +2101,7 @@ INFO is a plist holding contextual information. See
(and (plist-get info :latex-custom-id-labels)
(org-element-property :CUSTOM_ID destination)))
(label (or custom-label
(org-export-get-headline-id destination info))))
(org-export-get-reference destination info))))
(if (and (not desc)
(org-export-numbered-headline-p destination info))
(format "\\ref{%s}" label)
@ -2109,9 +2111,9 @@ INFO is a plist holding contextual information. See
(org-element-property :title destination) info))))))
;; Fuzzy link points to a target. Do as above.
(otherwise
(let ((path (org-export-solidify-link-text path)))
(if (not desc) (format "\\ref{%s}" path)
(format "\\hyperref[%s]{%s}" path desc)))))))
(let ((ref (org-export-get-reference destination info)))
(if (not desc) (format "\\ref{%s}" ref)
(format "\\hyperref[%s]{%s}" ref desc)))))))
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
@ -2165,7 +2167,8 @@ contextual information."
latex-type
(or (plist-get attr :options) "")
contents
latex-type))))
latex-type)
info)))
;;;; Plain Text
@ -2393,8 +2396,7 @@ channel."
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(org-latex--wrap-label
quote-block
(format "\\begin{quote}\n%s\\end{quote}" contents)))
quote-block (format "\\begin{quote}\n%s\\end{quote}" contents) info))
;;;; Radio Target
@ -2403,10 +2405,7 @@ holding contextual information."
"Transcode a RADIO-TARGET object from Org to LaTeX.
TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "\\label{%s}%s"
(org-export-solidify-link-text
(org-element-property :value radio-target))
text))
(format "\\label{%s}%s" (org-export-get-reference radio-target info) text))
;;;; Section
@ -3019,8 +3018,7 @@ a communication channel."
"Transcode a TARGET object from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format "\\label{%s}"
(org-export-solidify-link-text (org-element-property :value target))))
(format "\\label{%s}" (org-export-get-reference target info)))
;;;; Timestamp
@ -3077,7 +3075,8 @@ contextual information."
"^[ \t]*\\\\\\\\$" "\\vspace*{1em}"
(replace-regexp-in-string
"\\([ \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.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format "\\fI%s\\fP"
(org-export-solidify-link-text (org-element-property :value target))))
(format "\\fI%s\\fP" (org-export-get-reference target info)))
;;; Timestamp

View File

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

View File

@ -459,11 +459,9 @@ anchor name is unique."
(or (cdr (assq blob cache))
(let ((name
(org-texinfo--sanitize-node
(case (org-element-type blob)
(headline
(org-export-data (org-export-get-alt-title blob info) info))
((radio-target target) (org-element-property :value blob))
(otherwise (or (org-element-property :name blob) ""))))))
(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))
@ -1205,8 +1203,7 @@ holding contextual information."
TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "@anchor{%s}%s"
(org-export-solidify-link-text
(org-element-property :value radio-target))
(org-export-get-reference radio-target info)
text))
;;;; Section
@ -1345,8 +1342,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-solidify-link-text (org-element-property :value target))))
(format "@anchor{%s}" (org-export-get-reference target info)))
;;;; Timestamp