Browse Source

Merge export and special blocks within back-ends

* lisp/ox-ascii.el (org-ascii-export-block): Remove function.
(org-ascii-special-block): Handle raw special blocks.

* lisp/ox-beamer.el (org-beamer-export-block): Remove function.

* lisp/ox-html.el (org-html-export-block): Remove function.
(org-html-special-block): Handle raw special blocks.

* lisp/ox-latex.el (org-latex-export-block): Remove function.
(org-latex-special-block): Handle raw special blocks.

* lisp/ox-man.el (org-man-export-block): Remove function.
(org-man-special-block): Handle raw special blocks.

* lisp/ox-md.el (org-md-export-block): Remove function.

* lisp/ox-odt.el (org-odt-export-block): Remove function.
(org-odt-special-block): Handle raw special blocks.

* lisp/ox-texinfo.el (org-texinfo-export-block): Remove function.
(org-texinfo-special-block): Handle raw special blocks.

* contrib/lisp/ox-groff.el (org-groff-export-block): Remove function.
(org-groff-special-block): Handle raw special blocks.

* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-block):
  Remove function.
Nicolas Goaziou 10 years ago
parent
commit
fbc7097ffa
10 changed files with 82 additions and 169 deletions
  1. 4 13
      contrib/lisp/ox-groff.el
  2. 0 9
      contrib/lisp/ox-koma-letter.el
  3. 7 15
      lisp/ox-ascii.el
  4. 0 11
      lisp/ox-beamer.el
  5. 19 28
      lisp/ox-html.el
  6. 11 19
      lisp/ox-latex.el
  7. 4 14
      lisp/ox-man.el
  8. 1 10
      lisp/ox-md.el
  9. 33 40
      lisp/ox-odt.el
  10. 3 10
      lisp/ox-texinfo.el

+ 4 - 13
contrib/lisp/ox-groff.el

@@ -56,7 +56,6 @@
     (dynamic-block . org-groff-dynamic-block)
     (entity . org-groff-entity)
     (example-block . org-groff-example-block)
-    (export-block . org-groff-export-block)
     (export-snippet . org-groff-export-snippet)
     (fixed-width . org-groff-fixed-width)
     (footnote-definition . org-groff-footnote-definition)
@@ -883,14 +882,6 @@ information."
    (format ".DS L\n%s\n.DE"
            (org-export-format-code-default example-block info))))
 
-;;; Export Block
-
-(defun org-groff-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to Groff.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "GROFF")
-    (org-remove-indentation (org-element-property :value export-block))))
-
 ;;; Export Snippet
 
 (defun org-groff-export-snippet (export-snippet contents info)
@@ -1478,10 +1469,10 @@ 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))))
-    (org-groff--wrap-label
-     special-block
-     (format "%s\n" contents))))
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    (let ((type (downcase (org-element-property :type special-block))))
+      (org-groff--wrap-label special-block (format "%s\n" contents)))))
 
 ;;; Src Block
 

+ 0 - 9
contrib/lisp/ox-koma-letter.el

@@ -518,15 +518,6 @@ are present return the preferred one as determined by
 
 ;;; Transcode Functions
 
-;;;; Export Block
-
-(defun org-koma-letter-export-block (export-block contents info)
-  "Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code.
-CONTENTS is nil.  INFO is a plist used as a communication
-channel."
-  (when (member (org-element-property :type export-block) '("KOMA-LETTER" "LATEX"))
-    (org-remove-indentation (org-element-property :value export-block))))
-
 ;;;; Export Snippet
 
 (defun org-koma-letter-export-snippet (export-snippet contents info)

+ 7 - 15
lisp/ox-ascii.el

@@ -55,7 +55,6 @@
     (dynamic-block . org-ascii-dynamic-block)
     (entity . org-ascii-entity)
     (example-block . org-ascii-example-block)
-    (export-block . org-ascii-export-block)
     (export-snippet . org-ascii-export-snippet)
     (fixed-width . org-ascii-fixed-width)
     (footnote-reference . org-ascii-footnote-reference)
@@ -1198,16 +1197,6 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (org-element-property :value export-snippet)))
 
 
-;;;; Export Block
-
-(defun org-ascii-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to ASCII.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "ASCII")
-    (org-ascii--justify-element
-     (org-element-property :value export-block) export-block info)))
-
-
 ;;;; Fixed Width
 
 (defun org-ascii-fixed-width (fixed-width contents info)
@@ -1665,10 +1654,13 @@ contextual information."
   "Transcode a SPECIAL-BLOCK element from Org to ASCII.
 CONTENTS holds the contents of the block.  INFO is a plist
 holding contextual information."
-  ;; "JUSTIFYLEFT" and "JUSTFYRIGHT" have already been taken care of
-  ;; at a lower level.  There is no other special block type to
-  ;; handle.
-  contents)
+  (if (org-export-raw-special-block-p special-block info)
+      (org-ascii--justify-element
+       (org-element-property :raw-value special-block) special-block info)
+    ;; "JUSTIFYLEFT" and "JUSTFYRIGHT" have already been taken care of
+    ;; at a lower level.  There is no other special block type to
+    ;; handle.
+    contents))
 
 
 ;;;; Src Block

