forked from mirrors/org-mode
Merge branch 'maint'
This commit is contained in:
commit
5e3c3f93bf
|
@ -1436,11 +1436,12 @@ containing `:type', `:begin', `:end', `:hiddenp',
|
||||||
|
|
||||||
Assume point is at the beginning of the block."
|
Assume point is at the beginning of the block."
|
||||||
(let* ((case-fold-search t)
|
(let* ((case-fold-search t)
|
||||||
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(S-+\\)")
|
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
|
||||||
(upcase (match-string-no-properties 1)))))
|
(upcase (match-string-no-properties 1)))))
|
||||||
(if (not (save-excursion
|
(if (not (save-excursion
|
||||||
(re-search-forward
|
(re-search-forward
|
||||||
(format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t)))
|
(format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type))
|
||||||
|
limit t)))
|
||||||
;; Incomplete block: parse it as a paragraph.
|
;; Incomplete block: parse it as a paragraph.
|
||||||
(org-element-paragraph-parser limit affiliated)
|
(org-element-paragraph-parser limit affiliated)
|
||||||
(let ((block-end-line (match-beginning 0)))
|
(let ((block-end-line (match-beginning 0)))
|
||||||
|
|
|
@ -1648,25 +1648,33 @@ Outside list"
|
||||||
(ert-deftest test-org-element/special-block-parser ()
|
(ert-deftest test-org-element/special-block-parser ()
|
||||||
"Test `special-block' parser."
|
"Test `special-block' parser."
|
||||||
;; Standard test.
|
;; Standard test.
|
||||||
(let ((special-block
|
(should
|
||||||
|
(equal "SPECIAL"
|
||||||
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
|
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
|
||||||
(org-element-map
|
(org-element-property :type (org-element-at-point)))))
|
||||||
(org-element-parse-buffer) 'special-block 'identity nil t))))
|
;; Special blocks can contain paragraphs.
|
||||||
(should (equal (org-element-property :type special-block) "SPECIAL"))
|
(should
|
||||||
(should (org-element-map special-block 'paragraph 'identity)))
|
(eq 'paragraph
|
||||||
|
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
|
||||||
|
(forward-line)
|
||||||
|
(org-element-type (org-element-at-point)))))
|
||||||
;; Test folded block.
|
;; Test folded block.
|
||||||
|
(should
|
||||||
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
|
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
|
||||||
(org-cycle)
|
(org-cycle)
|
||||||
(should
|
(org-element-property :hiddenp (org-element-at-point))))
|
||||||
(org-element-property
|
|
||||||
:hiddenp
|
|
||||||
(org-element-map
|
|
||||||
(org-element-parse-buffer) 'special-block 'identity nil t))))
|
|
||||||
;; Ignore incomplete block.
|
;; Ignore incomplete block.
|
||||||
(should-not
|
(should-not
|
||||||
|
(eq 'special-block
|
||||||
(org-test-with-temp-text "#+BEGIN_SPECIAL"
|
(org-test-with-temp-text "#+BEGIN_SPECIAL"
|
||||||
(org-element-map
|
(org-element-type (org-element-at-point)))))
|
||||||
(org-element-parse-buffer) 'special-block 'identity nil t))))
|
;; Allow special characters in type.
|
||||||
|
(should
|
||||||
|
(equal '(special-block "SPECIAL*")
|
||||||
|
(org-test-with-temp-text "#+BEGIN_SPECIAL*\nContents\n#+END_SPECIAL*"
|
||||||
|
(let ((element (org-element-at-point)))
|
||||||
|
(list (org-element-type element)
|
||||||
|
(org-element-property :type element)))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Src Block
|
;;;; Src Block
|
||||||
|
|
Loading…
Reference in New Issue