Browse Source

org.el: More general TeX to MathML convert support

* org.el (org-latex-to-mathml-convert-command): Work with
  other converters than mathtoweb.
  (org-latex-to-mathml-convert-command): Add possibility of
  passing latex-fragment.
* org.texi (Working with @LaTeX{} math snippets): Show LaTeXML config.
Rasmus 3 years ago
parent
commit
f82dad1237
2 changed files with 20 additions and 8 deletions
  1. 8 3
      doc/org.texi
  2. 12 5
      lisp/org.el

+ 8 - 3
doc/org.texi

@@ -12491,9 +12491,9 @@ You can specify the @LaTeX{}-to-MathML converter by customizing the variables
 @code{org-latex-to-mathml-convert-command} and
 @code{org-latex-to-mathml-jar-file}.
 
-If you prefer to use @file{MathToWeb}@footnote{See
-@uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
-converter, you can configure the above variables as shown below.
+To use MathToWeb@footnote{See
+@uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}.} as your
+converter, you can configure the above variables as
 
 @lisp
 (setq org-latex-to-mathml-convert-command
@@ -12501,6 +12501,11 @@ converter, you can configure the above variables as shown below.
       org-latex-to-mathml-jar-file
       "/path/to/mathtoweb.jar")
 @end lisp
+To use @LaTeX{}ML@footnote{See @uref{http://dlmf.nist.gov/LaTeXML/}.} use
+@lisp
+(setq org-latex-to-mathml-convert-command
+      "latexmlmath \"%i\" --presentationmathml=%o")
+@end lisp
 
 You can use the following commands to quickly verify the reliability of
 the @LaTeX{}-to-MathML converter.

+ 12 - 5
lisp/org.el

@@ -3970,12 +3970,16 @@ 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
-%o:     Output MathML 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 to
-\"java -jar %j -unicode -force -df %o %I\"."
+\"java -jar %j -unicode -force -df %o %I\".
+
+When using  LaTeXML set this to
+\"latexmlmath \"%i\" --presentationmathml=%o\"."
   :group 'org-latex
   :version "24.1"
   :type '(choice
@@ -18949,6 +18953,7 @@ inspection."
 	       `((?j . ,(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 (org-called-interactively-p 'any)
@@ -18963,9 +18968,11 @@ inspection."
 	      (when (re-search-forward
 		     (concat
 		      (regexp-quote
-		       "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">")
+		       "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"")
+		      "[^>]*?>"
 		      "\\(.\\|\n\\)*"
-		      (regexp-quote "</math>")) nil t)
+		      "</math>")
+		     nil t)
 		(prog1 (match-string 0) (kill-buffer))))))
     (cond
      (mathml