org-odt.el: Support for captioning and labelling of equation images
* contrib/lisp/org-lparse.el (org-do-lparse): let-bind org-lparse-opt-plist to current export options. * contrib/lisp/org-odt.el (org-odt-begin-office-body): Add a directive so that Equations can be sequentially numbered. (org-export-odt-preprocess): Removed call to org-export-odt-preprocess-latex-fragments. (org-export-odt-preprocess-latex-fragments): Fix signature and hook it to org-export-preprocess-after-blockquote-hook. Use org-lparse-opt-plist. (org-odt-unload-function): Leave no trace in org-export-preprocess-after-blockquote-hook. Thanks to Myles English for registering this requirement. http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg01116.html
This commit is contained in:
parent
09618ba25a
commit
3688deeb3f
|
@ -847,6 +847,7 @@ version."
|
||||||
(org-export-footnotes-seen nil)
|
(org-export-footnotes-seen nil)
|
||||||
(org-export-footnotes-data (org-footnote-all-labels 'with-defs))
|
(org-export-footnotes-data (org-footnote-all-labels 'with-defs))
|
||||||
(org-footnote-insert-pos-for-preprocessor 'point-min)
|
(org-footnote-insert-pos-for-preprocessor 'point-min)
|
||||||
|
(org-lparse-opt-plist opt-plist)
|
||||||
(lines
|
(lines
|
||||||
(org-split-string
|
(org-split-string
|
||||||
(org-export-preprocess-string
|
(org-export-preprocess-string
|
||||||
|
|
|
@ -143,8 +143,9 @@ OpenDocument xml files.")
|
||||||
(org-lparse-register-backend 'odt)
|
(org-lparse-register-backend 'odt)
|
||||||
|
|
||||||
(defun org-odt-unload-function ()
|
(defun org-odt-unload-function ()
|
||||||
;; notify org-lparse library on unload
|
|
||||||
(org-lparse-unregister-backend 'odt)
|
(org-lparse-unregister-backend 'odt)
|
||||||
|
(remove-hook 'org-export-preprocess-after-blockquote-hook
|
||||||
|
'org-export-odt-preprocess-latex-fragments)
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defcustom org-export-odt-automatic-styles-file nil
|
(defcustom org-export-odt-automatic-styles-file nil
|
||||||
|
@ -435,6 +436,7 @@ PUB-DIR is set, use this as the publishing directory."
|
||||||
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Table\"/>
|
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Table\"/>
|
||||||
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Text\"/>
|
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Text\"/>
|
||||||
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Drawing\"/>
|
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Drawing\"/>
|
||||||
|
<text:sequence-decl text:display-outline-level=\"0\" text:name=\"Equation\"/>
|
||||||
</text:sequence-decls>"))
|
</text:sequence-decls>"))
|
||||||
|
|
||||||
;; Following variable is let bound when `org-do-lparse' is in
|
;; Following variable is let bound when `org-do-lparse' is in
|
||||||
|
@ -1648,29 +1650,28 @@ visually."
|
||||||
(substring label (match-beginning 1))))))
|
(substring label (match-beginning 1))))))
|
||||||
|
|
||||||
(defvar org-lparse-latex-fragment-fallback) ; set by org-do-lparse
|
(defvar org-lparse-latex-fragment-fallback) ; set by org-do-lparse
|
||||||
(defun org-export-odt-preprocess-latex-fragments (parameters)
|
(defvar org-lparse-opt-plist) ; bound during org-do-lparse
|
||||||
|
(defun org-export-odt-preprocess-latex-fragments ()
|
||||||
"Convert LaTeX fragments to images."
|
"Convert LaTeX fragments to images."
|
||||||
(when (and org-current-export-file
|
(let* ((latex-frag-opt (plist-get org-lparse-opt-plist :LaTeX-fragments))
|
||||||
(plist-get parameters :LaTeX-fragments))
|
(latex-frag-opt-1 ; massage the options
|
||||||
|
(or (and (member latex-frag-opt '(mathjax t))
|
||||||
|
(prog1 org-lparse-latex-fragment-fallback
|
||||||
|
(org-lparse-warn
|
||||||
|
(concat
|
||||||
|
"Use of MathJax is incompatible with ODT exporter. "
|
||||||
|
(format "Using %S instead."
|
||||||
|
org-lparse-latex-fragment-fallback)))))
|
||||||
|
latex-frag-opt)))
|
||||||
|
(when (and org-current-export-file latex-frag-opt-1)
|
||||||
|
;; Investigate MathToWeb for converting TeX equations to MathML
|
||||||
|
;; http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html
|
||||||
(org-format-latex
|
(org-format-latex
|
||||||
(concat "ltxpng/" (file-name-sans-extension
|
(concat "ltxpng/" (file-name-sans-extension
|
||||||
(file-name-nondirectory
|
(file-name-nondirectory
|
||||||
org-current-export-file)))
|
org-current-export-file)))
|
||||||
org-current-export-dir nil "Creating LaTeX image %s"
|
org-current-export-dir nil "Creating LaTeX image %s"
|
||||||
nil nil
|
nil nil latex-frag-opt-1))))
|
||||||
(cond
|
|
||||||
((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
|
|
||||||
;; Investigate MathToWeb for converting TeX equations to MathML
|
|
||||||
;; See http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html
|
|
||||||
((or (eq (plist-get parameters :LaTeX-fragments) 'mathjax )
|
|
||||||
(eq (plist-get parameters :LaTeX-fragments) t ))
|
|
||||||
(org-lparse-warn
|
|
||||||
(concat
|
|
||||||
"Use of MathJax is incompatible with ODT exporter. "
|
|
||||||
(format "Using %S instead." org-lparse-latex-fragment-fallback)))
|
|
||||||
org-lparse-latex-fragment-fallback)
|
|
||||||
((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng)
|
|
||||||
(t nil)))))
|
|
||||||
|
|
||||||
(defun org-export-odt-preprocess-label-references ()
|
(defun org-export-odt-preprocess-label-references ()
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
@ -1688,8 +1689,17 @@ visually."
|
||||||
'("<text:sequence-ref text:reference-format=\"category-and-value\" text:ref-name=\"%s\">"
|
'("<text:sequence-ref text:reference-format=\"category-and-value\" text:ref-name=\"%s\">"
|
||||||
. "</text:sequence-ref>") pretty-label label)) t t)))))
|
. "</text:sequence-ref>") pretty-label label)) t t)))))
|
||||||
|
|
||||||
|
;; process latex fragments as part of
|
||||||
|
;; `org-export-preprocess-after-blockquote-hook'. Note that this hook
|
||||||
|
;; is the one that is closest and well before the call to
|
||||||
|
;; `org-export-attach-captions-and-attributes' in
|
||||||
|
;; `org-export-preprocess-stirng'. The above arrangement permits
|
||||||
|
;; captions, labels and attributes to be attached to png images
|
||||||
|
;; generated out of latex equations.
|
||||||
|
(add-hook 'org-export-preprocess-after-blockquote-hook
|
||||||
|
'org-export-odt-preprocess-latex-fragments)
|
||||||
|
|
||||||
(defun org-export-odt-preprocess (parameters)
|
(defun org-export-odt-preprocess (parameters)
|
||||||
(org-export-odt-preprocess-latex-fragments parameters)
|
|
||||||
(org-export-odt-preprocess-label-references))
|
(org-export-odt-preprocess-label-references))
|
||||||
|
|
||||||
(declare-function archive-zip-extract "arc-mode.el" (archive name))
|
(declare-function archive-zip-extract "arc-mode.el" (archive name))
|
||||||
|
|
Loading…
Reference in New Issue