Browse Source

org-export: Fix subtree option with `split' behaviour

* contrib/lisp/org-export.el (org-export--get-subtree-options): Store
  value of options with `split' behaviour as a list of strings, not
  simply as a string.  Small refactoring.
* testing/lisp/test-org-export.el: Add tests.
Nicolas Goaziou 5 years ago
parent
commit
5107ca3c9b
2 changed files with 37 additions and 8 deletions
  1. 11 8
      contrib/lisp/org-export.el
  2. 26 0
      testing/lisp/test-org-export.el

+ 11 - 8
contrib/lisp/org-export.el

@@ -1396,9 +1396,8 @@ for export.  Return options as a plist."
      (unless (org-at-heading-p) (org-back-to-heading t))
      ;; Take care of EXPORT_TITLE. If it isn't defined, use headline's
      ;; title as its fallback value.
-     (when (setq prop (progn (looking-at org-todo-line-regexp)
-			     (or (save-match-data
-				   (org-entry-get (point) "EXPORT_TITLE"))
+     (when (setq prop (or (org-entry-get (point) "EXPORT_TITLE")
+			  (progn (looking-at org-todo-line-regexp)
 				 (org-match-string-no-properties 3))))
        (setq plist
 	     (plist-put
@@ -1426,11 +1425,15 @@ for export.  Return options as a plist."
 			(plist-put
 			 plist
 			 (car option)
-			 ;; Parse VALUE if required.
-			 (if (member property org-element-document-properties)
-			     (org-element-parse-secondary-string
-			      value (org-element-restriction 'keyword))
-			   value))))))))
+			 (cond
+			  ;; Parse VALUE if required.
+			  ((member property org-element-document-properties)
+			   (org-element-parse-secondary-string
+			    value (org-element-restriction 'keyword)))
+			  ;; If BEHAVIOUR is `split' expected value is
+			  ;; a list of strings, not a string.
+			  ((eq (nth 4 option) 'split) (org-split-string value))
+			  (t value)))))))))
 	;; Also look for both general keywords and back-end specific
 	;; options if BACKEND is provided.
 	(append (and backend (org-export-backend-options backend))

+ 26 - 0
testing/lisp/test-org-export.el

@@ -185,6 +185,32 @@ Paragraph"
     (forward-line)
     (should (equal (plist-get (org-export-get-environment nil t) :date)
 		   '("29-03-2012"))))
+  ;; Properties with `split' behaviour are stored as a list of
+  ;; strings.
+  (should
+   (equal '("a" "b")
+	  (org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
+* Headline
+  :PROPERTIES:
+  :EXPORT_EXCLUDE_TAGS: a b
+  :END:
+Paragraph"
+	    (progn
+	      (forward-line)
+	      (plist-get (org-export-get-environment nil t) :exclude-tags)))))
+  ;; Handle :PROPERTY+: syntax.
+  (should
+   (equal '("a" "b")
+	  (org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
+* Headline
+  :PROPERTIES:
+  :EXPORT_EXCLUDE_TAGS: a
+  :EXPORT_EXCLUDE_TAGS+: b
+  :END:
+Paragraph"
+	    (progn
+	      (forward-line)
+	      (plist-get (org-export-get-environment nil t) :exclude-tags)))))
   ;; Export properties are case-insensitive.
   (org-test-with-temp-text "* Headline
   :PROPERTIES: