Pārlūkot izejas kodu

ox: Fix plain text export with `org-export-with-backend'

* lisp/ox.el (org-export-with-backend): Handle arity for plain text
  transcoder.
* testing/lisp/test-ox.el (test-org-export/with-backend): Add test.
Nicolas Goaziou 7 gadi atpakaļ
vecāks
revīzija
84cb63a44a
2 mainītis faili ar 14 papildinājumiem un 5 dzēšanām
  1. 3 1
      lisp/ox.el
  2. 11 4
      testing/lisp/test-ox.el

+ 3 - 1
lisp/ox.el

@@ -3699,7 +3699,9 @@ the communication channel used for export, as a plist."
 		    :translate-alist all-transcoders
 		    :exported-data (make-hash-table :test #'eq :size 401)))))
 	;; `:internal-references' are shared across back-ends.
-	(prog1 (funcall transcoder data contents new-info)
+	(prog1 (if (eq type 'plain-text)
+		   (funcall transcoder data new-info)
+		 (funcall transcoder data contents new-info))
 	  (plist-put info :internal-references
 		     (plist-get new-info :internal-references)))))))
 

+ 11 - 4
testing/lisp/test-ox.el

@@ -1771,12 +1771,19 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
    (equal "Success"
 	  (let (org-export-registered-backends)
 	    (org-export-define-backend 'test
-	      '((plain-text . (lambda (text contents info) "Failure"))))
+	      '((verbatim . (lambda (text contents info) "Failure"))))
 	    (org-export-define-backend 'test2
-	      '((plain-text . (lambda (text contents info) "Success"))))
-	    (org-export-with-backend 'test2 "Test"))))
+	      '((verbatim . (lambda (text contents info) "Success"))))
+	    (org-export-with-backend 'test2 '(verbatim (:value "=Test="))))))
+  ;; Corner case: plain-text transcoders have a different arity.
+  (should
+   (equal "Success"
+	  (org-export-with-backend
+	   (org-export-create-backend
+	    :transcoders '((plain-text . (lambda (text info) "Success"))))
+	   "Test")))
   ;; Provide correct back-end if transcoder needs to use recursive
-  ;; calls anyway.
+  ;; calls.
   (should
    (equal "Success\n"
 	  (let ((test-back-end