浏览代码

ox: Fix `org-export-with-footnotes' behaviour

* lisp/ox.el (org-export--skip-p, org-export--interpret-p): When
  `org-export-with-footnotes' is nil, ignore completely footnotes
  references and definitions instead of exporting them verbatim.
* testing/lisp/test-ox.el: Add tests.
Nicolas Goaziou 12 年之前
父节点
当前提交
d408d721c3
共有 2 个文件被更改,包括 17 次插入3 次删除
  1. 2 3
      lisp/ox.el
  2. 15 0
      testing/lisp/test-ox.el

+ 2 - 3
lisp/ox.el

@@ -1994,6 +1994,8 @@ a tree with a select tag."
 		  (if (eq (car with-drawers-p) 'not)
 		      (member-ignore-case name (cdr with-drawers-p))
 		    (not (member-ignore-case name with-drawers-p))))))))
+    ((footnote-definition footnote-reference)
+     (not (plist-get options :with-footnotes)))
     ((headline inlinetask)
      (let ((with-tasks (plist-get options :with-tasks))
 	   (todo (org-element-property :todo-keyword blob))
@@ -2230,9 +2232,6 @@ according to export options INFO, stored as a plist."
      (plist-get info :with-emphasize))
     ;; ... fixed-width areas.
     (fixed-width (plist-get info :with-fixed-width))
-    ;; ... footnotes...
-    ((footnote-definition footnote-reference)
-     (plist-get info :with-footnotes))
     ;; ... LaTeX environments and fragments...
     ((latex-environment latex-fragment)
      (let ((with-latex-p (plist-get info :with-latex)))

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

@@ -361,6 +361,21 @@ Paragraph"
 	(should
 	 (equal (org-export-as 'test nil nil nil '(:with-drawers (not "BAR")))
 		":FOO:\nkeep\n:END:\n")))))
+  ;; Footnotes.
+  (should
+   (equal "Footnote?"
+	  (let ((org-footnote-section nil))
+	    (org-test-with-temp-text "Footnote?[fn:1]\n\n[fn:1] Def"
+	      (org-test-with-backend test
+		(org-trim
+		 (org-export-as 'test nil nil nil '(:with-footnotes nil))))))))
+  (should
+   (equal "Footnote?[fn:1]\n\n[fn:1] Def"
+	  (let ((org-footnote-section nil))
+	    (org-test-with-temp-text "Footnote?[fn:1]\n\n[fn:1] Def"
+	      (org-test-with-backend test
+		(org-trim
+		 (org-export-as 'test nil nil nil '(:with-footnotes t))))))))
   ;; Inlinetasks.
   (when (featurep 'org-inlinetask)
     (should