Browse Source

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.
Nicolas Goaziou 10 years ago
parent
commit
3432681fbe

+ 1 - 1
contrib/lisp/ox-groff.el

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

+ 1 - 1
lisp/org-element.el

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

+ 1 - 2
lisp/ox-html.el

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

+ 1 - 1
lisp/ox-latex.el

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

+ 1 - 1
lisp/ox-man.el

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

+ 1 - 1
lisp/ox-odt.el

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

+ 2 - 1
lisp/ox-texinfo.el

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

+ 5 - 0
testing/lisp/test-org-element.el

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