Pārlūkot izejas kodu

org-export: Secondary strings are transcoded with `org-export-data'

* contrib/lisp/org-export.el (org-export-transcoder): New function.
(org-export-data): Also export secondary strings.  Refactored.
(org-export-secondary-string): Remove function.
(org-export-expand): Fix code indentation.
(org-export-expand-macro): Use `org-export-data' instead of
`org-export-secondary-string'.
* 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-inlinetask,
  org-e-ascii-item, org-e-ascii-link, org-e-ascii-quote-section,
  org-e-ascii--table-cell-width): Use `org-export-data' instead of
  `org-export-secondary-string'.
* contrib/lisp/org-e-html.el (org-e-html-footnote-section,
org-e-html--caption/label-string, org-e-html-meta-info,
org-e-html-preamble, org-e-html-template,
org-e-html-format-headline--wrap, org-e-html-headline,
org-e-html-item, org-e-html-link): Use `org-export-data' instead of
`org-export-secondary-string'.
* contrib/lisp/org-e-latex.el (org-e-latex--caption/label-string,
  org-e-latex-template, 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): Use `org-export-data'
  instead of `org-export-secondary-string'.
* contrib/lisp/org-e-odt.el (org-e-odt-format-preamble,
  org-e-odt-format-label, org-e-odt-update-meta-file,
  org-e-odt--caption/label-string, org-e-odt-footnote-def,
  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):
  Use `org-export-data' instead of `org-export-secondary-string'.
Nicolas Goaziou 13 gadi atpakaļ
vecāks
revīzija
03813d9bc4

+ 25 - 35
contrib/lisp/org-e-ascii.el

@@ -62,7 +62,6 @@
 (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 info))
 (declare-function
  org-export-to-file "org-export"
  (backend file &optional subtreep visible-only body-only ext-plist))
@@ -584,13 +583,11 @@ title."
 		 #'number-to-string
 		 (org-export-get-headline-number element info) ".")
 		" ")))
-	 (text (org-export-secondary-string
-		(org-element-property :title element) info))
+	 (text (org-export-data (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 info) " ")))))
+		 (and todo (concat (org-export-data todo info) " ")))))
 	 (tags (and (not notags)
 		    (plist-get info :with-tags)
 		    (org-element-property :tags element)))
@@ -643,8 +640,7 @@ keyword."
 	(org-e-ascii--fill-string
 	 (format
 	  title-fmt reference
-	  (if (not caption) name
-	    (org-export-secondary-string (car caption) info)))
+	  (if (not caption) name (org-export-data (car caption) info)))
 	 (org-e-ascii--current-text-width element info) info)))))
 
 (defun org-e-ascii--build-toc (info &optional n keyword)
@@ -709,9 +705,8 @@ generation.  INFO is a plist used as a communication channel."
 	       (org-e-ascii--fill-string
 		(let ((caption (org-element-property :caption src-block)))
 		  (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)) info)))
+		    (org-export-data (or (cdr caption) (car caption)) info)))
 		(- text-width (length initial-text)) info)
 	       (length initial-text))))))
 	(org-export-collect-listings info) "\n")))))
@@ -749,8 +744,7 @@ generation.  INFO is a plist used as a communication channel."
 		(let ((caption (org-element-property :caption table)))
 		  (if (not caption) (org-element-property :name table)
 		    ;; Use short name in priority, if available.
-		    (org-export-secondary-string
-		     (or (cdr caption) (car caption)) info)))
+		    (org-export-data (or (cdr caption) (car caption)) info)))
 		(- text-width (length initial-text)) info)
 	       (length initial-text))))))
 	(org-export-collect-tables info) "\n")))))
@@ -809,7 +803,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 info)))))
+		       (org-export-data desc info)))))
        (cond
 	;; Coderefs, radio links and fuzzy links are ignored.
 	((member type '("coderef" "radio" "fuzzy")) nil)
@@ -847,12 +841,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) info))
+	(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-secondary-string auth info)))))
+		       (and auth (org-export-data auth info)))))
 	(email (and (plist-get info :with-email)
-		    (org-export-secondary-string (plist-get info :email) info)))
+		    (org-export-data (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.
@@ -962,7 +956,7 @@ holding export options."
 		      ;; 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 info))
