ox-mathml: Refactor mathml export

* lisp/ox-mathml.el: Introduce a new library for managing mathml conversion.

* lisp/org-latex-preview.el (org-create-math-formula,
org-format-latex-mathml-available-p, org-latex-to-mathml-jar-file): Move
the various mathml functions into ox-mathml.

* lisp/org-compat.el: Add compat entries for the various mathml
conversion functions that have now been brought under ox-mathml.

* lisp/ox-odt.el (org-odt-export-as-odf,
org-odt--translate-latex-fragments): Use the new org-mathml functions.
This commit is contained in:
TEC 2023-03-01 00:34:07 +08:00
parent 0d28e6ef72
commit 7ce7e39650
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
4 changed files with 336 additions and 249 deletions

View File

@ -706,6 +706,43 @@ This constant, for example, makes the below code not err:
'org-latex-color 'org-latex-preview--attr-color "9.7") 'org-latex-color 'org-latex-preview--attr-color "9.7")
(define-obsolete-function-alias (define-obsolete-function-alias
'org-normalize-color 'org-latex-preview--normalize-color "9.7") 'org-normalize-color 'org-latex-preview--normalize-color "9.7")
;; MathML related functions from org-latex-preview.el
(define-obsolete-variable-alias
'org-latex-to-mathml-jar-file 'org-mathml-converter-jar-file "9.7")
(define-obsolete-variable-alias
'org-latex-to-mathml-convert-command 'org-mathml-convert-command "9.7")
(define-obsolete-function-alias
'org-format-latex-mathml-available-p 'org-mathml-converter-available-p "9.7")
(define-obsolete-function-alias
'org-create-math-formula 'org-mathml-convert-latex "9.7")
;; FIXME: Unused; obsoleted; to be removed.
(defun org-format-latex-as-mathml (latex-frag latex-frag-type
prefix &optional dir)
(let* ((absprefix (expand-file-name prefix dir))
(print-length nil) (print-level nil)
(formula-id (concat
"formula-"
(sha1
(prin1-to-string
(list latex-frag
org-latex-to-mathml-convert-command)))))
(formula-cache (format "%s-%s.mathml" absprefix formula-id))
(formula-cache-dir (file-name-directory formula-cache)))
(unless (file-directory-p formula-cache-dir)
(make-directory formula-cache-dir t))
(unless (file-exists-p formula-cache)
(org-mathml-convert-latex latex-frag formula-cache))
(if (file-exists-p formula-cache)
;; Successful conversion. Return the link to MathML file.
(org-add-props
(format "[[file:%s]]" (file-relative-name formula-cache dir))
(list 'org-latex-src (replace-regexp-in-string "\"" "" latex-frag)
'org-latex-src-embed-type (if latex-frag-type
'paragraph 'character)))
;; Failed conversion. Return the LaTeX fragment verbatim
latex-frag)))
(make-obsolete #'org-format-latex-as-mathml "to be removed" "9.7")
;; FIXME: Unused; obsoleted; to be removed. ;; FIXME: Unused; obsoleted; to be removed.
(defun org-dvipng-color (attr) (defun org-dvipng-color (attr)

View File

@ -71,43 +71,6 @@ This is a property list with the following properties:
:package-version '(Org . "9.7") :package-version '(Org . "9.7")
:type 'plist) :type 'plist)
(defcustom org-latex-to-mathml-jar-file nil
"Value of\"%j\" in `org-latex-to-mathml-convert-command'.
Use this to specify additional executable file say a jar file.
When using MathToWeb as the converter, specify the full-path to
your mathtoweb.jar file."
:group 'org-latex
:version "24.1"
:type '(choice
(const :tag "None" nil)
(file :tag "JAR file" :must-match t)))
(defcustom org-latex-to-mathml-convert-command nil
"Command to convert LaTeX fragments to MathML.
Replace format-specifiers in the command as noted below and use
`shell-command' to convert LaTeX to MathML.
%j: Executable file in fully expanded form as specified by
`org-latex-to-mathml-jar-file'.
%I: Input LaTeX file in fully expanded form.
%i: Shell-escaped LaTeX fragment to be converted.
It must not be used inside a quoted argument, the result of %i
expansion inside a quoted argument is undefined.
%o: Output MathML file.
This command is used by `org-create-math-formula'.
When using MathToWeb as the converter, set this option to
\"java -jar %j -unicode -force -df %o %I\".
When using LaTeXML set this option to
\"latexmlmath %i --presentationmathml=%o\"."
:group 'org-latex
:version "24.1"
:type '(choice
(const :tag "None" nil)
(string :tag "\nShell command")))
(defcustom org-latex-to-html-convert-command nil (defcustom org-latex-to-html-convert-command nil
"Shell command to convert LaTeX fragments to HTML. "Shell command to convert LaTeX fragments to HTML.
This command is very open-ended: the output of the command will This command is very open-ended: the output of the command will
@ -299,19 +262,6 @@ See `org-latex-preview-processing-indicator'."
(defconst org-latex-preview--precompile-log "*Org Preview Preamble Precompilation*" (defconst org-latex-preview--precompile-log "*Org Preview Preamble Precompilation*"
"Buffer name for Preview LaTeX output.") "Buffer name for Preview LaTeX output.")
(defun org-format-latex-mathml-available-p ()
"Return t if `org-latex-to-mathml-convert-command' is usable."
(save-match-data
(when (and (boundp 'org-latex-to-mathml-convert-command)
org-latex-to-mathml-convert-command)
(let ((executable (car (split-string
org-latex-to-mathml-convert-command))))
(when (executable-find executable)
(if (string-match
"%j" org-latex-to-mathml-convert-command)
(file-readable-p org-latex-to-mathml-jar-file)
t))))))
(defcustom org-latex-preview-preamble "\\documentclass{article} (defcustom org-latex-preview-preamble "\\documentclass{article}
\[DEFAULT-PACKAGES] \[DEFAULT-PACKAGES]
\[PACKAGES] \[PACKAGES]
@ -2269,97 +2219,6 @@ BLOCK-TYPE determines whether the result is placed inline or as a paragraph."
'org-latex-src-embed-type 'org-latex-src-embed-type
(if block-type 'paragraph 'character))))) (if block-type 'paragraph 'character)))))
(defun org-create-math-formula (latex-frag &optional mathml-file)
"Convert LATEX-FRAG to MathML and store it in MATHML-FILE.
Use `org-latex-to-mathml-convert-command'. If the conversion is
successful, return the portion between \"<math...> </math>\"
elements otherwise return nil. When MATHML-FILE is specified,
write the results in to that file. When invoked as an
interactive command, prompt for LATEX-FRAG, with initial value
set to the current active region and echo the results for user
inspection."
(interactive (list (let ((frag (when (org-region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end)))))
(read-string "LaTeX Fragment: " frag nil frag))))
(unless latex-frag (user-error "Invalid LaTeX fragment"))
(let* ((tmp-in-file
(let ((file (file-relative-name
(make-temp-name (expand-file-name "ltxmathml-in")))))
(write-region latex-frag nil file)
file))
(tmp-out-file (file-relative-name
(make-temp-name (expand-file-name "ltxmathml-out"))))
(cmd (format-spec
org-latex-to-mathml-convert-command
`((?j . ,(and org-latex-to-mathml-jar-file
(shell-quote-argument
(expand-file-name
org-latex-to-mathml-jar-file))))
(?I . ,(shell-quote-argument tmp-in-file))
(?i . ,latex-frag)
(?o . ,(shell-quote-argument tmp-out-file)))))
mathml shell-command-output)
(when (called-interactively-p 'any)
(unless (org-format-latex-mathml-available-p)
(user-error "LaTeX to MathML converter not configured")))
(message "Running %s" cmd)
(setq shell-command-output (shell-command-to-string cmd))
(setq mathml
(when (file-readable-p tmp-out-file)
(with-current-buffer (find-file-noselect tmp-out-file t)
(goto-char (point-min))
(when (re-search-forward
(format "<math[^>]*?%s[^>]*?>\\(.\\|\n\\)*</math>"
(regexp-quote
"xmlns=\"http://www.w3.org/1998/Math/MathML\""))
nil t)
(prog1 (match-string 0) (kill-buffer))))))
(cond
(mathml
(setq mathml
(concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" mathml))
(when mathml-file
(write-region mathml nil mathml-file))
(when (called-interactively-p 'any)
(message mathml)))
((warn "LaTeX to MathML conversion failed")
(message shell-command-output)))
(delete-file tmp-in-file)
(when (file-exists-p tmp-out-file)
(delete-file tmp-out-file))
mathml))
(defun org-format-latex-as-mathml (latex-frag latex-frag-type
prefix &optional dir)
"Use `org-create-math-formula' but check local cache first."
(let* ((absprefix (expand-file-name prefix dir))
(print-length nil) (print-level nil)
(formula-id (concat
"formula-"
(sha1
(prin1-to-string
(list latex-frag
org-latex-to-mathml-convert-command)))))
(formula-cache (format "%s-%s.mathml" absprefix formula-id))
(formula-cache-dir (file-name-directory formula-cache)))
(unless (file-directory-p formula-cache-dir)
(make-directory formula-cache-dir t))
(unless (file-exists-p formula-cache)
(org-create-math-formula latex-frag formula-cache))
(if (file-exists-p formula-cache)
;; Successful conversion. Return the link to MathML file.
(org-add-props
(format "[[file:%s]]" (file-relative-name formula-cache dir))
(list 'org-latex-src (replace-regexp-in-string "\"" "" latex-frag)
'org-latex-src-embed-type (if latex-frag-type
'paragraph 'character)))
;; Failed conversion. Return the LaTeX fragment verbatim
latex-frag)))
(defun org-format-latex-as-html (latex-fragment) (defun org-format-latex-as-html (latex-fragment)
"Convert LATEX-FRAGMENT to HTML. "Convert LATEX-FRAGMENT to HTML.
This uses `org-latex-to-html-convert-command', which see." This uses `org-latex-to-html-convert-command', which see."

157
lisp/ox-mathml.el Normal file
View File

@ -0,0 +1,157 @@
;;; ox-mathml.el --- Support for MathML exports -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2023 TEC
;;
;; Author: TEC <contact@tecosaur.net>
;; Maintainer: TEC <contact@tecosaur.net>
;; Created: February 27, 2023
;; Modified: February 27, 2023
;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/tecosaur/ox-mathml
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Support for MathML exports
;;
;;; Code:
(defgroup org-mathml nil
"Options for generation of MathML representations of LaTeX math."
:tag "Org MathML export"
:group 'org-export)
(defcustom org-mathml-converter-jar-file nil
"Value of\"%j\" in `org-mathml-convert-command'.
Use this to specify additional executable file say a jar file.
When using MathToWeb as the converter, specify the full-path to
your mathtoweb.jar file."
:group 'org-mathml
:version "24.1"
:type '(choice
(const :tag "None" nil)
(file :tag "JAR file" :must-match t)))
(defcustom org-mathml-convert-command nil
"Command to convert LaTeX fragments to MathML.
Replace format-specifiers in the command as noted below and use
`shell-command' to convert LaTeX to MathML.
%j: Executable file in fully expanded form as specified by
`org-latex-to-mathml-jar-file'.
%I: Input LaTeX file in fully expanded form.
%i: Shell-escaped LaTeX fragment to be converted.
It must not be used inside a quoted argument, the result of %i
expansion inside a quoted argument is undefined.
%o: Output MathML file.
This command is used by `org-mathml-convert-latex'.
When using MathToWeb as the converter, set this option to
\"java -jar %j -unicode -force -df %o %I\".
When using LaTeXML set this option to
\"latexmlmath %i --preload=amsmath.sty --preload=amssymb.sty --presentationmathml=%o\"."
:group 'org-mathml
:version "24.1"
:type '(choice
(const :tag "None" nil)
(string :tag "\nShell command")))
(defun org-mathml-converter-available-p ()
"Return t if `org-mathml-convert-command' is usable."
(save-match-data
(when (and (boundp 'org-mathml-convert-command)
org-mathml-convert-command)
(let ((executable (car (split-string
org-mathml-convert-command))))
(when (executable-find executable)
(if (string-match
"%j" org-mathml-convert-command)
(file-readable-p org-mathml-converter-jar-file)
t))))))
(defun org-mathml-convert-latex (latex-frag &optional mathml-file)
"Convert LATEX-FRAG to MathML and store it in MATHML-FILE.
Use `org-latex-to-mathml-convert-command'. If the conversion is
successful, return the portion between \"<math...> </math>\"
elements otherwise return nil. When MATHML-FILE is specified,
write the results in to that file. When invoked as an
interactive command, prompt for LATEX-FRAG, with initial value
set to the current active region and echo the results for user
inspection."
(interactive (list (let ((frag (when (org-region-active-p)
(buffer-substring-no-properties
(region-beginning) (region-end)))))
(read-string "LaTeX Fragment: " frag nil frag))))
(unless latex-frag (user-error "Invalid LaTeX fragment"))
(let* ((tmp-in-file
(let ((file (file-relative-name
(make-temp-name (expand-file-name "ltxmathml-in")))))
(write-region latex-frag nil file)
file))
(tmp-out-file (file-relative-name
(make-temp-name (expand-file-name "ltxmathml-out"))))
(cmd (format-spec
org-mathml-convert-command
`((?j . ,(and org-mathml-converter-jar-file
(shell-quote-argument
(expand-file-name
org-mathml-converter-jar-file))))
(?I . ,(shell-quote-argument tmp-in-file))
(?i . ,latex-frag)
(?o . ,(shell-quote-argument tmp-out-file)))))
mathml shell-command-output)
(when (called-interactively-p 'any)
(unless (org-mathml-converter-available-p)
(user-error "LaTeX to MathML converter not configured")))
(message "Running %s" cmd)
(setq shell-command-output (shell-command-to-string cmd))
(setq mathml
(when (file-readable-p tmp-out-file)
(with-current-buffer (find-file-noselect tmp-out-file t)
(goto-char (point-min))
(when (re-search-forward
(format "<math[^>]*?%s[^>]*?>\\(.\\|\n\\)*</math>"
(regexp-quote
"xmlns=\"http://www.w3.org/1998/Math/MathML\""))
nil t)
(prog1 (match-string 0) (kill-buffer))))))
(cond
(mathml
(setq mathml
(concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" mathml))
(when mathml-file
(write-region mathml nil mathml-file))
(when (called-interactively-p 'any)
(message mathml)))
((warn "LaTeX to MathML conversion failed")
(message shell-command-output)))
(delete-file tmp-in-file)
(when (file-exists-p tmp-out-file)
(delete-file tmp-out-file))
mathml))
(defun org-mathml-convert-latex-cached (latex-frag)
"Use `org-mathml-convert-latex' but check local cache first."
(let ((latex-hash-path
(expand-file-name
(concat
"org-mathml-formula-"
(sha1
(prin1-to-string
(list latex-frag
org-mathml-convert-command)))
".mathml")
temporary-file-directory))
print-length print-level)
(unless (file-exists-p latex-hash-path)
(org-mathml-convert-latex latex-frag latex-hash-path))
(and (file-exists-p latex-hash-path)
latex-hash-path)))
(provide 'ox-mathml)
;;; ox-mathml.el ends here

View File

@ -34,6 +34,7 @@
(require 'org-macs) (require 'org-macs)
(require 'ox) (require 'ox)
(require 'table nil 'noerror) (require 'table nil 'noerror)
(require 'ox-mathml)
(declare-function org-at-heading-p "org" (&optional _)) (declare-function org-at-heading-p "org" (&optional _))
(declare-function org-back-to-heading "org" (&optional invisible-ok)) (declare-function org-back-to-heading "org" (&optional invisible-ok))
@ -3729,114 +3730,147 @@ contextual information."
(defun org-odt--translate-latex-fragments (tree _backend info) (defun org-odt--translate-latex-fragments (tree _backend info)
(let ((processing-type (plist-get info :with-latex)) (let ((processing-type (plist-get info :with-latex))
(count 0) (count 0)
(warning nil)) (warning nil))
;; Normalize processing-type to one of dvipng, mathml or verbatim. ;; MathML will be handled seperately.
;; If the desired converter is not available, force verbatim (if (and (memq processing-type '(t mathml))
;; processing. (fboundp 'org-format-latex-mathml-available-p)
(cl-case processing-type (org-format-latex-mathml-available-p)
((t mathml) (plist-put info :with-latex 'mathml))
(if (and (fboundp 'org-format-latex-mathml-available-p) (org-element-map tree '(latex-fragment latex-environment)
(org-format-latex-mathml-available-p)) (lambda (latex)
(setq processing-type 'mathml) (cl-incf count)
(setq warning "`org-odt-with-latex': LaTeX to MathML converter not available. Falling back to verbatim.") (if-let ((latex-frag (org-element-property :value latex))
(setq processing-type 'verbatim))) (path (org-mathml-convert-latex-cached latex-frag))
((dvipng imagemagick) (link (list 'link
(unless (and (org-check-external-command "latex" "" t) (list :type "file"
(org-check-external-command :path path
(if (eq processing-type 'dvipng) "dvipng" "convert") "" t)) :format 'bracket
(setq warning "`org-odt-with-latex': LaTeX to PNG converter not available. Falling back to verbatim.") :raw-link (format "file:%s" path))))
(setq processing-type 'verbatim))) (replacement
(verbatim) ;; nothing to do (if (eq (org-element-type latex) 'latex-environment)
(otherwise ;;LaTeX environment. Mimic a "standalone image
(setq warning "`org-odt-with-latex': Unknown LaTeX option. Forcing verbatim.") ;; or formula" by enclosing the `link' in
(setq processing-type 'verbatim))) ;; a `paragraph'. Copy over original
;; attributes, captions to the enclosing
;; Display warning if the selected PROCESSING-TYPE is not ;; paragraph.
;; available, but there are fragments to be converted. (org-element-adopt-elements
(when warning (list 'paragraph
(org-element-map tree '(latex-fragment latex-environment) (list :style "OrgFormula"
(lambda (_) (warn warning)) :name
info 'first-match nil t)) (org-element-property :name latex)
:caption
;; Store normalized value for later use. (org-element-property :caption latex)))
(when (plist-get info :with-latex) link)
(plist-put info :with-latex processing-type)) link)))
(message "Formatting LaTeX using %s" processing-type) (progn
;; Note down the object that link replaces.
;; Convert `latex-fragment's and `latex-environment's. (org-element-put-property replacement :replaces
(when (memq processing-type '(mathml dvipng imagemagick)) (list (org-element-type latex)
(org-element-map tree '(latex-fragment latex-environment) (list :value latex-frag)))
(lambda (latex-*) ;; Restore blank after initial element or object.
(cl-incf count) (org-element-put-property
(let* ((latex-frag (org-element-property :value latex-*)) replacement :post-blank
(input-file (plist-get info :input-file)) (org-element-property :post-blank latex))
(cache-dir (file-name-directory input-file)) ;; Replace now.
(cache-subdir (concat (org-element-set-element latex replacement))
(cl-case processing-type (setq warning "Conversion of LaTeX to MathML failed. Falling back to verbatim.")))
((dvipng imagemagick) info nil nil)
org-preview-latex-image-directory) ;; Normalize processing-type to one of dvipng or verbatim.
(mathml "ltxmathml/")) ;; If the desired converter is not available, force verbatim
(file-name-sans-extension ;; processing.
(file-name-nondirectory input-file)))) (cl-case processing-type
(display-msg ((t mathml)
(cl-case processing-type (setq warning "LaTeX to MathML converter not available. Falling back to verbatim."
((dvipng imagemagick) processing-type 'verbatim))
(format "Creating LaTeX Image %d..." count)) ((dvipng imagemagick)
(mathml (format "Creating MathML snippet %d..." count)))) (unless (and (org-check-external-command "latex" "" t)
;; Get an Org-style link to PNG image or the MathML (org-check-external-command
;; file. (if (eq processing-type 'dvipng) "dvipng" "convert") "" t))
(link (setq warning "LaTeX to PNG converter not available. Falling back to verbatim."
(with-temp-buffer processing-type 'verbatim)))
(insert latex-frag) (otherwise
(delay-mode-hooks (let ((org-inhibit-startup t)) (org-mode))) (setq warning "Unknown LaTeX option. Forcing verbatim."
;; When converting to a PNG image, make sure to processing-type 'verbatim)))
;; copy all LaTeX header specifications from the ;; Display warning if the selected PROCESSING-TYPE is not
;; Org source. ;; available, but there are fragments to be converted.
(unless (eq processing-type 'mathml) (when warning
(let ((h (plist-get info :latex-header))) (org-element-map tree '(latex-fragment latex-environment)
(when h (lambda (_) (warn warning))
(insert "\n" info 'first-match nil t))
(replace-regexp-in-string ;; Store normalized value for later use.
"^" "#+LATEX_HEADER: " h))))) (when (plist-get info :with-latex)
(org-latex-preview-replace-fragments (plist-put info :with-latex processing-type))
cache-subdir processing-type cache-dir display-msg) (message "Formatting LaTeX using %s" processing-type)
(goto-char (point-min)) ;; Convert `latex-fragment's and `latex-environment's.
(skip-chars-forward " \t\n") (when (memq processing-type '(dvipng imagemagick))
(org-element-link-parser)))) (org-element-map tree '(latex-fragment latex-environment)
(if (not (org-element-type-p link 'link)) (lambda (latex-*)
(message "LaTeX Conversion failed.") (cl-incf count)
;; Conversion succeeded. Parse above Org-style link to (let* ((latex-frag (org-element-property :value latex-*))
;; a `link' object. (input-file (plist-get info :input-file))
(let ((replacement (cache-dir (file-name-directory input-file))
(cl-case (org-element-type latex-*) (cache-subdir (concat
;;LaTeX environment. Mimic a "standalone image (cl-case processing-type
;; or formula" by enclosing the `link' in ((dvipng imagemagick)
;; a `paragraph'. Copy over original org-preview-latex-image-directory))
;; attributes, captions to the enclosing (file-name-sans-extension
;; paragraph. (file-name-nondirectory input-file))))
(latex-environment (display-msg
(org-element-adopt (cl-case processing-type
(list 'paragraph ((dvipng imagemagick)
(list :style "OrgFormula" (format "Creating LaTeX Image %d..." count))))
:name ;; Get an Org-style link to PNG image.
(org-element-property :name latex-*) (link
:caption (with-temp-buffer
(org-element-property :caption latex-*))) (insert latex-frag)
link)) (delay-mode-hooks (let ((org-inhibit-startup t)) (org-mode)))
;; LaTeX fragment. No special action. ;; When converting to a PNG image, make sure to
(latex-fragment link)))) ;; copy all LaTeX header specifications from the
;; Note down the object that link replaces. ;; Org source.
(org-element-put-property replacement :replaces (let ((h (plist-get info :latex-header)))
(list (org-element-type latex-*) (when h
(list :value latex-frag))) (insert "\n"
;; Restore blank after initial element or object. (replace-regexp-in-string
(org-element-put-property "^" "#+LATEX_HEADER: " h))))
replacement :post-blank (org-latex-preview-replace-fragments
(org-element-property :post-blank latex-*)) cache-subdir processing-type cache-dir display-msg)
;; Replace now. (goto-char (point-min))
(org-element-set latex-* replacement))))) (skip-chars-forward " \t\n")
info nil nil t))) (org-element-link-parser))))
(if (not (eq 'link (org-element-type link)))
(message "LaTeX Conversion failed.")
;; Conversion succeeded. Parse above Org-style link to
;; a `link' object.
(let ((replacement
(cl-case (org-element-type latex-*)
;;LaTeX environment. Mimic a "standalone image
;; or formula" by enclosing the `link' in
;; a `paragraph'. Copy over original
;; attributes, captions to the enclosing
;; paragraph.
(latex-environment
(org-element-adopt-elements
(list 'paragraph
(list :style "OrgFormula"
:name
(org-element-property :name latex-*)
:caption
(org-element-property :caption latex-*)))
link))
;; LaTeX fragment. No special action.
(latex-fragment link))))
;; Note down the object that link replaces.
(org-element-put-property replacement :replaces
(list (org-element-type latex-*)
(list :value latex-frag)))
;; Restore blank after initial element or object.
(org-element-put-property
replacement :post-blank
(org-element-property :post-blank latex-*))
;; Replace now.
(org-element-set-element latex-* replacement)))))
info nil nil t))))
tree) tree)
@ -4163,7 +4197,7 @@ MathML source to kill ring depending on the value of
(save-buffer-coding-system 'utf-8)) (save-buffer-coding-system 'utf-8))
(set-buffer buffer) (set-buffer buffer)
(set-buffer-file-coding-system coding-system-for-write) (set-buffer-file-coding-system coding-system-for-write)
(let ((mathml (org-create-math-formula latex-frag))) (let ((mathml (org-mathml-convert-latex-cached latex-frag)))
(unless mathml (error "No Math formula created")) (unless mathml (error "No Math formula created"))
(insert mathml) (insert mathml)
;; Add MathML to kill ring, if needed. ;; Add MathML to kill ring, if needed.