Selaa lähdekoodia

Fix export blocks

* lisp/org-element.el (org-element-export-block-parser): Type is always
  stored in capitals.

* testing/lisp/test-ox.el (test-org-export/export-block): Add test.

Reported-by: Suvayu Ali <fatkasuvayu+linux@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/103921>
Nicolas Goaziou 9 vuotta sitten
vanhempi
commit
7dc6748452
2 muutettua tiedostoa jossa 29 lisäystä ja 1 poistoa
  1. 1 1
      lisp/org-element.el
  2. 28 0
      testing/lisp/test-ox.el

+ 1 - 1
lisp/org-element.el

@@ -1968,7 +1968,7 @@ Assume point is at export-block beginning."
 						      contents-end)))
 	  (list 'export-block
 		(nconc
-		 (list :type backend
+		 (list :type (and backend (upcase backend))
 		       :begin begin
 		       :end end
 		       :value value

+ 28 - 0
testing/lisp/test-ox.el

@@ -1742,6 +1742,34 @@ Para2"
 	  "[fn:1] Para1\n\nPara2\n")))
 
 
+
+;;; Export blocks
+
+(ert-deftest test-org-export/export-block ()
+  "Test export blocks transcoding."
+  (should
+   (equal "Success!\n"
+	  (org-test-with-temp-text
+	      "#+BEGIN_EXPORT backend\nSuccess!\n#+END_EXPORT"
+	    (org-export-as
+	     (org-export-create-backend
+	      :transcoders '((export-block . (lambda (b _c _i)
+					       (org-element-property :value b)))
+			     (section . (lambda (_s c _i) c))))))))
+  (should
+   (equal "Success!\n"
+	  (org-test-with-temp-text
+	      "#+BEGIN_EXPORT backend\nSuccess!\n#+END_EXPORT"
+	    (org-export-as
+	     (org-export-create-backend
+	      :transcoders
+	      (list
+	       (cons 'export-block
+		     (lambda (b _c _i)
+		       (and (equal (org-element-property :type b) "BACKEND")
+			    (org-element-property :value b))))
+	       (cons 'section (lambda (_s c _i) c)))))))))
+
 
 ;;; Export Snippets