org-element-special-block-interpreter: Fix when no content

* lisp/org-element.el (org-element-special-block-interpreter): Use
empty string when content is nil.

*
testing/lisp/test-org-element.el (test-org-element/special-block-interpreter):
Test the case with no content.
This commit is contained in:
Bruno BARBIER 2022-10-19 00:37:05 +02:00 committed by Ihor Radchenko
parent 7f8e616f3b
commit 7d1e3dc38e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 11 additions and 3 deletions

View File

@ -1910,7 +1910,7 @@ Assume point is at the beginning of the block."
"Interpret SPECIAL-BLOCK element as Org syntax.
CONTENTS is the contents of the element."
(let ((block-type (org-element-property :type special-block)))
(format "#+begin_%s\n%s#+end_%s" block-type contents block-type)))
(format "#+begin_%s\n%s#+end_%s" block-type (or contents "") block-type)))

View File

@ -2425,7 +2425,11 @@ Outside list"
;; Handle non-empty blank line at the end of buffer.
(should
(org-test-with-temp-text "#+BEGIN_SPECIAL\nC\n#+END_SPECIAL\n "
(= (org-element-property :end (org-element-at-point)) (point-max)))))
(= (org-element-property :end (org-element-at-point)) (point-max))))
;; When contents is empty, the parsed contents is nil.
(should
(org-test-with-temp-text "#+BEGIN_SPECIAL\n#+END_SPECIAL"
(eq nil (org-element-contents (org-element-at-point))))))
;;;; Src Block
@ -2943,7 +2947,11 @@ Outside list"
"Test special block interpreter."
(should (equal (org-test-parse-and-interpret
"#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL")
"#+begin_SPECIAL\nTest\n#+end_SPECIAL\n")))
"#+begin_SPECIAL\nTest\n#+end_SPECIAL\n"))
;; No content
(should (equal (org-test-parse-and-interpret
"#+BEGIN_SPECIAL\n#+END_SPECIAL")
"#+begin_SPECIAL\n#+end_SPECIAL\n")))
(ert-deftest test-org-element/babel-call-interpreter ()
"Test Babel call interpreter."