+ 0 - 11
lisp/ox-beamer.el

@@ -245,7 +245,6 @@ Return overlay specification, as a string, or nil."
     (:beamer-outline-frame-options nil nil org-beamer-outline-frame-options)
     (:beamer-outline-frame-title nil nil org-beamer-outline-frame-title))
   :translate-alist '((bold . org-beamer-bold)
-		     (export-block . org-beamer-export-block)
 		     (export-snippet . org-beamer-export-snippet)
 		     (headline . org-beamer-headline)
 		     (item . org-beamer-item)
@@ -271,16 +270,6 @@ a communication channel."
 	  contents))
 
 
-;;;; Export Block
-
-(defun org-beamer-export-block (export-block contents info)
-  "Transcode an EXPORT-BLOCK element into Beamer code.
-CONTENTS is nil.  INFO is a plist used as a communication
-channel."
-  (when (member (org-element-property :type export-block) '("BEAMER" "LATEX"))
-    (org-remove-indentation (org-element-property :value export-block))))
-
-
 ;;;; Export Snippet
 
 (defun org-beamer-export-snippet (export-snippet contents info)

+ 19 - 28
lisp/ox-html.el

@@ -55,7 +55,6 @@
     (dynamic-block . org-html-dynamic-block)
     (entity . org-html-entity)
     (example-block . org-html-example-block)
-    (export-block . org-html-export-block)
     (export-snippet . org-html-export-snippet)
     (fixed-width . org-html-fixed-width)
     (footnote-definition . org-html-footnote-definition)
@@ -2298,14 +2297,6 @@ information."
   (when (eq (org-export-snippet-backend export-snippet) 'html)
     (org-element-property :value export-snippet)))
 
-;;;; Export Block
-
-(defun org-html-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to HTML.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "HTML")
-    (org-remove-indentation (org-element-property :value export-block))))
-
 ;;;; Fixed Width
 
 (defun org-html-fixed-width (fixed-width contents info)
@@ -3154,25 +3145,25 @@ 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)))
-	 (contents (or contents ""))
-	 (html5-fancy (and (org-html-html5-p info)
-			   (plist-get info :html-html5-fancy)
-			   (member block-type org-html-html5-elements)))
-	 (attributes (org-export-read-attribute :attr_html special-block)))
-    (unless html5-fancy
-      (let ((class (plist-get attributes :class)))
-	(setq attributes (plist-put attributes :class
-				    (if class (concat class " " block-type)
-				      block-type)))))
-    (setq attributes (org-html--make-attribute-string attributes))
-    (when (not (equal attributes ""))
-      (setq attributes (concat " " attributes)))
-    (if html5-fancy
-	(format "<%s%s>\n%s</%s>" block-type attributes
-		contents block-type)
-      (format "<div%s>\n%s\n</div>" attributes contents))))
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    (let* ((block-type (downcase (org-element-property :type special-block)))
+	   (contents (or contents ""))
+	   (html5-fancy (and (org-html-html5-p info)
+			     (plist-get info :html-html5-fancy)
+			     (member block-type org-html-html5-elements)))
+	   (attributes (org-export-read-attribute :attr_html special-block)))
+      (unless html5-fancy
+	(let ((class (plist-get attributes :class)))
+	  (setq attributes (plist-put attributes :class
+				      (if class (concat class " " block-type)
+					block-type)))))
+      (setq attributes (org-html--make-attribute-string attributes))
+      (when (not (equal attributes ""))
+	(setq attributes (concat " " attributes)))
+      (if html5-fancy
+	  (format "<%s%s>\n%s</%s>" block-type attributes contents block-type)
+	(format "<div%s>\n%s\n</div>" attributes contents)))))
 
 ;;;; Src Block
 

