Parsing and exporting special blocks preserve case

* lisp/org-element.el (org-element-special-block-parser):
* lisp/ox-latex.el (org-latex-special-block):
* lisp/ox-html.el (org-html-special-block):
* lisp/ox-man.el (org-man-special-block):
* lisp/ox-odt.el (org-odt-special-block):
* lisp/ox-texinfo.el (org-texinfo-special-block):
* contrib/lisp/ox-groff.el (org-groff-special-block): Preserve case.

* testing/lisp/test-org-element.el (test-org-element/special-block-parser):
  Add test.
This commit is contained in:
Nicolas Goaziou 2014-09-17 19:38:06 +02:00
parent b2fca73e30
commit 3432681fbe
8 changed files with 13 additions and 8 deletions

View File

@ -1478,7 +1478,7 @@ holding contextual information."
"Transcode a SPECIAL-BLOCK element from Org to Groff.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (downcase (org-element-property :type special-block))))
(let ((type (org-element-property :type special-block)))
(org-groff--wrap-label
special-block
(format "%s\n" contents))))

View File

@ -1526,7 +1526,7 @@ containing `:type', `:begin', `:end', `:contents-begin',
Assume point is at the beginning of the block."
(let* ((case-fold-search t)
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
(upcase (match-string-no-properties 1)))))
(match-string-no-properties 1))))
(if (not (save-excursion
(re-search-forward
(format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type))

View File

@ -3099,8 +3099,7 @@ contextual information."
"Transcode a SPECIAL-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let* ((block-type (downcase
(org-element-property :type special-block)))
(let* ((block-type (org-element-property :type special-block))
(contents (or contents ""))
(html5-fancy (and (org-html-html5-p info)
(plist-get info :html-html5-fancy)

View File

@ -2242,7 +2242,7 @@ holding contextual information."
"Transcode a SPECIAL-BLOCK element from Org to LaTeX.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (downcase (org-element-property :type special-block)))
(let ((type (org-element-property :type special-block))
(opt (org-export-read-attribute :attr_latex special-block :options)))
(concat (format "\\begin{%s}%s\n" type (or opt ""))
;; Insert any label or caption within the block

View File

@ -775,7 +775,7 @@ holding contextual information."
"Transcode a SPECIAL-BLOCK element from Org to Man.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (downcase (org-element-property :type special-block))))
(let ((type (org-element-property :type special-block)))
(org-man--wrap-label
special-block
(format "%s\n" contents))))

View File

@ -3059,7 +3059,7 @@ contextual information."
"Transcode a SPECIAL-BLOCK element from Org to ODT.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (downcase (org-element-property :type special-block)))
(let ((type (org-element-property :type special-block))
(attributes (org-export-read-attribute :attr_odt special-block)))
(cond
;; Annotation.

View File

@ -1235,7 +1235,8 @@ holding contextual information."
"Transcode a SPECIAL-BLOCK element from Org to Texinfo.
CONTENTS holds the contents of the block. INFO is a plist used
as a communication channel."
contents)
(let ((type (org-element-property :type)))
(format "@%s\n%s@end %s" type contents type)))
;;;; Src Block

View File

@ -1860,6 +1860,11 @@ Outside list"
(equal "SPECIAL"
(org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
(org-element-property :type (org-element-at-point)))))
;; Special blocks are case sensitive.
(should
(equal "CaSe"
(org-test-with-temp-text "#+BEGIN_CaSe\nText\n#+END_CaSe"
(org-element-property :type (org-element-at-point)))))
;; Special blocks can contain paragraphs.
(should
(eq 'paragraph