+		       (concat id (org-export-data def info))
 		       text-width info))))))
 	     definitions "\n\n"))))
        ;; 5. Creator.  Ignore `comment' value as there are no comments in
@@ -1227,13 +1221,10 @@ contextual information."
 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) info))
+	(title (org-export-data (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 info)))))
+		   (let ((todo (org-element-property :todo-keyword inlinetask)))
+		     (and todo (org-export-data todo info)))))
 	(todo-type (org-element-property :todo-type inlinetask))
 	(tags (and (plist-get info :with-tags)
 		   (org-element-property :tags inlinetask)))
@@ -1289,10 +1280,8 @@ contextual information."
 	 (org-list-bullet-string
 	  (case (org-element-property :type (org-export-get-parent item info))
 	    (descriptive
-	     (concat
-	      (org-export-secondary-string
-	       (org-element-property :tag item) info)
-	      ": "))
+	     (concat (org-export-data (org-element-property :tag item) info)
+		     ": "))
 	    (ordered
 	     ;; Return correct number for ITEM, paying attention to
 	     ;; counters.
@@ -1393,7 +1382,7 @@ INFO is a plist holding contextual information."
      ;; Do not apply a special syntax on radio links.  Though, parse
      ;; and transcode path to have a proper display of contents.
      ((string= type "radio")
-      (org-export-secondary-string
+      (org-export-data
        (org-element-parse-secondary-string
 	(org-element-property :path link)
 	(cdr (assq 'radio-target org-element-object-restrictions)))
@@ -1520,9 +1509,8 @@ holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (let ((width (org-e-ascii--current-text-width quote-section info))
 	(value
-	 (org-export-secondary-string
-	  (org-remove-indentation
-	   (org-element-property :value quote-section))
+	 (org-export-data
+	  (org-remove-indentation (org-element-property :value quote-section))
 	  info)))
     (org-e-ascii--indent-string
      value
@@ -1663,11 +1651,13 @@ are ignored. "
 	 (lambda (row)
 	   (setq max-width
 		 (max (length
-		       (org-export-data
-			(elt (if specialp (car (org-element-contents row))
-			       (org-element-contents row))
-			     col)
-			info))
+		       (mapconcat
+			(lambda (obj) (org-export-data obj info))
+			(org-element-contents
+			 (elt (if specialp (car (org-element-contents row))
+				(org-element-contents row))
+			      col))
+			""))
 		      max-width))))
 	max-width)))
 

+ 20 - 29
contrib/lisp/org-e-html.el

@@ -71,7 +71,6 @@
 		  "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 info))
 (declare-function org-export-solidify-link-text "org-export" (s))
 (declare-function
  org-export-to-buffer "org-export"
@@ -1364,8 +1363,7 @@ Replaces invalid characters with \"_\"."
 		(cons n (if (equal (org-element-type raw) 'org-data)
 			    (org-trim (org-export-data raw info))
 			  (format "<p>%s</p>"
-				  (org-trim
-				   (org-export-secondary-string raw info))))))))
+				  (org-trim (org-export-data raw info))))))))
     (when fn-alist
       (org-e-html-format-footnotes-section
        (nth 4 (or (assoc (plist-get info :language)
@@ -1407,15 +1405,14 @@ 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) info)
+	      (org-export-data (cdr caption) info)
 	      label-str
-	      (org-export-secondary-string (car caption) info)))
+	      (org-export-data (car caption) info)))
      ;; Standard caption format.
      ;; (t (format "\\caption{%s%s}\n"
      ;; 		label-str
-     ;; 		(org-export-secondary-string (car caption) info)))
-
-     (t (org-export-secondary-string (car caption) info)))))
+     ;; 		(org-export-data (car caption) info)))
+     (t (org-export-data (car caption) info)))))
 
 (defun org-e-html--find-verb-separator (s)
   "Return a character not used in string S.
@@ -1454,10 +1451,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) info))
+  (let* ((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-secondary-string auth info)))))
+			(and auth (org-export-data auth info)))))
 	 (description (plist-get info :description))
 	 (keywords (plist-get info :keywords)))
     (concat
@@ -1519,9 +1516,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) info))
+    (let* ((title (org-export-data (plist-get info :title) info))
 	   (date (org-e-html-format-date info))
-	   (author (org-export-secondary-string (plist-get info :author) info))
+	   (author (org-export-data (plist-get info :author) info))
 	   (lang-words (or (assoc (plist-get info :language)
 				  org-export-language-setup)
 			   (assoc "en" org-export-language-setup)))
@@ -1670,8 +1667,7 @@ original parsed data.  INFO is a plist holding export options."
 		     (nth 1 org-e-html-divs)))
    ;; document title
    (format "
-<h1 class=\"title\">%s</h1>\n" (org-export-secondary-string
-				(plist-get info :title) info))
+<h1 class=\"title\">%s</h1>\n" (org-export-data (plist-get info :title) info))
    ;; table of contents
    (let ((depth (plist-get info :with-toc)))
      (when (wholenump depth) (org-e-html-toc depth info)))
@@ -2031,15 +2027,12 @@ holding contextual information."
 			      (mapconcat 'number-to-string
 					 headline-number ".")))
 	 (todo (and (plist-get info :with-todo-keywords)
-		    (let ((todo (org-element-property
-				 :todo-keyword headline)))
-		      (and todo
-			   (org-export-secondary-string todo info)))))
+		    (let ((todo (org-element-property :todo-keyword headline)))
+		      (and todo (org-export-data 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) info))
+	 (text (org-export-data (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
@@ -2064,12 +2057,10 @@ CONTENTS holds the contents of the headline.  INFO is a plist
 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) info))
+	 (text (org-export-data (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 info)))))
+		    (let ((todo (org-element-property :todo-keyword headline)))
+		      (and todo (org-export-data todo info)))))
 	 (todo-type (and todo (org-element-property :todo-type headline)))
 	 (tags (and (plist-get info :with-tags)
 		    (org-element-property :tags headline)))
@@ -2237,7 +2228,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 info)))))
+		(and tag (org-export-data tag info)))))
     (org-e-html-format-list-item
      contents type checkbox (or tag counter))))
 
@@ -2453,7 +2444,7 @@ INFO is a plist holding contextual information.  See
      ((string= type "radio")
       (format "<a href=\"#%s\">%s</a>"
 	      (org-export-solidify-link-text path)
-	      (org-export-secondary-string
+	      (org-export-data
 	       (org-element-parse-secondary-string
 		path (org-element-restriction 'radio-target))
 	       info)))
@@ -2468,7 +2459,7 @@ INFO is a plist holding contextual information.  See
 	  ('nil
 	   (format "<i>%s</i>"
 		   (or desc
-		       (org-export-secondary-string
+		       (org-export-data
 			(org-element-property :raw-link link) info))))
 	  ;; Fuzzy link points to an invisible target.
 	  (keyword nil)
@@ -2485,7 +2476,7 @@ INFO is a plist holding contextual information.  See
 		   (cond
 		    (desc desc)
 		    ((plist-get info :section-numbers) section-no)
-		    (t (org-export-secondary-string
+		    (t (org-export-data
 			(org-element-property :title destination) info))))
 	     (format "<a href=\"#%s\">%s</a>" label desc)))
           ;; Fuzzy link points to a target.  Do as above.

+ 20 - 31
contrib/lisp/org-e-latex.el

@@ -71,7 +71,6 @@
 		  "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 info))
 (declare-function org-export-solidify-link-text "org-export" (s))
 (declare-function
  org-export-to-buffer "org-export"
@@ -746,13 +745,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) info)
+	      (org-export-data (cdr caption) info)
 	      label-str
-	      (org-export-secondary-string (car caption) info)))
+	      (org-export-data (car caption) info)))
      ;; Standard caption format.
      (t (format "\\caption{%s%s}\n"
 		label-str
-		(org-export-secondary-string (car caption) info))))))
+		(org-export-data (car caption) info))))))
 
 (defun org-e-latex--guess-inputenc (header)
   "Set the coding system in inputenc to what the buffer is.
@@ -858,7 +857,7 @@ See `org-e-latex-text-markup-alist' for details."
   "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) info)))