+ 11 - 19
lisp/ox-latex.el

@@ -49,7 +49,6 @@
     (dynamic-block . org-latex-dynamic-block)
     (entity . org-latex-entity)
     (example-block . org-latex-example-block)
-    (export-block . org-latex-export-block)
     (export-snippet . org-latex-export-snippet)
     (fixed-width . org-latex-fixed-width)
     (footnote-definition . org-latex-footnote-definition)
@@ -1378,15 +1377,6 @@ information."
 	     (org-export-format-code-default example-block info)))))
 
 
-;;;; Export Block
-
-(defun org-latex-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to LaTeX.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (member (org-element-property :type export-block) '("LATEX" "TEX"))
-    (org-remove-indentation (org-element-property :value export-block))))
-
-
 ;;;; Export Snippet
 
 (defun org-latex-export-snippet (export-snippet contents info)
@@ -2264,15 +2254,17 @@ 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)))
-	(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
-	    ;; (otherwise, a reference pointing to that element will
-	    ;; count the section instead).
-	    (org-latex--caption/label-string special-block info)
-	    contents
-	    (format "\\end{%s}" type))))
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    (let ((type (downcase (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
+	      ;; (otherwise, a reference pointing to that element will
+	      ;; count the section instead).
+	      (org-latex--caption/label-string special-block info)
+	      contents
+	      (format "\\end{%s}" type)))))
 
 
 ;;;; Src Block

+ 4 - 14
lisp/ox-man.el

@@ -61,7 +61,6 @@
     (dynamic-block . org-man-dynamic-block)
     (entity . org-man-entity)
     (example-block . org-man-example-block)
-    (export-block . org-man-export-block)
     (export-snippet . org-man-export-snippet)
     (fixed-width . org-man-fixed-width)
     (footnote-definition . org-man-footnote-definition)
@@ -435,15 +434,6 @@ information."
            (org-export-format-code-default example-block info))))
 
 
-;;; Export Block
-
-(defun org-man-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to Man.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "MAN")
-    (org-remove-indentation (org-element-property :value export-block))))
-
-
 ;;; Export Snippet
 
 (defun org-man-export-snippet (export-snippet contents info)
@@ -777,10 +767,10 @@ 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))))
-    (org-man--wrap-label
-     special-block
-     (format "%s\n" contents))))
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    (let ((type (downcase (org-element-property :type special-block))))
+      (org-man--wrap-label special-block (format "%s\n" contents)))))
 
 
 ;;; Src Block

+ 1 - 10
lisp/ox-md.el

@@ -71,7 +71,6 @@ This variable can be set to either `atx' or `setext'."
 		     (comment . (lambda (&rest args) ""))
 		     (comment-block . (lambda (&rest args) ""))
 		     (example-block . org-md-example-block)
-		     (export-block . org-md-export-block)
 		     (fixed-width . org-md-example-block)
 		     (footnote-definition . ignore)
 		     (footnote-reference . ignore)
@@ -151,7 +150,7 @@ channel."
 	    value)))
 
 
-;;;; Example Block, Src Block and export Block
+;;;; Example Block and Src Block
 
 (defun org-md-example-block (example-block contents info)
   "Transcode EXAMPLE-BLOCK element into Markdown format.
@@ -162,14 +161,6 @@ channel."
    (org-remove-indentation
     (org-export-format-code-default example-block info))))
 
