Просмотр исходного кода

org-element: Interpret correctly switches in example blocks

* contrib/lisp/org-element.el (org-element-example-block-interpreter):
  Interpret correctly switches in example blocks.
* testing/lisp/test-org-element.el: Add test.
Nicolas Goaziou 13 лет назад
Родитель
Сommit
2ab6367daf
2 измененных файлов с 9 добавлено и 3 удалено
  1. 2 2
      contrib/lisp/org-element.el
  2. 7 1
      testing/lisp/test-org-element.el

+ 2 - 2
contrib/lisp/org-element.el

@@ -1135,8 +1135,8 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
 (defun org-element-example-block-interpreter (example-block contents)
   "Interpret EXAMPLE-BLOCK element as Org syntax.
 CONTENTS is nil."
-  (let ((options (org-element-property :options example-block)))
-    (concat "#+BEGIN_EXAMPLE" (and options (concat " " options)) "\n"
+  (let ((switches (org-element-property :switches example-block)))
+    (concat "#+BEGIN_EXAMPLE" (and switches (concat " " switches)) "\n"
 	    (org-remove-indentation
 	     (org-element-property :value example-block))
 	    "#+END_EXAMPLE")))

+ 7 - 1
testing/lisp/test-org-element.el

@@ -536,9 +536,15 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] =>  0:01"))
 
 (ert-deftest test-org-element/example-block-interpreter ()
   "Test example block interpreter."
+  ;; Without switches.
   (should (equal (org-test-parse-and-interpret
 		  "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE")
-		 "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE\n")))
+		 "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE\n"))
+  ;; With switches.
+  (should
+   (equal (org-test-parse-and-interpret
+	   "#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE")
+	  "#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE\n")))
 
 (ert-deftest test-org-element/export-block-interpreter ()
   "Test export block interpreter."