+  (let ((title (org-export-data (plist-get info :title) info)))
     (concat
      ;; 1. Time-stamp.
      (and (plist-get info :time-stamp-file)
@@ -890,10 +889,9 @@ 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 info)))))
+			  (and auth (org-export-data auth info)))))
 	   (email (and (plist-get info :with-email)
-		       (org-export-secondary-string
-			(plist-get info :email) info))))
+		       (org-export-data (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))
@@ -1138,10 +1136,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	      "\\footnotetext[%s]{%s}"
 	      (org-export-get-footnote-number ref info)
 	      (org-trim
-	       (funcall
-		(if (eq (org-element-property :type ref) 'inline)
-		    'org-export-secondary-string
-		  'org-export-data)
+	       (org-export-data
 		(org-export-get-footnote-definition ref info) info))))
 	   (funcall search-refs def) ""))))))))
 
@@ -1178,12 +1173,11 @@ holding contextual information."
 	     ((= (length sec) 4)
 	      (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) info))
+	 (text (org-export-data (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 info)))))
+		 (and todo (org-export-data todo info)))))
 	 (todo-type (and todo (org-element-property :todo-type headline)))
 	 (tags (and (plist-get info :with-tags)
 		    (org-element-property :tags headline)))
@@ -1297,13 +1291,10 @@ contextual information."
   "Transcode an INLINETASK element from Org to LaTeX.
 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) info))
