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 13f37014ee
commit 9593c81d1c
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
4 changed files with 334 additions and 246 deletions

View File

@ -687,6 +687,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,41 +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: The latex fragment to be converted.
%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
@ -300,19 +265,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]
@ -2270,97 +2222,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."

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

@ -0,0 +1,155 @@
;;; 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: The latex fragment to be converted.
%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))
@ -3712,113 +3713,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
(otherwise (if (eq (org-element-type latex) 'latex-environment)
(setq warning "`org-odt-with-latex': Unknown LaTeX option. Forcing verbatim.") ;;LaTeX environment. Mimic a "standalone image
(setq processing-type 'verbatim))) ;; or formula" by enclosing the `link' in
;; a `paragraph'. Copy over original
;; Display warning if the selected PROCESSING-TYPE is not ;; attributes, captions to the enclosing
;; available, but there are fragments to be converted. ;; paragraph.
(when warning (org-element-adopt-elements
(org-element-map tree '(latex-fragment latex-environment) (list 'paragraph
(lambda (_) (warn warning)) (list :style "OrgFormula"
info 'first-match nil t)) :name
(org-element-property :name latex)
;; Store normalized value for later use. :caption
(when (plist-get info :with-latex) (org-element-property :caption latex)))
(plist-put info :with-latex processing-type)) link)
(message "Formatting LaTeX using %s" processing-type) link)))
(progn
;; Convert `latex-fragment's and `latex-environment's. ;; Note down the object that link replaces.
(when (memq processing-type '(mathml dvipng imagemagick)) (org-element-put-property replacement :replaces
(org-element-map tree '(latex-fragment latex-environment) (list (org-element-type latex)
(lambda (latex-*) (list :value latex-frag)))
(cl-incf count) ;; Restore blank after initial element or object.
(let* ((latex-frag (org-element-property :value latex-*)) (org-element-put-property
(input-file (plist-get info :input-file)) replacement :post-blank
(cache-dir (file-name-directory input-file)) (org-element-property :post-blank latex))
(cache-subdir (concat ;; Replace now.
(cl-case processing-type (org-element-set-element latex replacement))
((dvipng imagemagick) (setq warning "Conversion of LaTeX to MathML failed. Falling back to verbatim.")))
org-preview-latex-image-directory) info nil nil)
(mathml "ltxmathml/")) ;; Normalize processing-type to one of dvipng or verbatim.
(file-name-sans-extension ;; If the desired converter is not available, force verbatim
(file-name-nondirectory input-file)))) ;; processing.
(display-msg (cl-case processing-type
(cl-case processing-type ((t mathml)
((dvipng imagemagick) (setq warning "LaTeX to MathML converter not available. Falling back to verbatim."
(format "Creating LaTeX Image %d..." count)) processing-type 'verbatim))
(mathml (format "Creating MathML snippet %d..." count)))) ((dvipng imagemagick)
;; Get an Org-style link to PNG image or the MathML (unless (and (org-check-external-command "latex" "" t)
;; file. (org-check-external-command
(link (if (eq processing-type 'dvipng) "dvipng" "convert") "" t))
(with-temp-buffer (setq warning "LaTeX to PNG converter not available. Falling back to verbatim."
(insert latex-frag) processing-type 'verbatim)))
(delay-mode-hooks (let ((org-inhibit-startup t)) (org-mode))) (otherwise
;; When converting to a PNG image, make sure to (setq warning "Unknown LaTeX option. Forcing verbatim."
;; copy all LaTeX header specifications from the processing-type 'verbatim)))
;; Org source. ;; Display warning if the selected PROCESSING-TYPE is not
(unless (eq processing-type 'mathml) ;; available, but there are fragments to be converted.
(let ((h (plist-get info :latex-header))) (when warning
(when h (org-element-map tree '(latex-fragment latex-environment)
(insert "\n" (lambda (_) (warn warning))
(replace-regexp-in-string info 'first-match nil t))
"^" "#+LATEX_HEADER: " h))))) ;; Store normalized value for later use.
(org-latex-preview-replace-fragments (when (plist-get info :with-latex)
cache-subdir processing-type cache-dir display-msg) (plist-put info :with-latex processing-type))
(goto-char (point-min)) (message "Formatting LaTeX using %s" processing-type)
(skip-chars-forward " \t\n") ;; Convert `latex-fragment's and `latex-environment's.
(org-element-link-parser)))) (when (memq processing-type '(dvipng imagemagick))
(if (not (org-element-type-p link 'link)) (org-element-map tree '(latex-fragment latex-environment)
(message "LaTeX Conversion failed.") (lambda (latex-*)
;; Conversion succeeded. Parse above Org-style link to (cl-incf count)
;; a `link' object. (let* ((latex-frag (org-element-property :value latex-*))
(let ((replacement (input-file (plist-get info :input-file))
(cl-case (org-element-type latex-*) (cache-dir (file-name-directory input-file))
;;LaTeX environment. Mimic a "standalone image (cache-subdir (concat
;; or formula" by enclosing the `link' in (cl-case processing-type
;; a `paragraph'. Copy over original ((dvipng imagemagick)
;; attributes, captions to the enclosing org-preview-latex-image-directory))
;; paragraph. (file-name-sans-extension
(latex-environment (file-name-nondirectory input-file))))
(org-element-adopt (display-msg
(list 'paragraph (cl-case processing-type
(list :style "OrgFormula" ((dvipng imagemagick)
:name (format "Creating LaTeX Image %d..." count))))
(org-element-property :name latex-*) ;; Get an Org-style link to PNG image.
:caption (link
(org-element-property :caption latex-*))) (with-temp-buffer
link)) (insert latex-frag)
;; LaTeX fragment. No special action. (delay-mode-hooks (let ((org-inhibit-startup t)) (org-mode)))
(latex-fragment link)))) ;; When converting to a PNG image, make sure to
;; Note down the object that link replaces. ;; copy all LaTeX header specifications from the
(org-element-put-property replacement :replaces ;; Org source.
(list (org-element-type latex-*) (let ((h (plist-get info :latex-header)))
(list :value latex-frag))) (when h
;; Restore blank after initial element or object. (insert "\n"
(org-element-put-property (replace-regexp-in-string
replacement :post-blank "^" "#+LATEX_HEADER: " h))))
(org-element-property :post-blank latex-*)) (org-latex-preview-replace-fragments
;; Replace now. cache-subdir processing-type cache-dir display-msg)
(org-element-set latex-* replacement))))) (goto-char (point-min))
info nil nil t))) (skip-chars-forward " \t\n")
(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)
@ -4145,7 +4180,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.