diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-09-13 17:15:07 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-09-13 17:33:46 +0200 |
commit | a0e3e84edc611861fe1c42712a9450bbb8b9a340 (patch) | |
tree | aee3c98c9e77cef3791720ffde4bfa83a3287dfc | |
parent | 1e1a47682463dbd01b1fdae0daa2d8d3eaa1ffd6 (diff) | |
download | org-mode-a0e3e84edc611861fe1c42712a9450bbb8b9a340.tar.gz |
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
-rw-r--r-- | contrib/lisp/org-e-html.el | 243 | ||||
-rw-r--r-- | contrib/lisp/org-e-odt.el | 273 |
2 files changed, 179 insertions, 337 deletions
diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index 4ce7828..8dc045b 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -1202,43 +1202,6 @@ Replaces invalid characters with \"_\"." (date date) (t (format-time-string "%Y-%m-%d %T %Z"))))) -(defun org-e-html--caption/label-string (caption label info) - "Return caption and label HTML string for floats. - -CAPTION is a cons cell of secondary strings, the car being the -standard caption and the cdr its short form. LABEL is a string -representing the label. INFO is a plist holding contextual -information. - -If there's no caption nor label, return the empty string. - -For non-floats, see `org-e-html--wrap-label'." - (setq label nil) ;; FIXME - - (let ((label-str (if label (format "\\label{%s}" label) ""))) - (cond - ((and (not caption) (not label)) "") - ((not caption) (format "\\label{%s}\n" label)) - ;; Option caption format with short name. - ((cdr caption) - (format "\\caption[%s]{%s%s}\n" - (org-export-data (cdr caption) info) - label-str - (org-export-data (car caption) info))) - ;; Standard caption format. - ;; (t (format "\\caption{%s%s}\n" - ;; label-str - ;; (org-export-data (car caption) info))) - (t (org-export-data (car caption) info))))) - -(defun org-e-html--find-verb-separator (s) - "Return a character not used in string S. -This is used to choose a separator for constructs like \\verb." - (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}")) - (loop for c across ll - when (not (string-match (regexp-quote (char-to-string c)) s)) - return (char-to-string c)))) - (defun org-e-html--quotation-marks (text info) "Export quotation marks depending on language conventions. TEXT is a string containing quotation marks to be replaced. INFO @@ -1253,16 +1216,6 @@ is a plist used as a communication channel." (assoc "en" org-e-html-quotes)))) text) -(defun org-e-html--wrap-label (element output) - "Wrap label associated to ELEMENT around OUTPUT, if appropriate. -This function shouldn't be used for floats. See -`org-e-html--caption/label-string'." - ;; (let ((label (org-element-property :name element))) - ;; (if (or (not output) (not label) (string= output "") (string= label "")) - ;; output - ;; (concat (format "\\label{%s}\n" label) output))) - output) - ;;; Template @@ -1678,9 +1631,7 @@ contextual information." "Transcode a CENTER-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (org-e-html--wrap-label - center-block - (format "<div style=\"text-align: center\">\n%s</div>" contents))) + (format "<div style=\"text-align: center\">\n%s</div>" contents)) ;;;; Clock @@ -1726,14 +1677,13 @@ information." "Transcode a DRAWER element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (let* ((name (org-element-property :drawer-name drawer)) - (output (if (functionp org-e-html-format-drawer-function) - (funcall org-e-html-format-drawer-function - name contents) - ;; If there's no user defined function: simply - ;; display contents of the drawer. - contents))) - (org-e-html--wrap-label drawer output))) + (if (functionp org-e-html-format-drawer-function) + (funcall org-e-html-format-drawer-function + (org-element-property :drawer-name drawer) + contents) + ;; If there's no user defined function: simply + ;; display contents of the drawer. + contents)) ;;;; Dynamic Block @@ -1742,7 +1692,7 @@ holding contextual information." "Transcode a DYNAMIC-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information. See `org-export-data'." - (org-e-html--wrap-label dynamic-block contents)) + contents) ;;;; Entity @@ -1759,28 +1709,14 @@ contextual information." (defun org-e-html-example-block (example-block contents info) "Transcode a EXAMPLE-BLOCK element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (let* ((options (or (org-element-property :options example-block) "")) - (lang (org-element-property :language example-block)) - (caption (org-element-property :caption example-block)) - (label (org-element-property :name example-block)) - (caption-str (org-e-html--caption/label-string caption label info)) - (attr (mapconcat #'identity - (org-element-property :attr_html example-block) - " ")) - ;; (switches (org-element-property :switches example-block)) - (switches nil) ; FIXME - (textarea-p (and switches (string-match "-t\\>" switches))) - (code (org-e-html-format-code example-block info))) + (let ((attr (org-export-read-attribute :attr_html example-block)) + (code (org-e-html-format-code example-block info))) (cond - (textarea-p - (let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches)) - 80 (string-to-number (match-string 1 switches)))) - (rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches) - (string-to-number (match-string 1 switches)) - (org-count-lines code)))) - (format - "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>" - cols rows code))) + ((plist-get attr :textarea) + (let ((cols (or (plist-get attr :width) 80)) + (rows (or (plist-get attr :height) (org-count-lines code)))) + (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>" + cols rows code))) (t (format "<pre class=\"example\">\n%s</pre>" code))))) @@ -1807,12 +1743,10 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-e-html-fixed-width (fixed-width contents info) "Transcode a FIXED-WIDTH element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-html--wrap-label - fixed-width - (format "<pre class=\"example\">\n%s</pre>" - (org-e-html-do-format-code - (org-remove-indentation - (org-element-property :value fixed-width)))))) + (format "<pre class=\"example\">\n%s</pre>" + (org-e-html-do-format-code + (org-remove-indentation + (org-element-property :value fixed-width))))) ;;;; Footnote Definition @@ -1966,10 +1900,7 @@ holding contextual information." (defun org-e-html-horizontal-rule (horizontal-rule contents info) "Transcode an HORIZONTAL-RULE object from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (let ((attr (mapconcat #'identity - (org-element-property :attr_html horizontal-rule) - " "))) - (org-e-html--wrap-label horizontal-rule "<hr/>"))) + "<hr/>") ;;;; Inline Babel Call @@ -1984,8 +1915,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." CONTENTS holds the contents of the item. INFO is a plist holding contextual information." (let* ((org-lang (org-element-property :language inline-src-block)) - (code (org-element-property :value inline-src-block)) - (separator (org-e-html--find-verb-separator code))) + (code (org-element-property :value inline-src-block))) (error "FIXME"))) @@ -2006,18 +1936,15 @@ holding contextual information." (let ((format-function (function* (lambda (todo todo-type priority text tags - &key contents &allow-other-keys) + &key contents &allow-other-keys) (funcall org-e-html-format-inlinetask-function todo todo-type priority text tags contents))))) (org-e-html-format-headline--wrap inlinetask info format-function :contents contents))) ;; Otherwise, use a default template. - (t (org-e-html--wrap-label - inlinetask - (format - "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>" - (org-e-html-format-headline--wrap inlinetask info) - contents))))) + (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>" + (org-e-html-format-headline--wrap inlinetask info) + contents)))) ;;;; Italic @@ -2130,28 +2057,24 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-e-html-latex-environment (latex-environment contents info) "Transcode a LATEX-ENVIRONMENT element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-html--wrap-label - latex-environment - (let ((processing-type (plist-get info :LaTeX-fragments)) - (latex-frag (org-remove-indentation - (org-element-property :value latex-environment))) - (caption (org-e-html--caption/label-string - (org-element-property :caption latex-environment) - (org-element-property :name latex-environment) - info)) - (attr nil) ; FIXME - (label (org-element-property :name latex-environment))) - (cond - ((memq processing-type '(t mathjax)) - (org-e-html-format-latex latex-frag 'mathjax)) - ((eq processing-type 'dvipng) - (let* ((formula-link (org-e-html-format-latex - latex-frag processing-type))) - (when (and formula-link - (string-match "file:\\([^]]*\\)" formula-link)) - (org-e-html-format-inline-image - (match-string 1 formula-link) caption label attr t)))) - (t latex-frag))))) + (let ((processing-type (plist-get info :LaTeX-fragments)) + (latex-frag (org-remove-indentation + (org-element-property :value latex-environment))) + (caption (org-export-data + (org-export-get-caption latex-environment) info)) + (attr nil) ; FIXME + (label (org-element-property :name latex-environment))) + (cond + ((memq processing-type '(t mathjax)) + (org-e-html-format-latex latex-frag 'mathjax)) + ((eq processing-type 'dvipng) + (let* ((formula-link (org-e-html-format-latex + latex-frag processing-type))) + (when (and formula-link + (string-match "file:\\([^]]*\\)" formula-link)) + (org-e-html-format-inline-image + (match-string 1 formula-link) caption label attr t)))) + (t latex-frag)))) ;;;; Latex Fragment @@ -2195,10 +2118,7 @@ used as a communication channel." (expand-file-name raw-path)) (t raw-path))) (parent (org-export-get-parent-element link)) - (caption (org-e-html--caption/label-string - (org-element-property :caption parent) - (org-element-property :name parent) - info)) + (caption (org-export-data (org-export-get-caption parent) info)) (label (org-element-property :name parent)) ;; Retrieve latex attributes from the element around. (attr (let ((raw-attr @@ -2461,14 +2381,10 @@ the plist used as a communication channel." CONTENTS is the contents of the list. INFO is a plist holding contextual information." (let* (arg1 ;; FIXME - (type (org-element-property :type plain-list)) - (attr (mapconcat #'identity - (org-element-property :attr_html plain-list) - " "))) - (org-e-html--wrap-label - plain-list (format "%s\n%s%s" - (org-e-html-begin-plain-list type) - contents (org-e-html-end-plain-list type))))) + (type (org-element-property :type plain-list))) + (format "%s\n%s%s" + (org-e-html-begin-plain-list type) + contents (org-e-html-end-plain-list type)))) ;;;; Plain Text @@ -2555,8 +2471,7 @@ information." "Transcode a QUOTE-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (org-e-html--wrap-label - quote-block (format "<blockquote>\n%s</blockquote>" contents))) + (format "<blockquote>\n%s</blockquote>" contents)) ;;;; Quote Section @@ -2608,10 +2523,9 @@ 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 ((type (downcase (org-element-property :type special-block)))) - (org-e-html--wrap-label - special-block - (format "<div class=\"%s\">\n%s\n</div>" type contents)))) + (format "<div class=\"%s\">\n%s\n</div>" + (downcase (org-element-property :type special-block)) + contents)) ;;;; Src Block @@ -2620,34 +2534,25 @@ holding contextual information." "Transcode a SRC-BLOCK element from Org to HTML. CONTENTS holds the contents of the item. INFO is a plist holding contextual information." - (let* ((lang (org-element-property :language src-block)) - (caption (org-element-property :caption src-block)) - (label (org-element-property :name src-block)) - (caption-str (org-e-html--caption/label-string caption label info)) - (attr (mapconcat #'identity - (org-element-property :attr_html src-block) - " ")) - ;; (switches (org-element-property :switches src-block)) - (switches nil) ; FIXME - (textarea-p (and switches (string-match "-t\\>" switches))) - (code (org-e-html-format-code src-block info))) + (let ((lang (org-element-property :language src-block)) + (caption (org-export-get-caption src-block)) + (attr (org-export-read-attribute :attr_html src-block)) + (code (org-e-html-format-code src-block info))) (cond - (lang (format - "<div class=\"org-src-container\">\n%s%s\n</div>" - (if (not caption) "" - (format "<label class=\"org-src-name\">%s</label>" caption-str)) - (format "\n<pre class=\"src src-%s\">%s</pre>" lang code))) - (textarea-p - (let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches)) - 80 (string-to-number (match-string 1 switches)))) - (rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches) - (string-to-number (match-string 1 switches)) - (org-count-lines code)))) - (format - "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>" - cols rows code))) + (lang + (format "<div class=\"org-src-container\">\n%s%s\n</div>" + (if (not caption) "" + (format "<label class=\"org-src-name\">%s</label>" + (org-export-data caption info))) + (format "\n<pre class=\"src src-%s\">%s</pre>" lang code))) + ((plist-get attr :textarea) + (let ((cols (or (plist-get attr :width) 80)) + (rows (or (plist-get attr :height) (org-count-lines code)))) + (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>" + cols rows code))) (t (format "<pre class=\"example\">\n%s</pre>" code))))) + ;;;; Statistics Cookie (defun org-e-html-statistics-cookie (statistics-cookie contents info) @@ -2787,8 +2692,7 @@ contextual information." ;; Case 2: Standard table. (t (let* ((label (org-element-property :name table)) - (caption (org-e-html--caption/label-string - (org-element-property :caption table) label info)) + (caption (org-export-get-caption table)) (attributes (mapconcat #'identity (org-element-property :attr_html table) " ")) @@ -2826,7 +2730,9 @@ contextual information." (setq contents (substring contents 0 -1)) (format "<table%s>\n%s\n%s\n%s\n</table>" table-attributes - (if (not caption) "" (format "<caption>%s</caption>" caption)) + (if (not caption) "" + (format "<caption>%s</caption>" + (org-export-data caption info))) (funcall table-column-specs table info) contents))))) @@ -2893,8 +2799,7 @@ contextual information." (ws (let (out) (dotimes (i num-ws out) (setq out (concat out " ")))))) (setq contents (replace-match ws nil t contents)))) - (org-e-html--wrap-label - verse-block (format "<p class=\"verse\">\n%s</p>" contents))) + (format "<p class=\"verse\">\n%s</p>" contents)) diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index f0d800d..2fab446 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -1305,49 +1305,6 @@ new entry in `org-e-odt-automatic-styles'. Return (OBJECT-NAME (cons object-name style-name))) -;;;; Caption and Labels - - -(defun org-e-odt--wrap-label (element output) - "Wrap label associated to ELEMENT around OUTPUT, if appropriate. -This function shouldn't be used for floats. See -`org-e-odt--caption/label-string'." - ;; (let ((label (org-element-property :name element))) - ;; (if (or (not output) (not label) (string= output "") (string= label "")) - ;; output - ;; (concat (format "\\label{%s}\n" label) output))) - output) - - -(defun org-e-odt--caption/label-string (caption label info) - "Return caption and label HTML string for floats. - -CAPTION is a cons cell of secondary strings, the car being the -standard caption and the cdr its short form. LABEL is a string -representing the label. INFO is a plist holding contextual -information. - -If there's no caption nor label, return the empty string. - -For non-floats, see `org-e-odt--wrap-label'." - (setq label nil) ;; FIXME - - (let ((label-str (if label (format "\\label{%s}" label) ""))) - (cond - ((and (not caption) (not label)) "") - ((not caption) (format "\\label{%s}\n" label)) - ;; Option caption format with short name. - ((cdr caption) - (format "\\caption[%s]{%s%s}\n" - (org-export-data (cdr caption) info) - label-str - (org-export-data (car caption) info))) - ;; Standard caption format. - ;; (t (format "\\caption{%s%s}\n" - ;; label-str - ;; (org-export-data (car caption) info))) - (t (org-export-data (car caption) info))))) - ;;;; Checkbox (defun org-e-odt--checkbox (item) @@ -1360,6 +1317,7 @@ For non-floats, see `org-e-odt--wrap-label'." (off "[ ] ") (trans "[-] ")))))) + ;;; Template (defun org-e-odt-template (contents info) @@ -1609,7 +1567,7 @@ contextual information." "Transcode a CENTER-BLOCK element from Org to ODT. CONTENTS holds the contents of the center block. INFO is a plist holding contextual information." - (org-e-odt--wrap-label center-block contents)) + contents) ;;;; Clock @@ -1657,14 +1615,13 @@ channel." "Transcode a DRAWER element from Org to ODT. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (let* ((name (org-element-property :drawer-name drawer)) - (output (if (functionp org-e-odt-format-drawer-function) - (funcall org-e-odt-format-drawer-function - name contents) - ;; If there's no user defined function: simply - ;; display contents of the drawer. - contents))) - (org-e-odt--wrap-label drawer output))) + (if (functionp org-e-odt-format-drawer-function) + (funcall org-e-odt-format-drawer-function + (org-element-property :drawer-name drawer) + contents) + ;; If there's no user defined function: simply display contents of + ;; the drawer. + contents)) ;;;; Dynamic Block @@ -1673,7 +1630,7 @@ holding contextual information." "Transcode a DYNAMIC-BLOCK element from Org to ODT. CONTENTS holds the contents of the block. INFO is a plist holding contextual information. See `org-export-data'." - (org-e-odt--wrap-label dynamic-block contents)) + contents) ;;;; Entity @@ -1694,8 +1651,7 @@ contextual information." (defun org-e-odt-example-block (example-block contents info) "Transcode a EXAMPLE-BLOCK element from Org to ODT. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-odt--wrap-label - example-block (org-e-odt-format-code example-block info))) + (org-e-odt-format-code example-block info)) ;;;; Export Snippet @@ -1721,9 +1677,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-e-odt-fixed-width (fixed-width contents info) "Transcode a FIXED-WIDTH element from Org to ODT. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-odt--wrap-label - fixed-width (org-e-odt-do-format-code - (org-element-property :value fixed-width)))) + (org-e-odt-do-format-code (org-element-property :value fixed-width))) ;;;; Footnote Definition @@ -1918,10 +1872,8 @@ holding contextual information." (defun org-e-odt-horizontal-rule (horizontal-rule contents info) "Transcode an HORIZONTAL-RULE object from Org to ODT. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-odt--wrap-label - horizontal-rule - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "Horizontal_20_Line" ""))) + (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "Horizontal_20_Line" "")) ;;;; Inline Babel Call @@ -1968,18 +1920,16 @@ holding contextual information." (org-e-odt-format-headline--wrap inlinetask info format-function :contents contents))) ;; Otherwise, use a default template. - (t (org-e-odt--wrap-label - inlinetask - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "Text_20_body" - (org-e-odt--textbox - (concat - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "OrgInlineTaskHeading" - (org-e-odt-format-headline--wrap - inlinetask info)) - contents) - nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))))) + (t (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "Text_20_body" + (org-e-odt--textbox + (concat + (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "OrgInlineTaskHeading" + (org-e-odt-format-headline--wrap + inlinetask info)) + contents) + nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\""))))) ;;;; Italic @@ -2086,40 +2036,38 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-e-odt-latex-environment (latex-environment contents info) "Transcode a LATEX-ENVIRONMENT element from Org to ODT. CONTENTS is nil. INFO is a plist holding contextual information." - (org-e-odt--wrap-label - latex-environment - (let* ((latex-frag - (org-remove-indentation - (org-element-property :value latex-environment))) - (processing-type (plist-get info :LaTeX-fragments)) - (caption (org-element-property :caption latex-environment)) - (short-caption (and (cdr caption) - (org-export-data (cdr caption) info))) - (caption (and (car caption) (org-export-data (car caption) info))) - (label (org-element-property :name latex-environment)) - (attr nil) ; FIXME - (label (org-element-property :name latex-environment))) - - (when (memq processing-type '(t mathjax)) - (unless (and (fboundp 'org-format-latex-mathml-available-p) - (org-format-latex-mathml-available-p)) - (message "LaTeX to MathML converter not available. Trying dvinpng...") - (setq processing-type 'dvipng))) - - (when (eq processing-type 'dvipng) - (unless (and (org-check-external-command "latex" "" t) - (org-check-external-command "dvipng" "" t)) - (message "LaTeX to PNG converter not available. Using verbatim.") - (setq processing-type 'verbatim))) - - (case processing-type - ((t mathjax) - (org-e-odt-format-formula latex-environment info)) - (dvipng - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "Text_20_body" - (org-e-odt-link--inline-image latex-environment info))) - (t (org-e-odt-do-format-code latex-frag)))))) + (let* ((latex-frag + (org-remove-indentation + (org-element-property :value latex-environment))) + (processing-type (plist-get info :LaTeX-fragments)) + (caption (org-element-property :caption latex-environment)) + (short-caption (and (cdr caption) + (org-export-data (cdr caption) info))) + (caption (and (car caption) (org-export-data (car caption) info))) + (label (org-element-property :name latex-environment)) + (attr nil) ; FIXME + (label (org-element-property :name latex-environment))) + + (when (memq processing-type '(t mathjax)) + (unless (and (fboundp 'org-format-latex-mathml-available-p) + (org-format-latex-mathml-available-p)) + (message "LaTeX to MathML converter not available. Trying dvinpng...") + (setq processing-type 'dvipng))) + + (when (eq processing-type 'dvipng) + (unless (and (org-check-external-command "latex" "" t) + (org-check-external-command "dvipng" "" t)) + (message "LaTeX to PNG converter not available. Using verbatim.") + (setq processing-type 'verbatim))) + + (case processing-type + ((t mathjax) + (org-e-odt-format-formula latex-environment info)) + (dvipng + (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "Text_20_body" + (org-e-odt-link--inline-image latex-environment info))) + (t (org-e-odt-do-format-code latex-frag))))) ;;;; Latex Fragment @@ -2209,9 +2157,9 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;; get label and caption. (label (org-element-property :name caption-from)) (caption (org-element-property :caption caption-from)) - (short-caption (cdr caption)) + (short-caption (org-export-get-caption caption-from t)) ;; transcode captions. - (caption (and (car caption) (org-export-data (car caption) info))) + (caption (and caption (org-export-data (car caption) info))) (short-caption (and short-caption (org-export-data short-caption info)))) (when (or label caption) @@ -2648,22 +2596,20 @@ the plist used as a communication channel." "Transcode a PLAIN-LIST element from Org to ODT. CONTENTS is the contents of the list. INFO is a plist holding contextual information." - (org-e-odt--wrap-label - plain-list - (format "\n<text:list text:style-name=\"%s\" %s>\n%s</text:list>" - ;; Choose style based on list type. - (case (org-element-property :type plain-list) - (ordered "OrgNumberedList") - (unordered "OrgBulletedList") - (descriptive-1 "OrgDescriptionList") - (descriptive-2 "OrgDescriptionList")) - ;; If top-level list, re-start numbering. Otherwise, - ;; continue numbering. - (format "text:continue-numbering=\"%s\"" - (let* ((parent (org-export-get-parent plain-list))) - (if (and parent (eq (org-element-type parent) 'item)) - "true" "false"))) - contents))) + (format "\n<text:list text:style-name=\"%s\" %s>\n%s</text:list>" + ;; Choose style based on list type. + (case (org-element-property :type plain-list) + (ordered "OrgNumberedList") + (unordered "OrgBulletedList") + (descriptive-1 "OrgDescriptionList") + (descriptive-2 "OrgDescriptionList")) + ;; If top-level list, re-start numbering. Otherwise, + ;; continue numbering. + (format "text:continue-numbering=\"%s\"" + (let* ((parent (org-export-get-parent plain-list))) + (if (and parent (eq (org-element-type parent) 'item)) + "true" "false"))) + contents)) ;;;; Plain Text @@ -2773,7 +2719,7 @@ information." "Transcode a QUOTE-BLOCK element from Org to ODT. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (org-e-odt--wrap-label quote-block contents)) + contents) ;;;; Quote Section @@ -2821,38 +2767,36 @@ 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))) - (org-e-odt--wrap-label - 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) - (plist-get info :date)))) - - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "Text_20_body" - (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-e-odt--date 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-e-odt--textbox contents width height - style extra anchor)))) - (t contents))))) + (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) + (plist-get info :date)))) + + (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "Text_20_body" + (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-e-odt--date 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-e-odt--textbox contents width height + style extra anchor)))) + (t contents)))) ;;;; Src Block @@ -2985,11 +2929,6 @@ contextual information." (caption (and (car caption) (org-export-data (car caption) info))) (label (org-element-property :name src-block)) (attributes (org-export-read-attribute :attr_odt src-block))) - ;; FIXME: Handle caption - ;; caption-str (when caption) - ;; (main (org-export-data (car caption) info)) - ;; (secondary (org-export-data (cdr caption) info)) - ;; (caption-str (org-e-odt--caption/label-string caption label info)) (let* ((captions (org-e-odt-format-label src-block info 'definition)) (caption (car captions)) (short-caption (cdr captions))) (concat @@ -3493,10 +3432,8 @@ contextual information." ;; Replace tabs and spaces. (setq contents (org-e-odt-fill-tabs-and-spaces contents)) ;; Surround it in a verse environment. - (org-e-odt--wrap-label - verse-block - (format "\n<text:p text:style-name=\"%s\">%s</text:p>" - "OrgVerse" contents))) + (format "\n<text:p text:style-name=\"%s\">%s</text:p>" + "OrgVerse" contents)) |