diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-01-19 17:05:02 +0100 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-01-19 17:07:18 +0100 |
commit | c12246931f7cdf8fab8fe172590b20fcacf23912 (patch) | |
tree | 41f4c84568c5b3342a04e915525f877a6ef05d62 | |
parent | 95e71f5705488626c73a512f90e8486dbf1fb312 (diff) | |
download | org-mode-c12246931f7cdf8fab8fe172590b20fcacf23912.tar.gz |
org-export: Add a function to resolve id or custom-id links
* contrib/lisp/org-export.el (org-export-resolve-id-link): New function.
-rw-r--r-- | contrib/lisp/org-export.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index f595a20..d94ad8b 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2224,6 +2224,10 @@ Return the parsed tree." ;; (i.e. links with "fuzzy" as type) within the parsed tree, and ;; returns an appropriate unique identifier when found, or nil. +;; `org-export-resolve-id-link' returns the first headline with +;; specified id or custom-id in parse tree, or nil when none was +;; found. + ;; `org-export-resolve-coderef' associates a reference to a line ;; number in the element it belongs, or returns the reference itself ;; when the element isn't numbered. @@ -2307,6 +2311,22 @@ Assume LINK type is \"fuzzy\"." ;; No match with a common ancestor: try the full parse-tree. (funcall find-headline path (plist-get info :parse-tree))))))) +(defun org-export-resolve-id-link (link info) + "Return headline referenced as LINK destination. + +INFO is a plist used as a communication channel. + +Return value can be an headline element or nil. Assume LINK type +is either \"id\" or \"custom-id\"." + (let ((id (org-element-get-property :path link))) + (org-element-map + (plist-get info :parse-tree) 'headline + (lambda (headline local) + (when (or (string= (org-element-get-property :id headline) id) + (string= (org-element-get-property :custom-id headline) id)) + headline)) + info 'first-match))) + (defun org-export-resolve-coderef (ref info) "Resolve a code reference REF. |