+  (let ((title (org-export-data (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 info)))))
+		   (let ((todo (org-element-property :todo-keyword inlinetask)))
+		     (and todo (org-export-data todo info)))))
 	(todo-type (org-element-property :todo-type inlinetask))
 	(tags (and (plist-get info :with-tags)
 		   (org-element-property :tags inlinetask)))
@@ -1364,8 +1355,7 @@ contextual information."
 			   ((eq checkbox 'off) "$\\Box$ ")
 			   ((eq checkbox 'trans) "$\\boxminus$ "))))
 	 (tag (let ((tag (org-element-property :tag item)))
-		(and tag
-		     (format "[%s]" (org-export-secondary-string tag info))))))
+		(and tag (format "[%s]" (org-export-data tag info))))))
     (concat counter "\\item" tag " " checkbox contents)))
 
 
@@ -1535,7 +1525,7 @@ INFO is a plist holding contextual information.  See
      ((string= type "radio")
       (format "\\hyperref[%s]{%s}"
 	      (org-export-solidify-link-text path)
-	      (org-export-secondary-string
+	      (org-export-data
 	       (org-element-parse-secondary-string
 		path (cdr (assq 'radio-target org-element-object-restrictions)))
 	       info)))
@@ -1550,7 +1540,7 @@ INFO is a plist holding contextual information.  See
 	  ('nil
 	   (format "\\texttt{%s}"
 		   (or desc
-		       (org-export-secondary-string
+		       (org-export-data
 			(org-element-property :raw-link link) info))))
 	  ;; Fuzzy link points to an invisible target.
 	  (keyword nil)
@@ -1569,7 +1559,7 @@ INFO is a plist holding contextual information.  See
 		 (format "\\ref{%s}" label)
 	       (format "\\hyperref[%s]{%s}" label
 		       (or desc
-			   (org-export-secondary-string
+			   (org-export-data
 			    (org-element-property :title destination) info))))))
           ;; Fuzzy link points to a target.  Do as above.
 	  (otherwise
@@ -1858,12 +1848,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) info)))
+	       (let ((main (org-export-data (car caption) info)))
 		 (if (not (cdr caption)) (format "{%s}" main)
-		   (format
-		    "{[%s]%s}"
-		    (org-export-secondary-string (cdr caption) info)
-		    main))))))
+		   (format "{[%s]%s}"
+			   (org-export-data (cdr caption) info)
+			   main))))))
 	(concat
 	 ;; Options.
 	 (format "\\lstset{%s}\n"

+ 25 - 34
contrib/lisp/org-e-odt.el

@@ -47,10 +47,10 @@
 ;; progress. See org-html.el.
 
 (defun org-e-odt-format-preamble (info)
-  (let* ((title (org-export-secondary-string (plist-get info :title) info))
+  (let* ((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-secondary-string auth info)))))
+			(and auth (org-export-data 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"))
@@ -859,10 +859,9 @@ 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) info)))
+	 (caption (and (car caption) (org-export-data (car caption) info)))
 	 (short-caption (and short-caption
-			     (org-export-secondary-string short-caption info))))
+			     (org-export-data short-caption info))))
     (when (or label caption)
       (let* ((default-category
 	       (cond
@@ -1079,9 +1078,9 @@ ATTR is a string of other attributes of the a element."
       (insert "\n</manifest:manifest>"))))
 
 (defun org-e-odt-update-meta-file (info) ; FIXME opt-plist
-  (let ((title (org-export-secondary-string (plist-get info :title) info))
+  (let ((title (org-export-data (plist-get info :title) info))
 	(author (or (let ((auth (plist-get info :author)))
-		      (and auth (org-export-secondary-string auth info))) ""))
+		      (and auth (org-export-data auth info))) ""))
 	(date (org-e-odt-format-date (plist-get info :date)))
 	(email (plist-get info :email))
 	(keywords (plist-get info :keywords))
@@ -1371,7 +1370,6 @@ 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 info))
 (declare-function org-export-solidify-link-text "org-export" (s))
 (declare-function
  org-export-to-buffer "org-export"
@@ -2743,15 +2741,14 @@ 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) info)
+	      (org-export-data (cdr caption) info)
 	      label-str
-	      (org-export-secondary-string (car caption) info)))
+	      (org-export-data (car caption) info)))
      ;; Standard caption format.
      ;; (t (format "\\caption{%s%s}\n"
      ;; 		label-str
-     ;; 		(org-export-secondary-string (car caption) info)))
-
-     (t (org-export-secondary-string (car caption) info)))))
+     ;; 		(org-export-data (car caption) info)))
+     (t (org-export-data (car caption) info)))))
 
 (defun org-e-odt--find-verb-separator (s)
   "Return a character not used in string S.
@@ -3073,7 +3070,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (if (equal (org-element-type raw) 'org-data)
       (org-trim (org-export-data raw info)) ; fix paragraph style
     (org-e-odt-format-stylized-paragraph
-     'footnote (org-trim (org-export-secondary-string raw info)))))
+     'footnote (org-trim (org-export-data raw info)))))
 
 (defvar org-e-odt-footnote-separator
   (org-e-odt-format-fontify "," 'superscript))
@@ -3127,15 +3124,12 @@ holding contextual information."
 			      (mapconcat 'number-to-string
 					 headline-number ".")))
 	 (todo (and (plist-get info :with-todo-keywords)
-		    (let ((todo (org-element-property
-				 :todo-keyword headline)))
-		      (and todo
-			   (org-export-secondary-string todo info)))))
+		    (let ((todo (org-element-property :todo-keyword headline)))
+		      (and todo (org-export-data 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) info))
+	 (text (org-export-data (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
@@ -3161,8 +3155,7 @@ holding contextual information."
   (let* ((numberedp (org-export-numbered-headline-p headline info))
 	 ;; 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) info))
+	 (text (org-export-data (org-element-property :title headline) info))
 	 ;; Create the headline text.
 	 (full-text (org-e-odt-format-headline--wrap headline info)))
     (cond
@@ -3300,7 +3293,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 info)))))
+		(and tag (org-export-data tag info)))))
     (org-e-odt-format-list-item
      contents type checkbox (or tag counter))))
 
