diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-05-20 13:57:58 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-05-20 13:57:58 +0200 |
commit | 65c0e18892829ef2adb51ff3e486e7e239a615ab (patch) | |
tree | 78b40799576272b063c642bf12591e461b6bf6ac | |
parent | c91bcb368f0ec483467da9cbe607eb89ac505f5b (diff) | |
download | org-mode-65c0e18892829ef2adb51ff3e486e7e239a615ab.tar.gz |
org-e-ascii: Ensure consistent cross-referencing between elements and links
* contrib/lisp/org-e-ascii.el (org-e-ascii--has-caption-or-name-p):
New function.
(org-e-ascii--build-caption, org-e-ascii-link): Use new function.
This patch ensures only elements with a name or a caption are counted
in when a fuzzy link pointing to an element is resolved.
-rw-r--r-- | contrib/lisp/org-e-ascii.el | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el index 36198dd..fd96237 100644 --- a/contrib/lisp/org-e-ascii.el +++ b/contrib/lisp/org-e-ascii.el @@ -676,6 +676,16 @@ title." (concat "\n" (make-string (length first-part) under-char)))))))) +(defun org-e-ascii--has-caption-or-name-p (element info) + "Non-nil when ELEMENT has a caption or a name affiliated keyword. + +INFO is a plist used as a communication channel. + +This function is meant to be used as a predicate for +`org-export-get-ordinal'." + (or (org-element-property :caption element) + (org-element-property :name element))) + (defun org-e-ascii--build-caption (element info) "Return caption string for ELEMENT, if applicable. @@ -692,9 +702,7 @@ keyword." ;; src-block with either a caption or a name. (let ((reference (org-export-get-ordinal - element info nil - (lambda (el info) (or (org-element-property :caption el) - (org-element-property :name el))))) + element info nil 'org-e-ascii--has-caption-or-name-p)) (title-fmt (org-e-ascii--translate (case (org-element-type element) (table "Table %d: %s") @@ -1458,11 +1466,14 @@ INFO is a plist holding contextual information." ;; targets. ((string= type "fuzzy") (let ((destination (org-export-resolve-fuzzy-link link info))) - ;; Ignore invisible "#+target: path". + ;; Ignore invisible "#+TARGET: path". (unless (eq (org-element-type destination) 'keyword) (if (org-string-nw-p desc) desc (when destination - (let ((number (org-export-get-ordinal destination info))) + (let ((number + (org-export-get-ordinal + destination info nil + 'org-e-ascii--has-caption-or-name-p))) (when number (if (atom number) (number-to-string number) (mapconcat 'number-to-string number "."))))))))) |