mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
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:
parent
7f8e616f3b
commit
7d1e3dc38e
|
@ -1910,7 +1910,7 @@ Assume point is at the beginning of the block."
|
||||||
"Interpret SPECIAL-BLOCK element as Org syntax.
|
"Interpret SPECIAL-BLOCK element as Org syntax.
|
||||||
CONTENTS is the contents of the element."
|
CONTENTS is the contents of the element."
|
||||||
(let ((block-type (org-element-property :type special-block)))
|
(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)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2425,7 +2425,11 @@ Outside list"
|
||||||
;; Handle non-empty blank line at the end of buffer.
|
;; Handle non-empty blank line at the end of buffer.
|
||||||
(should
|
(should
|
||||||
(org-test-with-temp-text "#+BEGIN_SPECIAL\nC\n#+END_SPECIAL\n "
|
(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
|
;;;; Src Block
|
||||||
|
@ -2943,7 +2947,11 @@ Outside list"
|
||||||
"Test special block interpreter."
|
"Test special block interpreter."
|
||||||
(should (equal (org-test-parse-and-interpret
|
(should (equal (org-test-parse-and-interpret
|
||||||
"#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL")
|
"#+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 ()
|
(ert-deftest test-org-element/babel-call-interpreter ()
|
||||||
"Test Babel call interpreter."
|
"Test Babel call interpreter."
|
||||||
|
|
Loading…
Reference in a new issue