@@ -3365,9 +3358,8 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	  (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) info)))
-	  (caption (and (car caption)
-			(org-export-secondary-string (car caption) info)))
+			      (org-export-data (cdr caption) info)))
+	  (caption (and (car caption) (org-export-data (car caption) info)))
 	  (label (org-element-property :name latex-environment))
 	  (attr nil)			; FIXME
 	  (label (org-element-property :name latex-environment)))
@@ -3594,7 +3586,7 @@ INFO is a plist holding contextual information.  See
      ;; display of the contents.
      ((string= type "radio")
       (org-e-odt-format-internal-link
-       (org-export-secondary-string
+       (org-export-data
 	(org-element-parse-secondary-string
 	 path (org-element-restriction 'radio-target))
 	info)
@@ -3609,7 +3601,7 @@ INFO is a plist holding contextual information.  See
 	  ;; Fuzzy link points nowhere.
 	  ('nil
 	   (org-e-odt-format-fontify
-	    (or desc (org-export-secondary-string
+	    (or desc (org-export-data
 		      (org-element-property :raw-link link) info))
 	    'emphasis))
 	  ;; Fuzzy link points to an invisible target.
@@ -3627,7 +3619,7 @@ INFO is a plist holding contextual information.  See
 		   (cond
 		    (desc desc)
 		    ((plist-get info :section-numbers) section-no)
-		    (t (org-export-secondary-string
+		    (t (org-export-data
 			(org-element-property :title destination) info))))
 	     (org-e-odt-format-internal-link desc label)))
 	  ;; Fuzzy link points to a target.  Do as above.
@@ -3871,14 +3863,13 @@ 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) info)))
-	 (caption (and (car caption)
-		       (org-export-secondary-string (car caption) info)))
+			     (org-export-data (cdr caption) info)))
+	 (caption (and (car caption) (org-export-data (car caption) info)))
 	 (label (org-element-property :name src-block)))
     ;; FIXME: Handle caption
     ;; caption-str (when caption)
-    ;; (main (org-export-secondary-string (car caption) info))
-    ;; (secondary (org-export-secondary-string (cdr caption) info))
+    ;; (main (org-export-data (car caption) info))
+    ;; (secondary (org-export-data (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)))

+ 106 - 130
contrib/lisp/org-export.el

@@ -1535,13 +1535,9 @@ non-nil, is a list of tags marking a subtree as exportable."
 ;;
 ;; `org-export-data' reads a parse tree (obtained with, i.e.
 ;; `org-element-parse-buffer') and transcodes it into a specified
-;; back-end output.  It takes care of updating local properties,
-;; filtering out elements or objects according to export options and
-;; organizing the output blank lines and white space are preserved.
-;;
-;; Though, this function is inapropriate for secondary strings, which
-;; require a fresh copy of the plist passed as INFO argument.  Thus,
-;; `org-export-secondary-string' is provided for that specific task.
+;; back-end output.  It takes care of filtering out elements or
+;; objects according to export options and organizing the output blank
+;; lines and white space are preserved.
 ;;
 ;; Internally, three functions handle the filtering of objects and
 ;; elements during the export.  In particular,
@@ -1551,122 +1547,106 @@ non-nil, is a list of tags marking a subtree as exportable."
 ;; `org-export-expand' transforms the others back into their original
 ;; shape.
 
+(defun org-export-transcoder (blob info)
+  "Return appropriate transcoder for BLOB.
+INFO is a plist containing export directives."
+  (let ((type (org-element-type blob)))
+    ;; Return contents only for complete parse trees.
+    (if (eq type 'org-data) (lambda (blob contents info) contents)
+      (let ((transcoder
+             (intern (format "org-%s-%s" (plist-get info :back-end) type))))
+        (and (fboundp transcoder) transcoder)))))
+
 (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'.
-
-INFO is a plist holding export options and also used as
-a communication channel between elements when walking the nested
-list.
-
-Return transcoded string."
-  (mapconcat
-   ;; BLOB can be an element, an object, a string, or nil.
-   (lambda (blob)
-     (cond
-      ((not blob) nil)
-      ;; BLOB is a string.  Check if the optional transcoder for plain
-      ;; text exists, and call it in that case.  Otherwise, simply
-      ;; return string.  Also update INFO and call
-      ;; `org-export-filter-plain-text-functions'.
-      ((stringp blob)
-       (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)
-	  info)))
-      ;; BLOB is an element or an object.
-      (t
-       (let* ((type (org-element-type blob))
-	      ;; 1. Determine the appropriate TRANSCODER.
-	      (transcoder
-	       (cond
-		;; 1.0 A full Org document is inserted.
-		((eq type 'org-data) 'identity)
-		;; 1.1. BLOB should be ignored.
-		((member blob (plist-get info :ignore-list)) nil)
-		;; 1.2. BLOB shouldn't be transcoded.  Interpret it
-		;;      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"
-						(plist-get info :back-end)
-						type))))
-		     (and (fboundp trans) trans)))))
-	      ;; 2. Compute CONTENTS of BLOB.
-	      (contents
-	       (cond
-		;; 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 info))
-		;; Case 2. For a greater element.
-		((memq type org-element-greater-elements)
-		 ;; Ignore contents of an archived tree
-		 ;; when `:with-archived-trees' is `headline'.
-		 (unless (and
-			  (eq type 'headline)
-			  (eq (plist-get info :with-archived-trees) 'headline)
-			  (org-element-property :archivedp blob))
-		   (org-element-normalize-string (org-export-data blob info))))
-		;; Case 3. For an element containing objects.
-		(t
-		 (org-export-data
-		  (org-element-normalize-contents
-		   blob
-		   ;; When normalizing contents of the first paragraph
-		   ;; in an item or a footnote definition, ignore
-		   ;; first line's indentation: there is none and it
-		   ;; might be misleading.
-		   (and (eq type 'paragraph)
-			(not (org-export-get-previous-element blob info))
-			(let ((parent (org-export-get-parent blob info)))
-			  (memq (org-element-type parent)
-				'(footnote-definition item)))))
-		  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))
-			  info))
-			(t (funcall transcoder blob contents info)))))
-	 ;; 4. Return results.
-	 (cond
-	  ((not results) nil)
-	  ;; No filter for a full document.
-	  ((eq type 'org-data) results)
-	  ;; Otherwise, update INFO, append the same white space
-	  ;; between elements or objects as in the original buffer,
-	  ;; and call appropriate filters.
-	  (t
-	   (let ((results
-		  (org-export-filter-apply-functions
-		   (plist-get info (intern (format ":filter-%s" type)))
-		   (let ((post-blank (org-element-property :post-blank blob)))
-		     (if (memq type org-element-all-elements)
-			 (concat (org-element-normalize-string results)
-				 (make-string post-blank ?\n))
-		       (concat results (make-string post-blank ? ))))
-		   info)))
-	     ;; Eventually return string.
-	     results)))))))
-   (org-element-contents data) ""))
-
-(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'.  INFO is a plist used as
-a communication channel.
+DATA is a parse tree, an element or an object or a secondary
+string.  INFO is a plist holding export options.
 
 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) (copy-sequence info))))
