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.
This commit is contained in:
Nicolas Goaziou 2012-04-30 23:44:30 +02:00
parent 537ab2ada3
commit 2ab6367daf
2 changed files with 9 additions and 3 deletions

View File

@ -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")))

View File

@ -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."