-(defun org-md-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to Markdown.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (if (member (org-element-property :type export-block) '("MARKDOWN" "MD"))
-      (org-remove-indentation (org-element-property :value export-block))
-    ;; Also include HTML export blocks.
-    (org-export-with-backend 'html export-block contents info)))
-
 
 ;;;; Headline
 

+ 33 - 40
lisp/ox-odt.el

@@ -43,7 +43,6 @@
     (dynamic-block . org-odt-dynamic-block)
     (entity . org-odt-entity)
     (example-block . org-odt-example-block)
-    (export-block . org-odt-export-block)
     (export-snippet . org-odt-export-snippet)
     (fixed-width . org-odt-fixed-width)
     (footnote-definition . org-odt-footnote-definition)
@@ -1684,15 +1683,6 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
     (org-element-property :value export-snippet)))
 
 
-;;;; Export Block
-
-(defun org-odt-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to ODT.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "ODT")
-    (org-remove-indentation (org-element-property :value export-block))))
-
-
 ;;;; Fixed Width
 
 (defun org-odt-fixed-width (fixed-width contents info)
@@ -3060,37 +3050,40 @@ 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)))
-	(attributes (org-export-read-attribute :attr_odt special-block)))
-    (cond
-     ;; Annotation.
-     ((string= type "annotation")
-      (let* ((author (or (plist-get attributes :author)
-			 (let ((author (plist-get info :author)))
-			   (and author (org-export-data author info)))))
-	     (date (or (plist-get attributes :date)
-		       ;; FIXME: Is `car' right thing to do below?
-		       (car (plist-get info :date)))))
-	(format "\n<text:p>%s</text:p>"
-		(format "<office:annotation>\n%s\n</office:annotation>"
-			(concat
-			 (and author
-			      (format "<dc:creator>%s</dc:creator>" author))
-			 (and date
-			      (format "<dc:date>%s</dc:date>"
-				      (org-odt--format-timestamp date nil 'iso-date)))
-			 contents)))))
-     ;; Textbox.
-     ((string= type "textbox")
-      (let ((width (plist-get attributes :width))
-	    (height (plist-get attributes :height))
-	    (style (plist-get attributes :style))
-	    (extra (plist-get attributes :extra))
-	    (anchor (plist-get attributes :anchor)))
-	(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
-		"Text_20_body" (org-odt--textbox contents width height
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    (let ((type (downcase (org-element-property :type special-block)))
+	  (attributes (org-export-read-attribute :attr_odt special-block)))
+      (cond
+       ;; Annotation.
+       ((string= type "annotation")
+	(let* ((author (or (plist-get attributes :author)
+			   (let ((author (plist-get info :author)))
+			     (and author (org-export-data author info)))))
+	       (date (or (plist-get attributes :date)
+			 ;; FIXME: Is `car' right thing to do below?
+			 (car (plist-get info :date)))))
+	  (format "\n<text:p>%s</text:p>"
+		  (format "<office:annotation>\n%s\n</office:annotation>"
+			  (concat
+			   (and author
+				(format "<dc:creator>%s</dc:creator>" author))
+			   (and date
+				(format "<dc:date>%s</dc:date>"
+					(org-odt--format-timestamp
+					 date nil 'iso-date)))
+			   contents)))))
+       ;; Textbox.
+       ((string= type "textbox")
+	(let ((width (plist-get attributes :width))
+	      (height (plist-get attributes :height))
+	      (style (plist-get attributes :style))
+	      (extra (plist-get attributes :extra))
+	      (anchor (plist-get attributes :anchor)))
+	  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+		  "Text_20_body" (org-odt--textbox contents width height
 						   style extra anchor))))
-     (t contents))))
+       (t contents)))))
 
 
 ;;;; Src Block

+ 3 - 10
lisp/ox-texinfo.el

@@ -76,7 +76,6 @@
     (dynamic-block . org-texinfo-dynamic-block)
     (entity . org-texinfo-entity)
     (example-block . org-texinfo-example-block)
-    (export-block . org-texinfo-export-block)
     (export-snippet . org-texinfo-export-snippet)
     (fixed-width . org-texinfo-fixed-width)
     (footnote-definition . org-texinfo-footnote-definition)
@@ -930,14 +929,6 @@ information."
   (format "@verbatim\n%s@end verbatim"
 	  (org-export-format-code-default example-block info)))
 
-;;; Export Block
-
-(defun org-texinfo-export-block (export-block contents info)
-  "Transcode a EXPORT-BLOCK element from Org to Texinfo.
-CONTENTS is nil.  INFO is a plist holding contextual information."
-  (when (string= (org-element-property :type export-block) "TEXINFO")
-    (org-remove-indentation (org-element-property :value export-block))))
-
 ;;; Export Snippet
 
 (defun org-texinfo-export-snippet (export-snippet contents info)
@@ -1477,7 +1468,9 @@ 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)
+  (if (org-export-raw-special-block-p special-block info)
+      (org-remove-indentation (org-element-property :raw-value special-block))
+    contents))
 
 ;;; Src Block