+  (let* ((type (org-element-type data))
+         (results
+          (cond
+           ;; Ignored element/object.
+           ((member data (plist-get info :ignore-list)) nil)
+           ;; Plain text.
+           ((eq type 'plain-text)
+            (org-export-filter-apply-functions
+             (plist-get info :filter-plain-text)
+             (let ((transcoder (org-export-transcoder data info)))
+               (if transcoder (funcall transcoder data info) data))
+             info))
+           ;; Uninterpreted element/object: change it back to Org
+           ;; syntax.
+           ((not (org-export-interpret-p data info))
+            (org-export-expand
+             data
+             (org-element-normalize-string
+              (mapconcat (lambda (blob) (org-export-data blob info))
+                         (org-element-contents data)
+                         ""))))
+           ;; Secondary string.
+           ((not type)
+            (mapconcat (lambda (obj) (org-export-data obj info)) data ""))
+           ;; Element/Object without contents or, as a special case,
+           ;; headline with archive tag and archived trees restricted
+           ;; to title only.
+           ((or (not (org-element-contents data))
+                (and (eq type 'headline)
+                     (eq (plist-get info :with-archived-trees) 'headline)
+                     (org-element-property :archivedp data)))
+            (let ((transcoder (org-export-transcoder data info)))
+              (and (fboundp transcoder) (funcall transcoder data nil info))))
+           ;; Element/Object with contents.
+           (t
+            (let ((transcoder (org-export-transcoder data info)))
+              (when transcoder
+                (let* ((greaterp (memq type org-element-greater-elements))
+		       (objectp (and (not greaterp)
+				     (memq type org-element-recursive-objects)))
+		       (contents
+			(mapconcat
+			 (lambda (element) (org-export-data element info))
+			 (org-element-contents
+			  (if (or greaterp objectp) data
+			    ;; Elements directly containing objects
+			    ;; must have their indentation normalized
+			    ;; first.
+			    (org-element-normalize-contents
+			     data
+			     ;; When normalizing contents of the first
+			     ;; paragraph in an item or a footnote
+			     ;; definition, ignore first line's
+			     ;; indentation: there is none and it
+			     ;; might be misleading.
+			     (when (eq type 'paragraph)
+			       (let ((parent (org-export-get-parent data info)))
+				 (and (equal (car (org-element-contents parent))
+					     data)
+				      (memq (org-element-type parent)
+					    '(footnote-definition item))))))))
+			 "")))
+                  (funcall transcoder data
+			   (if greaterp (org-element-normalize-string contents)
+			     contents)
+			   info))))))))
+    (cond
+     ((not results) nil)
+     ((memq type '(org-data plain-text nil)) results)
+     ;; Append the same white space between elements or objects as in
+     ;; the original buffer, and call appropriate filters.
+     (t
+      (let ((results
+             (org-export-filter-apply-functions
+              (plist-get info (intern (format ":filter-%s" type)))
+              (let ((post-blank (org-element-property :post-blank data)))
+                (if (memq type org-element-all-elements)
+                    (concat (org-element-normalize-string results)
+                            (make-string post-blank ?\n))
+                  (concat results (make-string post-blank ? ))))
+              info)))
+        ;; Eventually return string.
+        results)))))
 
 (defun org-export-interpret-p (blob info)
   "Non-nil if element or object BLOB should be interpreted as Org syntax.
@@ -1696,8 +1676,9 @@ a plist."
   "Expand a parsed element or object to its original state.
 BLOB is either an element or an object.  CONTENTS is its
 contents, as a string or nil."
-  (funcall (intern (format "org-element-%s-interpreter" (org-element-type blob)))
-	   blob contents))
+  (funcall
+   (intern (format "org-element-%s-interpreter" (org-element-type blob)))
+   blob contents))
 
 (defun org-export-ignore-element (element info)
   "Add ELEMENT to `:ignore-list' in INFO.
@@ -2571,10 +2552,8 @@ DATA is the parse tree from which definitions are collected.
 INFO is the plist used as a communication channel.
 
 Definitions are sorted by order of references.  They either
-appear as Org data (transcoded with `org-export-data') or as
-a secondary string for inlined footnotes (transcoded with
-`org-export-secondary-string').  Unreferenced definitions are
-ignored."
+appear as Org data or as a secondary string for inlined
+footnotes.  Unreferenced definitions are ignored."
   (let (num-alist
 	(collect-fn
 	 (function
@@ -2944,12 +2923,9 @@ INFO is a plist holding export options."
   (let* ((key (org-element-property :key macro))
 	 (args (org-element-property :args macro))
 	 ;; User's macros are stored in the communication channel with
-	 ;; a ":macro-" prefix.  If it's a string leave it as-is.
-	 ;; Otherwise, it's a secondary string that needs to be
-	 ;; expanded recursively.
-	 (value
-	  (let ((val (plist-get info (intern (format ":macro-%s" key)))))
-	    (if (stringp val) val (org-export-secondary-string val info)))))
+	 ;; a ":macro-" prefix.
+	 (value (org-export-data
+		 (plist-get info (intern (format ":macro-%s" key))) val info)))
     ;; Replace arguments in VALUE.
     (let ((s 0) n)
       (while (string-match "\\$\\([0-9]+\\)" value s)