From 312e22568550c7e996cdce73494a69247b95f8fc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 28 Apr 2012 11:33:16 +0200 Subject: [PATCH] org-export: Remove unnecessary back-end arguments * contrib/lisp/org-e-ascii.el (org-e-ascii--build-title, org-e-ascii--build-caption, org-e-ascii--list-listings, org-e-ascii--list-tables, org-e-ascii--describe-links, org-e-ascii-template--document-title, org-e-ascii-dynamic-block, org-e-ascii-inlinetask, org-e-ascii-item, org-e-ascii-link, org-e-ascii-quote-section, org-e-ascii--table-cell-width): Do not provide back-end symbol. * contrib/lisp/org-e-html.el (org-e-html--caption/label-string, org-e-html-footnote-section, org-e-html-template, org-e-html-dynamic-block, org-e-html-format-headline--wrap, org-e-html-headline, org-e-html-item, org-e-html-link, org-e-html-time-stamp): Do not provide back-end symbol. * contrib/lisp/org-e-latex.el (org-e-latex--caption/label-string, org-e-latex-template, org-e-latex-dynamic-block, org-e-latex-footnote-reference, org-e-latex-headline, org-e-latex-inlinetask, org-e-latex-item, org-e-latex-link, org-e-latex-src-block): Do not provide back-end symbol. * contrib/lisp/org-e-odt.el (org-e-odt-format-preamble, org-e-odt-format-label, org-e-odt-write-manifest-file, org-e-odt--caption/label-string, org-e-odt-dynamic-block, org-e-odt-format-headline--wrap, org-e-odt-headline, org-e-odt-item, org-e-odt-latex-environment, org-e-odt-link, org-e-odt-src-block, org-e-odt-time-stamp): Do not provide back-end symbol. * contrib/lisp/org-export.el (org-export-get-environment): Provide back-end symbol under `:back-end' property. (org-export-collect-tree-properties, org-export-data, org-export-filter-verbatim-functions, org-export-install-filters, org-export-as, org-export-expand-macro, org-export-filter-apply-functions, org-export-secondary-string): Remove back-end references. * testing/lisp/test-org-export.el: Update tests. Back-end can be found in communication channel with (plist-get info :back-end). Hence back-ends do not have to hard-code their name in any transcoder. It will allow to derive a back-end from another one. --- contrib/lisp/org-e-ascii.el | 62 +++++++--------- contrib/lisp/org-e-html.el | 64 +++++++---------- contrib/lisp/org-e-latex.el | 53 ++++++-------- contrib/lisp/org-e-odt.el | 82 ++++++++++----------- contrib/lisp/org-export.el | 92 +++++++++++------------- testing/lisp/test-org-export.el | 122 ++++++++++++++------------------ 6 files changed, 205 insertions(+), 270 deletions(-) diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el index 05f430db1..b6e375393 100644 --- a/contrib/lisp/org-e-ascii.el +++ b/contrib/lisp/org-e-ascii.el @@ -42,13 +42,12 @@ (declare-function org-element-time-stamp-interpreter "org-element" (time-stamp contents)) -(declare-function org-export-clean-table "org-export" (table specialp)) (declare-function org-export-collect-footnote-definitions "org-export" (data info)) (declare-function org-export-collect-headlines "org-export" (info &optional n)) (declare-function org-export-collect-listings "org-export" (info)) (declare-function org-export-collect-tables "org-export" (info)) -(declare-function org-export-data "org-export" (data backend info)) +(declare-function org-export-data "org-export" (data info)) (declare-function org-export-expand-macro "org-export" (macro info)) (declare-function org-export-format-code-default "org-export" (element info)) (declare-function org-export-get-coderef-format "org-export" (path desc)) @@ -58,7 +57,6 @@ (element info &optional types predicate)) (declare-function org-export-get-parent-headline "org-export" (blob info)) (declare-function org-export-get-relative-level "org-export" (headline info)) -(declare-function org-export-included-file "org-export" (keyword backend info)) (declare-function org-export-low-level-p "org-export" (headline info)) (declare-function org-export-output-file-name "org-export" (extension &optional subtreep pub-dir)) @@ -66,9 +64,7 @@ (declare-function org-export-resolve-fuzzy-link "org-export" (link info)) (declare-function org-export-resolve-id-link "org-export" (link info)) (declare-function org-export-resolve-ref-link "org-export" (link info)) -(declare-function org-export-secondary-string - "org-export" (secondary backend info)) -(declare-function org-export-table-format-info "org-export" (table)) +(declare-function org-export-secondary-string "org-export" (secondary info)) (declare-function org-export-to-file "org-export" (backend file &optional subtreep visible-only body-only ext-plist)) @@ -592,13 +588,12 @@ title." (org-export-get-headline-number element info) ".") " "))) (text (org-export-secondary-string - (org-element-property :title element) 'e-ascii info)) + (org-element-property :title element) info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword element))) (and todo - (concat (org-export-secondary-string todo 'e-ascii info) - " "))))) + (concat (org-export-secondary-string todo info) " "))))) (tags (and (not notags) (plist-get info :with-tags) (org-element-property :tags element))) @@ -652,7 +647,7 @@ keyword." (format title-fmt reference (if (not caption) name - (org-export-secondary-string (car caption) 'e-ascii info))) + (org-export-secondary-string (car caption) info))) (org-e-ascii--current-text-width element info) info))))) (defun org-e-ascii--build-toc (info &optional n keyword) @@ -719,7 +714,7 @@ generation. INFO is a plist used as a communication channel." (if (not caption) (org-element-property :name src-block) (org-export-secondary-string ;; Use short name in priority, if available. - (or (cdr caption) (car caption)) 'e-ascii info))) + (or (cdr caption) (car caption)) info))) (- text-width (length initial-text)) info) (length initial-text)))))) (org-export-collect-listings info) "\n"))))) @@ -758,7 +753,7 @@ generation. INFO is a plist used as a communication channel." (if (not caption) (org-element-property :name table) ;; Use short name in priority, if available. (org-export-secondary-string - (or (cdr caption) (car caption)) 'e-ascii info))) + (or (cdr caption) (car caption)) info))) (- text-width (length initial-text)) info) (length initial-text)))))) (org-export-collect-tables info) "\n"))))) @@ -817,7 +812,7 @@ channel." (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-secondary-string desc 'e-ascii info))))) + (org-export-secondary-string desc info))))) (cond ;; Coderefs, radio links and fuzzy links are ignored. ((member type '("coderef" "radio" "fuzzy")) nil) @@ -855,16 +850,12 @@ channel." "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-secondary-string - (plist-get info :title) 'e-ascii info)) - (author - (and (plist-get info :with-author) - (let ((auth (plist-get info :author))) - (and auth (org-export-secondary-string auth 'e-ascii info))))) - (email - (and (plist-get info :with-email) - (org-export-secondary-string - (plist-get info :email) 'e-ascii info))) + (title (org-export-secondary-string (plist-get info :title) info)) + (author (and (plist-get info :with-author) + (let ((auth (plist-get info :author))) + (and auth (org-export-secondary-string auth info))))) + (email (and (plist-get info :with-email) + (org-export-secondary-string (plist-get info :email) info))) (date (plist-get info :date))) ;; There are two types of title blocks depending on the presence ;; of a title to display. @@ -968,13 +959,13 @@ holding export options." ;; take it into consideration. (let ((first (car (org-element-contents def)))) (if (not (eq (org-element-type first) 'paragraph)) - (concat id "\n" (org-export-data def 'e-ascii info)) + (concat id "\n" (org-export-data def info)) (push id (nthcdr 2 first)) - (org-export-data def 'e-ascii info))) + (org-export-data def info))) ;; Fill paragraph once footnote ID is inserted in ;; order to have a correct length for first line. (org-e-ascii--fill-string - (concat id (org-export-secondary-string def 'e-ascii info)) + (concat id (org-export-secondary-string def info)) text-width info)))))) definitions "\n\n")))) ;; 5. Creator. Ignore `comment' value as there are no comments in @@ -1049,8 +1040,7 @@ holding contextual information." (defun org-e-ascii-dynamic-block (dynamic-block contents info) "Transcode a DYNAMIC-BLOCK element from Org to ASCII. CONTENTS holds the contents of the block. INFO is a plist -holding contextual information. See -`org-export-data'." +holding contextual information. See `org-export-data'." contents) @@ -1218,12 +1208,12 @@ CONTENTS holds the contents of the block. INFO is a plist holding contextual information." (let ((width (org-e-ascii--current-text-width inlinetask info)) (title (org-export-secondary-string - (org-element-property :title inlinetask) 'e-ascii info)) + (org-element-property :title inlinetask) info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword inlinetask))) (and todo - (org-export-secondary-string todo 'e-ascii info))))) + (org-export-secondary-string todo info))))) (todo-type (org-element-property :todo-type inlinetask)) (tags (and (plist-get info :with-tags) (org-element-property :tags inlinetask))) @@ -1244,7 +1234,7 @@ holding contextual information." ;; Add title. Fill it if wider than inlinetask. (let ((title (org-e-ascii--build-title inlinetask info width))) (if (<= (length title) width) title - (org-e-ascii--fill-string title width info))) + (org-e-ascii--fill-string title width info))) "\n" ;; If CONTENTS is not empty, insert it along with ;; a separator. @@ -1273,7 +1263,8 @@ contextual information." (descriptive (concat (org-export-secondary-string - (org-element-property :tag item) 'e-ascii info) ": ")) + (org-element-property :tag item) info) + ": ")) (ordered ;; Return correct number for ITEM, paying attention to ;; counters. @@ -1378,7 +1369,7 @@ INFO is a plist holding contextual information." (org-element-parse-secondary-string (org-element-property :path link) (cdr (assq 'radio-target org-element-object-restrictions))) - 'e-ascii info)) + info)) ;; Do not apply a special syntax on fuzzy links pointing to ;; targets. ((string= type "fuzzy") @@ -1488,7 +1479,8 @@ CONTENTS is nil. INFO is a plist holding contextual information." (value (org-export-secondary-string (org-remove-indentation - (org-element-property :value quote-section)) 'e-ascii info))) + (org-element-property :value quote-section)) + info))) (org-e-ascii--indent-string value (+ org-e-ascii-quote-margin @@ -1624,7 +1616,7 @@ are ignored. " (elt (if specialp (car (org-element-contents row)) (org-element-contents row)) col) - (plist-get info :back-end) info)) + info)) max-width)))) max-width))) diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index d9350ff1a..426ae03d3 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -49,8 +49,7 @@ (defvar org-element-string-restrictions) (defvar org-element-object-restrictions) -(declare-function org-export-clean-table "org-export" (table specialp)) -(declare-function org-export-data "org-export" (data backend info)) +(declare-function org-export-data "org-export" (data info)) (declare-function org-export-directory "org-export" (type plist)) (declare-function org-export-expand-macro "org-export" (macro info)) (declare-function org-export-first-sibling-p "org-export" (headline info)) @@ -64,7 +63,6 @@ (declare-function org-export-get-relative-level "org-export" (headline info)) (declare-function org-export-handle-code "org-export" (element info &optional num-fmt ref-fmt delayed)) -(declare-function org-export-included-file "org-export" (keyword backend info)) (declare-function org-export-inline-image-p "org-export" (link &optional extensions)) (declare-function org-export-last-sibling-p "org-export" (headline info)) @@ -73,10 +71,8 @@ "org-export" (extension &optional subtreep pub-dir)) (declare-function org-export-resolve-coderef "org-export" (ref info)) (declare-function org-export-resolve-fuzzy-link "org-export" (link info)) -(declare-function org-export-secondary-string "org-export" - (secondary backend info)) +(declare-function org-export-secondary-string "org-export" (secondary info)) (declare-function org-export-solidify-link-text "org-export" (s)) -(declare-function org-export-table-format-info "org-export" (table)) (declare-function org-export-to-buffer "org-export" (backend buffer &optional subtreep visible-only body-only ext-plist)) @@ -1365,10 +1361,10 @@ Replaces invalid characters with \"_\"." (fn-alist (loop for (n type raw) in fn-alist collect (cons n (if (equal (org-element-type raw) 'org-data) - (org-trim (org-export-data raw 'e-html info)) + (org-trim (org-export-data raw info)) (format "

%s

" - (org-trim (org-export-secondary-string - raw 'e-html info)))))))) + (org-trim + (org-export-secondary-string raw info)))))))) (when fn-alist (org-e-html-format-footnotes-section (nth 4 (or (assoc (plist-get info :language) @@ -1410,15 +1406,15 @@ For non-floats, see `org-e-html--wrap-label'." ;; Option caption format with short name. ((cdr caption) (format "\\caption[%s]{%s%s}\n" - (org-export-secondary-string (cdr caption) 'e-html info) + (org-export-secondary-string (cdr caption) info) label-str - (org-export-secondary-string (car caption) 'e-html info))) + (org-export-secondary-string (car caption) info))) ;; Standard caption format. ;; (t (format "\\caption{%s%s}\n" ;; label-str - ;; (org-export-secondary-string (car caption) 'e-html info))) + ;; (org-export-secondary-string (car caption) info))) - (t (org-export-secondary-string (car caption) 'e-html info))))) + (t (org-export-secondary-string (car caption) info))))) (defun org-e-html--find-verb-separator (s) "Return a character not used in string S. @@ -1457,12 +1453,10 @@ This function shouldn't be used for floats. See ;;; Template (defun org-e-html-meta-info (info) - (let* ((title (org-export-secondary-string - (plist-get info :title) 'e-html info)) + (let* ((title (org-export-secondary-string (plist-get info :title) info)) (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) - (and auth (org-export-secondary-string - auth 'e-html info))))) + (and auth (org-export-secondary-string auth info))))) (description (plist-get info :description)) (keywords (plist-get info :keywords))) (concat @@ -1524,11 +1518,9 @@ This function shouldn't be used for floats. See (defun org-e-html-preamble (info) (when (plist-get info :html-preamble) - (let* ((title (org-export-secondary-string - (plist-get info :title) 'e-html info)) + (let* ((title (org-export-secondary-string (plist-get info :title) info)) (date (org-e-html-format-date info)) - (author (org-export-secondary-string - (plist-get info :author) 'e-html info)) + (author (org-export-secondary-string (plist-get info :author) info)) (lang-words (or (assoc (plist-get info :language) org-export-language-setup) (assoc "en" org-export-language-setup))) @@ -1678,7 +1670,7 @@ original parsed data. INFO is a plist holding export options." ;; document title (format "

%s

\n" (org-export-secondary-string - (plist-get info :title) 'e-html info)) + (plist-get info :title) info)) ;; table of contents (let ((depth (plist-get info :with-toc))) (when (wholenump depth) (org-e-html-toc depth info))) @@ -1880,8 +1872,7 @@ holding contextual information." (defun org-e-html-dynamic-block (dynamic-block contents info) "Transcode a DYNAMIC-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist -holding contextual information. See -`org-export-data'." +holding contextual information. See `org-export-data'." (org-e-html--wrap-label dynamic-block contents)) @@ -2015,12 +2006,12 @@ holding contextual information." (let ((todo (org-element-property :todo-keyword headline))) (and todo - (org-export-secondary-string todo 'e-html info))))) + (org-export-secondary-string todo info))))) (todo-type (and todo (org-element-property :todo-type headline))) (priority (and (plist-get info :with-priority) (org-element-property :priority headline))) (text (org-export-secondary-string - (org-element-property :title headline) 'e-html info)) + (org-element-property :title headline) info)) (tags (and (plist-get info :with-tags) (org-element-property :tags headline))) (headline-label (concat "sec-" (mapconcat 'number-to-string @@ -2046,12 +2037,11 @@ holding contextual information." (let* ((numberedp (org-export-numbered-headline-p headline info)) (level (org-export-get-relative-level headline info)) (text (org-export-secondary-string - (org-element-property :title headline) 'e-html info)) + (org-element-property :title headline) info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword headline))) - (and todo - (org-export-secondary-string todo 'e-html info))))) + (and todo (org-export-secondary-string todo info))))) (todo-type (and todo (org-element-property :todo-type headline))) (tags (and (plist-get info :with-tags) (org-element-property :tags headline))) @@ -2210,7 +2200,7 @@ contextual information." (counter (org-element-property :counter item)) (checkbox (org-element-property :checkbox item)) (tag (let ((tag (org-element-property :tag item))) - (and tag (org-export-secondary-string tag 'e-html info))))) + (and tag (org-export-secondary-string tag info))))) (org-e-html-format-list-item contents type checkbox (or tag counter)))) @@ -2429,7 +2419,7 @@ INFO is a plist holding contextual information. See (org-export-secondary-string (org-element-parse-secondary-string path (org-element-restriction 'radio-target)) - 'e-html info))) + info))) ;; Links pointing to an headline: Find destination and build ;; appropriate referencing command. ((member type '("custom-id" "fuzzy" "id")) @@ -2440,9 +2430,9 @@ INFO is a plist holding contextual information. See ;; Fuzzy link points nowhere. ('nil (format "%s" - (or desc (org-export-secondary-string - (org-element-property :raw-link link) - 'e-html info)))) + (or desc + (org-export-secondary-string + (org-element-property :raw-link link) info)))) ;; Fuzzy link points to an invisible target. (keyword nil) ;; LINK points to an headline. If headlines are numbered @@ -2459,8 +2449,7 @@ INFO is a plist holding contextual information. See (desc desc) ((plist-get info :section-numbers) section-no) (t (org-export-secondary-string - (org-element-property :title destination) - 'e-html info)))) + (org-element-property :title destination) info)))) (format "%s" label desc))) ;; Fuzzy link points to a target. Do as above. (otherwise @@ -2923,8 +2912,7 @@ information." (let ((value (org-element-property :value time-stamp)) (type (org-element-property :type time-stamp)) (appt-type (org-element-property :appt-type time-stamp))) - (setq value (org-translate-time - (org-export-secondary-string value 'e-html info))) + (setq value (org-translate-time (org-export-secondary-string value info))) (setq appt-type (case appt-type (scheduled org-scheduled-string) (deadline org-deadline-string) diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el index 3c78b6453..4c94b140b 100644 --- a/contrib/lisp/org-e-latex.el +++ b/contrib/lisp/org-e-latex.el @@ -47,8 +47,7 @@ (defvar org-element-string-restrictions) (defvar org-element-object-restrictions) -(declare-function org-export-clean-table "org-export" (table specialp)) -(declare-function org-export-data "org-export" (data backend info)) +(declare-function org-export-data "org-export" (data info)) (declare-function org-export-directory "org-export" (type plist)) (declare-function org-export-expand-macro "org-export" (macro info)) (declare-function org-export-first-sibling-p "org-export" (headline info)) @@ -64,7 +63,6 @@ (declare-function org-export-get-previous-element "org-export" (blob info)) (declare-function org-export-get-relative-level "org-export" (headline info)) (declare-function org-export-unravel-code "org-export" (element)) -(declare-function org-export-included-file "org-export" (keyword backend info)) (declare-function org-export-inline-image-p "org-export" (link &optional extensions)) (declare-function org-export-last-sibling-p "org-export" (headline info)) @@ -73,10 +71,8 @@ "org-export" (extension &optional subtreep pub-dir)) (declare-function org-export-resolve-coderef "org-export" (ref info)) (declare-function org-export-resolve-fuzzy-link "org-export" (link info)) -(declare-function org-export-secondary-string "org-export" - (secondary backend info)) +(declare-function org-export-secondary-string "org-export" (secondary info)) (declare-function org-export-solidify-link-text "org-export" (s)) -(declare-function org-export-table-format-info "org-export" (table)) (declare-function org-export-to-buffer "org-export" (backend buffer &optional subtreep visible-only body-only ext-plist)) @@ -746,13 +742,13 @@ For non-floats, see `org-e-latex--wrap-label'." ;; Option caption format with short name. ((cdr caption) (format "\\caption[%s]{%s%s}\n" - (org-export-secondary-string (cdr caption) 'e-latex info) + (org-export-secondary-string (cdr caption) info) label-str - (org-export-secondary-string (car caption) 'e-latex info))) + (org-export-secondary-string (car caption) info))) ;; Standard caption format. (t (format "\\caption{%s%s}\n" label-str - (org-export-secondary-string (car caption) 'e-latex info)))))) + (org-export-secondary-string (car caption) info)))))) (defun org-e-latex--guess-inputenc (header) "Set the coding system in inputenc to what the buffer is. @@ -822,8 +818,7 @@ This function shouldn't be used for floats. See "Return complete document string after LaTeX conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - (let ((title (org-export-secondary-string - (plist-get info :title) 'e-latex info))) + (let ((title (org-export-secondary-string (plist-get info :title) info))) (concat ;; 1. Time-stamp. (and (plist-get info :time-stamp-file) @@ -855,11 +850,10 @@ holding export options." ;; 5. Author. (let ((author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) - (and auth (org-export-secondary-string - auth 'e-latex info))))) + (and auth (org-export-secondary-string auth info))))) (email (and (plist-get info :with-email) (org-export-secondary-string - (plist-get info :email) 'e-latex info)))) + (plist-get info :email) info)))) (cond ((and author email (not (string= "" email))) (format "\\author{%s\\thanks{%s}}\n" author email)) (author (format "\\author{%s}\n" author)) @@ -949,8 +943,7 @@ holding contextual information." (defun org-e-latex-dynamic-block (dynamic-block contents info) "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'." +holding contextual information. See `org-export-data'." (org-e-latex--wrap-label dynamic-block contents)) @@ -1051,7 +1044,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (unless (eq (org-element-type def) 'org-data) (setq def (cons 'org-data (cons nil def)))) (concat - (format "\\footnote{%s}" (org-trim (org-export-data def 'e-latex info))) + (format "\\footnote{%s}" (org-trim (org-export-data def info))) ;; Retrieve all footnote references within the footnote and ;; add their definition after it, since LaTeX doesn't support ;; them inside. @@ -1081,7 +1074,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (if (eq (org-element-property :type ref) 'inline) 'org-export-secondary-string 'org-export-data) - (org-export-get-footnote-definition ref info) 'e-latex info)))) + (org-export-get-footnote-definition ref info) info)))) (funcall search-refs def) "")))))))) @@ -1118,11 +1111,11 @@ holding contextual information." (if numberedp (concat (car sec) "\n%s" (nth 1 sec)) (concat (nth 2 sec) "\n%s" (nth 3 sec))))))) (text (org-export-secondary-string - (org-element-property :title headline) 'e-latex info)) + (org-element-property :title headline) info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword headline))) - (and todo (org-export-secondary-string todo 'e-latex info))))) + (and todo (org-export-secondary-string todo info))))) (todo-type (and todo (org-element-property :todo-type headline))) (tags (and (plist-get info :with-tags) (org-element-property :tags headline))) @@ -1237,12 +1230,12 @@ contextual information." CONTENTS holds the contents of the block. INFO is a plist holding contextual information." (let ((title (org-export-secondary-string - (org-element-property :title inlinetask) 'e-latex info)) + (org-element-property :title inlinetask) info)) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword inlinetask))) (and todo - (org-export-secondary-string todo 'e-latex info))))) + (org-export-secondary-string todo info))))) (todo-type (org-element-property :todo-type inlinetask)) (tags (and (plist-get info :with-tags) (org-element-property :tags inlinetask))) @@ -1295,8 +1288,7 @@ contextual information." ((eq checkbox 'trans) "$\\boxminus$ ")))) (tag (let ((tag (org-element-property :tag item))) (and tag - (format "[%s]" (org-export-secondary-string - tag 'e-latex info)))))) + (format "[%s]" (org-export-secondary-string tag info)))))) (concat counter "\\item" tag " " checkbox contents))) @@ -1469,7 +1461,7 @@ INFO is a plist holding contextual information. See (org-export-secondary-string (org-element-parse-secondary-string path (cdr (assq 'radio-target org-element-object-restrictions))) - 'e-latex info))) + info))) ;; Links pointing to an headline: Find destination and build ;; appropriate referencing command. ((member type '("custom-id" "fuzzy" "id")) @@ -1482,8 +1474,7 @@ INFO is a plist holding contextual information. See (format "\\texttt{%s}" (or desc (org-export-secondary-string - (org-element-property :raw-link link) - 'e-latex info)))) + (org-element-property :raw-link link) info)))) ;; Fuzzy link points to an invisible target. (keyword nil) ;; LINK points to an headline. If headlines are numbered @@ -1502,8 +1493,7 @@ INFO is a plist holding contextual information. See (format "\\hyperref[%s]{%s}" label (or desc (org-export-secondary-string - (org-element-property :title destination) - 'e-latex info)))))) + (org-element-property :title destination) info)))))) ;; Fuzzy link points to a target. Do as above. (otherwise (let ((path (org-export-solidify-link-text path))) @@ -1762,12 +1752,11 @@ contextual information." (or (cadr (assq (intern lang) org-e-latex-listings-langs)) lang)) (caption-str (when caption - (let ((main (org-export-secondary-string - (car caption) 'e-latex info))) + (let ((main (org-export-secondary-string (car caption) info))) (if (not (cdr caption)) (format "{%s}" main) (format "{[%s]%s}" - (org-export-secondary-string (cdr caption) 'e-latex info) + (org-export-secondary-string (cdr caption) info) main)))))) (concat ;; Options. diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index 263c4eb90..a490f1af5 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -47,12 +47,10 @@ ;; progress. See org-html.el. (defun org-e-odt-format-preamble (info) - (let* ((title (org-export-secondary-string - (plist-get info :title) 'e-odt info)) + (let* ((title (org-export-secondary-string (plist-get info :title) info)) (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) - (and auth (org-export-secondary-string - auth 'e-odt info))))) + (and auth (org-export-secondary-string auth info))))) (date (plist-get info :date)) (iso-date (org-e-odt-format-date date)) (date (org-e-odt-format-date date "%d %b %Y")) @@ -861,10 +859,10 @@ ATTR is a string of other attributes of the a element." (caption (org-element-property :caption caption-from)) (short-caption (cdr caption)) ;; transcode captions. - (caption (and (car caption) (org-export-secondary-string - (car caption) 'e-odt info))) - (short-caption (and short-caption (org-export-secondary-string - short-caption 'e-odt info)))) + (caption (and (car caption) + (org-export-secondary-string (car caption) info))) + (short-caption (and short-caption + (org-export-secondary-string short-caption info)))) (when (or label caption) (let* ((default-category (cond @@ -1081,11 +1079,9 @@ ATTR is a string of other attributes of the a element." (insert "\n")))) (defun org-e-odt-update-meta-file (info) ; FIXME opt-plist - (let ((title (org-export-secondary-string - (plist-get info :title) 'e-odt info)) + (let ((title (org-export-secondary-string (plist-get info :title) info)) (author (or (let ((auth (plist-get info :author))) - (and auth (org-export-secondary-string - auth 'e-odt info))) "")) + (and auth (org-export-secondary-string auth info))) "")) (date (org-e-odt-format-date (plist-get info :date))) (email (plist-get info :email)) (keywords (plist-get info :keywords)) @@ -1352,8 +1348,7 @@ formula file." (defvar org-element-string-restrictions) (defvar org-element-object-restrictions) -(declare-function org-export-clean-table "org-export" (table specialp)) -(declare-function org-export-data "org-export" (data backend info)) +(declare-function org-export-data "org-export" (data info)) (declare-function org-export-directory "org-export" (type plist)) (declare-function org-export-expand-macro "org-export" (macro info)) (declare-function org-export-first-sibling-p "org-export" (headline info)) @@ -1376,10 +1371,8 @@ formula file." "org-export" (extension &optional subtreep pub-dir)) (declare-function org-export-resolve-coderef "org-export" (ref info)) (declare-function org-export-resolve-fuzzy-link "org-export" (link info)) -(declare-function org-export-secondary-string "org-export" - (secondary backend info)) +(declare-function org-export-secondary-string "org-export" (secondary info)) (declare-function org-export-solidify-link-text "org-export" (s)) -(declare-function org-export-table-format-info "org-export" (table)) (declare-function org-export-to-buffer "org-export" (backend buffer &optional subtreep visible-only body-only ext-plist)) @@ -2750,15 +2743,15 @@ For non-floats, see `org-e-odt--wrap-label'." ;; Option caption format with short name. ((cdr caption) (format "\\caption[%s]{%s%s}\n" - (org-export-secondary-string (cdr caption) 'e-odt info) + (org-export-secondary-string (cdr caption) info) label-str - (org-export-secondary-string (car caption) 'e-odt info))) + (org-export-secondary-string (car caption) info))) ;; Standard caption format. ;; (t (format "\\caption{%s%s}\n" ;; label-str - ;; (org-export-secondary-string (car caption) 'e-odt info))) + ;; (org-export-secondary-string (car caption) info))) - (t (org-export-secondary-string (car caption) 'e-odt info))))) + (t (org-export-secondary-string (car caption) info))))) (defun org-e-odt--find-verb-separator (s) "Return a character not used in string S. @@ -2976,8 +2969,7 @@ holding contextual information." (defun org-e-odt-dynamic-block (dynamic-block contents info) "Transcode a DYNAMIC-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist -holding contextual information. See -`org-export-data'." +holding contextual information. See `org-export-data'." (org-e-odt--wrap-label dynamic-block contents)) @@ -3065,10 +3057,9 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-e-odt-footnote-def (raw info) ; FIXME (if (equal (org-element-type raw) 'org-data) - (org-trim (org-export-data raw 'e-odt info)) ; fix paragraph - ; style + (org-trim (org-export-data raw info)) ; fix paragraph style (org-e-odt-format-stylized-paragraph - 'footnote (org-trim (org-export-secondary-string raw 'e-odt info))))) + 'footnote (org-trim (org-export-secondary-string raw info))))) (defvar org-e-odt-footnote-separator (org-e-odt-format-fontify "," 'superscript)) @@ -3125,12 +3116,12 @@ holding contextual information." (let ((todo (org-element-property :todo-keyword headline))) (and todo - (org-export-secondary-string todo 'e-odt info))))) + (org-export-secondary-string todo info))))) (todo-type (and todo (org-element-property :todo-type headline))) (priority (and (plist-get info :with-priority) (org-element-property :priority headline))) (text (org-export-secondary-string - (org-element-property :title headline) 'e-odt info)) + (org-element-property :title headline) info)) (tags (and (plist-get info :with-tags) (org-element-property :tags headline))) (headline-label (concat "sec-" (mapconcat 'number-to-string @@ -3157,7 +3148,7 @@ holding contextual information." ;; Get level relative to current parsed data. (level (org-export-get-relative-level headline info)) (text (org-export-secondary-string - (org-element-property :title headline) 'e-odt info)) + (org-element-property :title headline) info)) ;; Create the headline text. (full-text (org-e-odt-format-headline--wrap headline info))) (cond @@ -3286,7 +3277,7 @@ contextual information." (counter (org-element-property :counter item)) (checkbox (org-element-property :checkbox item)) (tag (let ((tag (org-element-property :tag item))) - (and tag (org-export-secondary-string tag 'e-odt info))))) + (and tag (org-export-secondary-string tag info))))) (org-e-odt-format-list-item contents type checkbox (or tag counter)))) @@ -3350,10 +3341,10 @@ CONTENTS is nil. INFO is a plist holding contextual information." (org-element-property :value latex-environment))) (processing-type (plist-get info :LaTeX-fragments)) (caption (org-element-property :caption latex-environment)) - (short-caption (and (cdr caption) (org-export-secondary-string - (cdr caption) 'e-odt info))) - (caption (and (car caption) (org-export-secondary-string - (car caption) 'e-odt info))) + (short-caption (and (cdr caption) + (org-export-secondary-string (cdr caption) info))) + (caption (and (car caption) + (org-export-secondary-string (car caption) info))) (label (org-element-property :name latex-environment)) (attr nil) ; FIXME (label (org-element-property :name latex-environment))) @@ -3583,7 +3574,7 @@ INFO is a plist holding contextual information. See (org-export-secondary-string (org-element-parse-secondary-string path (org-element-restriction 'radio-target)) - 'e-odt info) + info) (org-export-solidify-link-text path))) ;; Links pointing to an headline: Find destination and build ;; appropriate referencing command. @@ -3596,8 +3587,8 @@ INFO is a plist holding contextual information. See ('nil (org-e-odt-format-fontify (or desc (org-export-secondary-string - (org-element-property :raw-link link) - 'e-odt info)) 'emphasis)) + (org-element-property :raw-link link) info)) + 'emphasis)) ;; Fuzzy link points to an invisible target. (keyword nil) ;; LINK points to an headline. If headlines are numbered @@ -3614,8 +3605,7 @@ INFO is a plist holding contextual information. See (desc desc) ((plist-get info :section-numbers) section-no) (t (org-export-secondary-string - (org-element-property :title destination) - 'e-odt info)))) + (org-element-property :title destination) info)))) (org-e-odt-format-internal-link desc label))) ;; Fuzzy link points to a target. Do as above. (otherwise @@ -3831,15 +3821,15 @@ CONTENTS holds the contents of the item. INFO is a plist holding contextual information." (let* ((lang (org-element-property :language src-block)) (caption (org-element-property :caption src-block)) - (short-caption (and (cdr caption) (org-export-secondary-string - (cdr caption) 'e-odt info))) - (caption (and (car caption) (org-export-secondary-string - (car caption) 'e-odt info))) + (short-caption (and (cdr caption) + (org-export-secondary-string (cdr caption) info))) + (caption (and (car caption) + (org-export-secondary-string (car caption) info))) (label (org-element-property :name src-block))) ;; FIXME: Handle caption ;; caption-str (when caption) - ;; (main (org-export-secondary-string (car caption) 'e-odt info)) - ;; (secondary (org-export-secondary-string (cdr caption) 'e-odt info)) + ;; (main (org-export-secondary-string (car caption) info)) + ;; (secondary (org-export-secondary-string (cdr caption) info)) ;; (caption-str (org-e-odt--caption/label-string caption label info)) (let* ((captions (org-e-odt-format-label src-block info 'definition)) (caption (car captions)) (short-caption (cdr captions))) @@ -4122,7 +4112,7 @@ information." (let ((value (org-element-property :value time-stamp)) (type (org-element-property :type time-stamp)) (appt-type (org-element-property :appt-type time-stamp))) - (setq value (org-export-secondary-string value 'e-odt info)) + (setq value (org-export-secondary-string value info)) (org-e-odt-format-fontify (concat (org-e-odt-format-fontify diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index b5b1e3f0a..4f607b90b 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -943,7 +943,9 @@ inferior to file-local settings." (and buffer-file-name (org-remove-double-quotes buffer-file-name))) ;; ... and from subtree, when appropriate. - (and subtreep (org-export-get-subtree-options))))) + (and subtreep (org-export-get-subtree-options)) + ;; Also install back-end symbol. + `(:back-end ,backend)))) ;; Return plist. options)) @@ -1259,16 +1261,13 @@ retrieved." ;; `org-export-collect-headline-numbering' builds an alist between ;; headlines and their numbering. -(defun org-export-collect-tree-properties (data info backend) +(defun org-export-collect-tree-properties (data info) "Extract tree properties from parse tree. DATA is the parse tree from which information is retrieved. INFO -is a list holding export options. BACKEND is the back-end called -for transcoding, as a symbol. +is a list holding export options. Following tree properties are set or updated: -`:back-end' Back-end used for transcoding. - `:footnote-definition-alist' List of footnotes definitions in original buffer and current parse tree. @@ -1283,8 +1282,6 @@ Following tree properties are set or updated: `:ignore-list' List of elements that should be ignored during export. -`:parse-tree' Whole parse tree. - `:target-list' List of all targets in the parse tree." ;; Install the parse tree in the communication channel, in order to ;; use `org-export-get-genealogy' and al. @@ -1325,8 +1322,7 @@ Following tree properties are set or updated: (when (or (eq (org-element-type blob) 'target) (string= (org-element-property :key blob) "TARGET")) blob)) info) - :headline-numbering ,(org-export-collect-headline-numbering data info) - :back-end ,backend) + :headline-numbering ,(org-export-collect-headline-numbering data info)) info)) (defun org-export-get-min-level (data options) @@ -1499,17 +1495,14 @@ OPTIONS is the plist holding export options." ;; `org-export-expand' transforms the others back into their original ;; shape. -(defun org-export-data (data backend info) - "Convert DATA to a string into BACKEND format. +(defun org-export-data (data info) + "Convert DATA into current back-end format. DATA is a nested list as returned by `org-element-parse-buffer'. -BACKEND is a symbol among supported exporters. - INFO is a plist holding export options and also used as a communication channel between elements when walking the nested -list. See `org-export-update-info' function for more -details. +list. Return transcoded string." (mapconcat @@ -1522,11 +1515,12 @@ Return transcoded string." ;; return string. Also update INFO and call ;; `org-export-filter-plain-text-functions'. ((stringp blob) - (let ((transcoder (intern (format "org-%s-plain-text" backend)))) + (let ((transcoder (intern (format "org-%s-plain-text" + (plist-get info :back-end))))) (org-export-filter-apply-functions (plist-get info :filter-plain-text) (if (fboundp transcoder) (funcall transcoder blob info) blob) - backend info))) + info))) ;; BLOB is an element or an object. (t (let* ((type (org-element-type blob)) @@ -1541,7 +1535,9 @@ Return transcoded string." ;; back into Org syntax. ((not (org-export-interpret-p blob info)) 'org-export-expand) ;; 1.3. Else apply naming convention. - (t (let ((trans (intern (format "org-%s-%s" backend type)))) + (t (let ((trans (intern (format "org-%s-%s" + (plist-get info :back-end) + type)))) (and (fboundp trans) trans))))) ;; 2. Compute CONTENTS of BLOB. (contents @@ -1549,7 +1545,7 @@ Return transcoded string." ;; Case 0. No transcoder or no contents: ignore BLOB. ((or (not transcoder) (not (org-element-contents blob))) nil) ;; Case 1. Transparently export an Org document. - ((eq type 'org-data) (org-export-data blob backend info)) + ((eq type 'org-data) (org-export-data blob info)) ;; Case 2. For a greater element. ((memq type org-element-greater-elements) ;; Ignore contents of an archived tree @@ -1558,8 +1554,7 @@ Return transcoded string." (eq type 'headline) (eq (plist-get info :with-archived-trees) 'headline) (org-element-property :archivedp blob)) - (org-element-normalize-string - (org-export-data blob backend info)))) + (org-element-normalize-string (org-export-data blob info)))) ;; Case 3. For an element containing objects. (t (org-export-data @@ -1574,14 +1569,14 @@ Return transcoded string." (let ((parent (org-export-get-parent blob info))) (memq (org-element-type parent) '(footnote-definition item))))) - backend info)))) + info)))) ;; 3. Transcode BLOB into RESULTS string. (results (cond ((not transcoder) nil) ((eq transcoder 'org-export-expand) (org-export-data `(org-data nil ,(funcall transcoder blob contents)) - backend info)) + info)) (t (funcall transcoder blob contents info))))) ;; 4. Return results. (cond @@ -1600,24 +1595,22 @@ Return transcoded string." (concat (org-element-normalize-string results) (make-string post-blank ?\n)) (concat results (make-string post-blank ? )))) - backend info))) + info))) ;; Eventually return string. results))))))) (org-element-contents data) "")) -(defun org-export-secondary-string (secondary backend info) - "Convert SECONDARY string into BACKEND format. +(defun org-export-secondary-string (secondary info) + "Convert SECONDARY string into current back-end target format. SECONDARY is a nested list as returned by -`org-element-parse-secondary-string'. - -BACKEND is a symbol among supported exporters. INFO is a plist -used as a communication channel. +`org-element-parse-secondary-string'. INFO is a plist used as +a communication channel. Return transcoded string." ;; Make SECONDARY acceptable for `org-export-data'. (let ((s (if (listp secondary) secondary (list secondary)))) - (org-export-data `(org-data nil ,@s) backend (copy-sequence info)))) + (org-export-data `(org-data nil ,@s) (copy-sequence info)))) (defun org-export-interpret-p (blob info) "Non-nil if element or object BLOB should be interpreted as Org syntax. @@ -2044,21 +2037,20 @@ verbatim, as a string, the back-end, as a symbol, and the communication channel, as a plist. It must return a string or nil.") -(defun org-export-filter-apply-functions (filters value backend info) - "Call every function in FILTERS with arguments VALUE, BACKEND and INFO. -Functions are called in a LIFO fashion, to be sure that developer -specified filters, if any, are called first." +(defun org-export-filter-apply-functions (filters value info) + "Call every function in FILTERS. +Functions are called with arguments VALUE, current export +back-end and INFO. Call is done in a LIFO fashion, to be sure +that developer specified filters, if any, are called first." (loop for filter in filters if (not value) return nil else - do (setq value (funcall filter value backend info))) + do (setq value (funcall filter value (plist-get info :back-end) info))) value) -(defun org-export-install-filters (backend info) +(defun org-export-install-filters (info) "Install filters properties in communication channel. -BACKEND is a symbol specifying which back-end specific filters to -install, if any. INFO is a plist containing the current -communication channel. +INFO is a plist containing the current communication channel. Return the updated communication channel." (let (plist) @@ -2067,7 +2059,8 @@ Return the updated communication channel." (setq plist (plist-put plist (car p) (eval (cdr p))))) org-export-filters-alist) ;; Prepend back-end specific filters to that list. - (let ((back-end-filters (intern (format "org-%s-filters-alist" backend)))) + (let ((back-end-filters (intern (format "org-%s-filters-alist" + (plist-get info :back-end))))) (when (boundp back-end-filters) (mapc (lambda (p) ;; Single values get consed, lists are prepended. @@ -2153,7 +2146,6 @@ Return code as a string." ;; they might not be accessible anymore in a narrowed parse ;; tree. Also install user's and developer's filters. (let ((info (org-export-install-filters - backend (org-export-store-footnote-definitions (org-export-get-environment backend subtreep ext-plist)))) ;; 2. Get parse tree. Buffer isn't parsed directly. @@ -2175,24 +2167,22 @@ Return code as a string." ;; 3. Call parse-tree filters to get the final tree. (setq tree (org-export-filter-apply-functions - (plist-get info :filter-parse-tree) tree backend info)) + (plist-get info :filter-parse-tree) tree info)) ;; 4. Now tree is complete, compute its properties and add ;; them to communication channel. (setq info (org-combine-plists - info - (org-export-collect-tree-properties tree info backend))) + info (org-export-collect-tree-properties tree info))) ;; 5. Eventually transcode TREE. Wrap the resulting string ;; into a template, if required. Eventually call ;; final-output filter. - (let* ((body (org-element-normalize-string - (org-export-data tree backend info))) + (let* ((body (org-element-normalize-string (org-export-data tree info))) (template (intern (format "org-%s-template" backend))) (output (org-export-filter-apply-functions (plist-get info :filter-final-output) (if (or (not (fboundp template)) body-only) body (funcall template body info)) - backend info))) + info))) ;; Maybe add final OUTPUT to kill ring, then return it. (when org-export-copy-to-kill-ring (org-kill-new output)) output))))) @@ -2906,9 +2896,7 @@ INFO is a plist holding export options." ;; expanded recursively. (value (let ((val (plist-get info (intern (format ":macro-%s" key))))) - (if (stringp val) val - (org-export-secondary-string - val (plist-get info :back-end) info))))) + (if (stringp val) val (org-export-secondary-string val info))))) ;; Replace arguments in VALUE. (let ((s 0) n) (while (string-match "\\$\\([0-9]+\\)" value s) diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el index 90a257cda..d21da395c 100644 --- a/testing/lisp/test-org-export.el +++ b/testing/lisp/test-org-export.el @@ -52,7 +52,7 @@ already filled in `info'." (declare (debug (form body)) (indent 1)) `(org-test-with-temp-text ,data (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil nil))) + (info (org-export-collect-tree-properties tree nil))) ,@body))) (ert-deftest test-org-export/parse-option-keyword () @@ -349,10 +349,10 @@ body\n"))) (org-test-with-backend "test" (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2" (let ((org-export-before-parsing-hook - ((lambda () - (org-map-entries - (lambda () - (delete-region (point) (progn (forward-line) (point))))))))) + '((lambda () + (org-map-entries + (lambda () + (delete-region (point) (progn (forward-line) (point))))))))) (should (equal (org-export-as 'test) "Body 1\nBody 2\n")))))) @@ -437,81 +437,69 @@ Paragraph[fn:1]" (ert-deftest test-org-export/fuzzy-links () "Test fuzzy link export specifications." ;; 1. Links to invisible (keyword) targets should be ignored. - (org-test-with-temp-text + (org-test-with-parsed-data "Paragraph.\n#+TARGET: Test\n[[Test]]" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should-not - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info)))) + (should-not + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info))) ;; 2. Link to an headline should return headline's number. - (org-test-with-temp-text + (org-test-with-parsed-data "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should - ;; Note: Headline's number is in fact a list of numbers. - (equal '(2) - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info t))))) + (should + ;; Note: Headline's number is in fact a list of numbers. + (equal '(2) + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info t)))) ;; 3. Link to a target in an item should return item's number. - (org-test-with-temp-text + (org-test-with-parsed-data "- Item1\n - Item11\n - <>Item12\n- Item2\n\n\n[[test]]" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should - ;; Note: Item's number is in fact a list of numbers. - (equal '(1 2) - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info t))))) + (should + ;; Note: Item's number is in fact a list of numbers. + (equal '(1 2) + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info t)))) ;; 4. Link to a target in a footnote should return footnote's ;; number. - (org-test-with-temp-text - "Paragraph[1][2][fn:lbl3:C<>][[test]][[target]]\n[1] A\n\n[2] <>B" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should - (equal '(2 3) - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info))))) + (org-test-with-parsed-data " +Paragraph[1][2][fn:lbl3:C<>][[test]][[target]]\n[1] A\n\n[2] <>B" + (should + (equal '(2 3) + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info)))) ;; 5. Link to a named element should return sequence number of that ;; element. - (org-test-with-temp-text + (org-test-with-parsed-data "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should - (= 2 - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info t))))) + (should + (= 2 + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info t)))) ;; 6. Link to a target not within an item, a table, a footnote ;; reference or definition should return section number. - (org-test-with-temp-text + (org-test-with-parsed-data "* Head1\n* Head2\nParagraph<>\n* Head3\n[[target]]" - (let* ((tree (org-element-parse-buffer)) - (info (org-export-collect-tree-properties tree nil 'test))) - (should - (equal '(2) - (org-element-map - tree 'link - (lambda (link) - (org-export-get-ordinal - (org-export-resolve-fuzzy-link link info) info)) info t)))))) + (should + (equal '(2) + (org-element-map + tree 'link + (lambda (link) + (org-export-get-ordinal + (org-export-resolve-fuzzy-link link info) info)) info t))))) (defun test-org-export/resolve-coderef () "Test `org-export-resolve-coderef' specifications."