ox: Implement `org-export-get-reference'
* lisp/ox.el (org-export-get-reference): New function. * etc/ORG-NEWS: Signal new function.
This commit is contained in:
parent
51d83b9165
commit
160820bc94
|
@ -279,6 +279,7 @@ in the output, depending on the parameters.
|
|||
*** Extend ~org-export-first-sibling-p~ and ~org-export-last-sibling-p~
|
||||
These functions now support any element or object, not only headlines.
|
||||
*** New function: ~org-export-table-row-in-header-p~
|
||||
*** New function: ~org-export-get-reference~
|
||||
*** New function: ~org-element-lineage~
|
||||
This function deprecates ~org-export-get-genealogy~. It also provides
|
||||
more features. See docstring for details.
|
||||
|
|
22
lisp/ox.el
22
lisp/ox.el
|
@ -4165,9 +4165,31 @@ has type \"radio\"."
|
|||
|
||||
;;;; For References
|
||||
;;
|
||||
;; `org-export-get-reference' associate a unique reference for any
|
||||
;; object or element.
|
||||
;;
|
||||
;; `org-export-get-ordinal' associates a sequence number to any object
|
||||
;; or element.
|
||||
|
||||
(defun org-export-get-reference (datum info)
|
||||
"Return a unique reference for DATUM, as a string.
|
||||
DATUM is either an element or an object. INFO is the current
|
||||
export state, as a plist. Returned reference consists of
|
||||
alphanumeric characters only."
|
||||
(let ((type (org-element-type datum))
|
||||
(cache (or (plist-get info :internal-references)
|
||||
(let ((h (make-hash-table :test #'eq)))
|
||||
(plist-put info :internal-references h)
|
||||
h))))
|
||||
(or (gethash datum cache)
|
||||
(puthash datum
|
||||
(format "org%s%d"
|
||||
(if type
|
||||
(replace-regexp-in-string "-" "" (symbol-name type))
|
||||
"secondarystring")
|
||||
(incf (gethash type cache 0)))
|
||||
cache))))
|
||||
|
||||
(defun org-export-get-ordinal (element info &optional types predicate)
|
||||
"Return ordinal number of an element or object.
|
||||
|
||||
|
|
Loading…
Reference in New Issue