summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-09-30 23:56:00 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-09-30 23:57:45 +0200
commit934208ece1b74b7bc0e70bc07a3637a2e467a1fb (patch)
tree3f8a1fd13b45cb7d144c1cd5c55eb7c703a1312c
parent324561944506eb1a5efcb2276cfef1383b76bc6e (diff)
downloadorg-mode-934208ece1b74b7bc0e70bc07a3637a2e467a1fb.tar.gz
org-element: Allow links in captions
* lisp/org-element.el (org-element-object-restrictions): Allow links in caption. Also allow inline-src-blocks and inline-babel-calls. * contrib/lisp/org-e-ascii.el (org-e-ascii--unique-links): Handle links in captions. (org-e-ascii--describe-links): Small refactoring. (org-e-ascii-template--document-title): Handle links in document properties.
-rw-r--r--contrib/lisp/org-e-ascii.el32
-rw-r--r--lisp/org-element.el3
2 files changed, 22 insertions, 13 deletions
diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el
index c78bd1a..5ebd3b0 100644
--- a/contrib/lisp/org-e-ascii.el
+++ b/contrib/lisp/org-e-ascii.el
@@ -734,7 +734,12 @@ is a plist used as a communication channel."
(let ((footprint
(cons (org-element-property :raw-link link)
(org-element-contents link))))
- (unless (member footprint seen)
+ ;; Ignore LINK if it hasn't been translated already.
+ ;; It can happen if it is located in an affiliated
+ ;; keyword that was ignored.
+ (when (and (org-string-nw-p
+ (gethash link (plist-get info :exported-data)))
+ (not (member footprint seen)))
(push footprint seen) link)))))
;; If at a section, find parent headline, if any, in order to
;; count links that might be in the title.
@@ -743,7 +748,7 @@ is a plist used as a communication channel."
(or (org-export-get-parent-headline element) element))))
;; Get all links in HEADLINE.
(org-element-map
- headline 'link (lambda (link) (funcall unique-link-p link)) info)))
+ headline 'link (lambda (l) (funcall unique-link-p l)) info nil nil t)))
(defun org-e-ascii--describe-links (links width info)
"Return a string describing a list of links.
@@ -756,8 +761,8 @@ channel."
(lambda (link)
(let ((type (org-element-property :type link))
(anchor (let ((desc (org-element-contents link)))
- (if (not desc) (org-element-property :raw-link link)
- (org-export-data desc info)))))
+ (if desc (org-export-data desc info)
+ (org-element-property :raw-link link)))))
(cond
;; Coderefs, radio links and fuzzy links are ignored.
((member type '("coderef" "radio" "fuzzy")) nil)
@@ -803,14 +808,17 @@ INFO is a plist used as a communication channel."
(defun org-e-ascii-template--document-title (info)
"Return document title, as a string.
INFO is a plist used as a communication channel."
- (let ((text-width org-e-ascii-text-width)
- (title (org-export-data (plist-get info :title) info))
- (author (and (plist-get info :with-author)
- (let ((auth (plist-get info :author)))
- (and auth (org-export-data auth info)))))
- (email (and (plist-get info :with-email)
- (org-export-data (plist-get info :email) info)))
- (date (org-export-data (plist-get info :date) info)))
+ (let* ((text-width org-e-ascii-text-width)
+ ;; Links in the title will not be resolved later, so we make
+ ;; sure their path is located right after them.
+ (org-e-ascii-links-to-notes nil)
+ (title (org-export-data (plist-get info :title) info))
+ (author (and (plist-get info :with-author)
+ (let ((auth (plist-get info :author)))
+ (and auth (org-export-data auth info)))))
+ (email (and (plist-get info :with-email)
+ (org-export-data (plist-get info :email) info)))
+ (date (org-export-data (plist-get info :date) info)))
;; There are two types of title blocks depending on the presence
;; of a title to display.
(if (string= title "")
diff --git a/lisp/org-element.el b/lisp/org-element.el
index eb33e3c..8a70791 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -304,7 +304,8 @@ a secondary string.")
link radio-target sub/superscript target text-markup timestamp)
(item export-snippet footnote-reference inline-babel-call latex-or-entity
link macro radio-target sub/superscript target text-markup)
- (keyword latex-or-entity macro sub/superscript text-markup)
+ (keyword inline-babel-call inline-src-block latex-or-entity link macro
+ sub/superscript text-markup)
(link export-snippet inline-babel-call inline-src-block latex-or-entity link
sub/superscript text-markup)
(paragraph export-snippet footnote-reference inline-babel-call