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
|
||||||
(org-format-latex
|
(or (and (member latex-frag-opt '(mathjax t))
|
||||||
(concat "ltxpng/" (file-name-sans-extension
|
(prog1 org-lparse-latex-fragment-fallback
|
||||||
(file-name-nondirectory
|
(org-lparse-warn
|
||||||
org-current-export-file)))
|
(concat
|
||||||
org-current-export-dir nil "Creating LaTeX image %s"
|
"Use of MathJax is incompatible with ODT exporter. "
|
||||||
nil nil
|
(format "Using %S instead."
|
||||||
(cond
|
org-lparse-latex-fragment-fallback)))))
|
||||||
((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
|
latex-frag-opt)))
|
||||||
|
(when (and org-current-export-file latex-frag-opt-1)
|
||||||
;; Investigate MathToWeb for converting TeX equations to MathML
|
;; Investigate MathToWeb for converting TeX equations to MathML
|
||||||
;; See http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html
|
;; http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html
|
||||||
((or (eq (plist-get parameters :LaTeX-fragments) 'mathjax )
|
(org-format-latex
|
||||||
(eq (plist-get parameters :LaTeX-fragments) t ))
|
(concat "ltxpng/" (file-name-sans-extension
|
||||||
(org-lparse-warn
|
(file-name-nondirectory
|
||||||
(concat
|
org-current-export-file)))
|
||||||
"Use of MathJax is incompatible with ODT exporter. "
|
org-current-export-dir nil "Creating LaTeX image %s"
|
||||||
(format "Using %S instead." org-lparse-latex-fragment-fallback)))
|
nil nil latex-frag-opt-1))))
|
||||||
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