Bug 81428 - Import MathML format generated by MathJax into OpenOffice / LibreOffice
Summary: Import MathML format generated by MathJax into OpenOffice / LibreOffice
Status: RESOLVED DUPLICATE of bug 47414
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
4.4.0.0.alpha0+ Master
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://web.archive.org/web/201410081...
Whiteboard:
Keywords:
Depends on:
Blocks: Formula-Editor
  Show dependency treegraph
 
Reported: 2014-07-16 12:53 UTC by rk601
Modified: 2016-10-29 19:15 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Request that LibreOffice integrate with MathML generated with MathJax (150.00 KB, image/png)
2014-07-16 12:53 UTC, rk601
Details
MathJax generates MathML (48.14 KB, image/png)
2015-07-14 14:58 UTC, rk601
Details
Copy MathJax generated MathML (103.52 KB, image/png)
2015-07-14 15:01 UTC, rk601
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rk601 2014-07-16 12:53:56 UTC
Created attachment 102921 [details]
Request that LibreOffice integrate with MathML generated with MathJax

The ability to generate and display higher mathematics is essential for numerous disciplines and businesses. For example, Cambridge Journals employs MathJax* to deliver high-quality, accessible mathematics in over 300 peer-reviewed journals. LibreOffice has begun to use MathML in its documents. However, MathML generated by MathJax does not import into LibreOffice without significant modification, and it is not possible to Copy and Paste the MathML format into LibreOffice.

We request that LibreOffice integrate with MathML generated with MathJax via Import and Copy and Paste. For quite some time, MSWord has allowed for this type of integration.

Please see the Web page and video located at the following address:

http://www.mathjax.org/demos/copy-and-paste/

*Note: MathJax is an open source JavaScript display engine for mathematics that works in all modern browsers.
Comment 1 rk601 2014-07-16 12:55:42 UTC
Comment on attachment 102921 [details]
Request that LibreOffice integrate with MathML generated with MathJax

Please note that the attachment is a .PNG image.
Comment 2 Dominik 2014-07-19 00:21:50 UTC
that would be great, especially as i see that mathjax is gathering pace.
Comment 3 Regina Henschel 2015-07-08 10:31:43 UTC
Can you please be more exact about "MathML generated with MathJax". I thought MathJax is a rendering help for webpages which contain MathML segments. The only thing I see, is the ability to show MathML source in a separate window from the context menu of a formula, when showing the webpage in the browser.
Comment 4 rk601 2015-07-08 16:16:19 UTC
Dear Regina:

The request that LibreOffice integrate with MathML generated with MathJax via Import and Copy and Paste was made more than a year ago, so the provided Web links to see how MathJax is implemented has changed.

Please check the following link:

https://web.archive.org/web/20141008170023/http://www.mathjax.org/demos/copy-and-paste/

Notice how MSWord can integrate with MathML generated with MathJax via Import and Copy and Paste. We request that LibreOffice integrate with MathML generated with MathJax via Import and Copy and Paste. If you have MSWord then you can use it and see how the MathJax syntax functions within the Word processor to generate accurate and beautiful formulas, functions, and math!

MathJax Syntax

MathJax uses LaTeX syntax to display math notations. For inline math, enclose the LaTeX syntax in dollar signs ($). For displayed math, enclose the syntax with two dollar signs ($$). For example, to display x squared inline (x2) type $ x^2 $ or type $$ x^2 $$

Syntax for MathJax can be found at the following Web address:

http://www.suluclac.com/Wiki+MathJax+Syntax

The ability to enhance and/or modify the existing MathML features of LibreOffice to work with MathJax would greatly impact the usage and desirability of LibreOffice.

You will also find how MathJax and its syntax is used in the next two Web addresses:

https://www.youtube.com/watch?v=9h7mMFFWer0

https://www.youtube.com/watch?v=TairRxyy_Hs

LibreOffice often is NOT used because IT DOES NOT support this extremely useful and important math functionality!

( See:

http://tex.stackexchange.com/questions/25223/embed-latex-math-equations-into-microsoft-word

for additional information on MathJax usage in Word. Please note that LaTeX is not as easily used for the purpose of cross-application-integration. For example, we can generate the desired MathML based on MathJax syntax and implement it in Word or on the Web or within publications, etc! )
Comment 5 Regina Henschel 2015-07-08 17:50:15 UTC
With commit http://cgit.freedesktop.org/libreoffice/core/commit/?id=64bc8b45b5c23efc5fe57585a69aa4263aaf4e83 I have added this:
If you have text in the clipboard, which can be interpreted as a MathML segment with math as root element, or if you have a clipboard content of MIME type "application/mathml+xml" then you can import the content in module LibreOffice Math. Find the item in menu Tools in the Equation Editor module.

As LibreOffice cannot natively render MathML, the import is transformed to StarMath. That has some known problems.

--------------

Your description is still not clear. Perhaps you need to separate it into different issues. I guess you have the following wishes; correct me, where I'm wrong:

(1) If the clipboard content has suitable MathML, then LibreOffice should offer "paste-special" and insert a formula immediately.
[That has a performance problem, because you can only know, whether the content can be transformed, when you try to transform it.]

(2) If you are in formula editing mode and the clipboard content has suitable MathML, than allow to paste it.
[That have I done, see above. For MathML the parser and a piece of code, that transforms MathML to StarMath already exists for file import and 'only' need to be used for clipboard too. MathML is the language, which is specified for Formulas in OpenDocument.]

(3) LibreOffice should offer to import clipboard content, which is actually Tex or Latex.

(4) Allow to write Tex or Latex and transform it on demand into StarMath.

But I do not see, what is the role of MathJax in all this.

--------

I cannot play the video on web.archive.org.
Comment 6 rk601 2015-07-14 14:19:51 UTC
We desire LibreOffice to be able to use MathML syntax, characters, format, commands, and equations generated by/for MathJax so that LibreOffice correctly represents (displays) the equation with the mathematical notations -- capturing both its structure and content by simply copy and paste. 

Follow these steps to display MathJax generated MathML in MSWord:

(1) Simply generate the desired MathJax MathML XML (within an Editor, Web browser, other software, or obtain it from an HTML fragment)

(2) Copy the desired MathJax MathML XML fragment

(3) Paste the MathJax MathML XML fragment copied from, for example, HTML, notepad, etc., into Word.

Here is a simple Integral, specified using the int element. The variable of integration is represented using the element bvar. The upper and lower limits of integration are usually specified using the elements lowlimit and uplimit:

<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<int/>
<bvar>
<ci>x</ci>
</bvar>
<lowlimit>
<ci>a</ci>
</lowlimit>
<uplimit>
<ci>b</ci>
</uplimit>
<ci>x</ci>
</apply>
</math>


So, just Copy and Paste the above XML into Word and the Integral will be displayed in the document.

Here is another example (when a≠0, there are two solutions to a x pow(2) +bx+c=0
and they are):

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mi>x</mi> <mo>=</mo>
  <mrow>
    <mfrac>
      <mrow>
        <mo>&#x2212;</mo>
        <mi>b</mi>
        <mo>&#x00B1;</mo>
        <msqrt>
          <msup><mi>b</mi><mn>2</mn></msup>
          <mo>&#x2212;</mo>
          <mn>4</mn><mi>a</mi><mi>c</mi>
        </msqrt>
      </mrow>
      <mrow> <mn>2</mn><mi>a</mi> </mrow>
    </mfrac>
  </mrow>
  <mtext>.</mtext>
</math>


Here is another example:

square-root of X divided by (y squared - 1)

Here is the XML:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mfrac>
<msqrt>
<mi>x</mi>
</msqrt>
<mrow>
<msup>
<mi>y</mi>
<mn>2</mn>
</msup>
<mo>-</mo>
<mn>1</mn>
</mrows>
</mfrac>
</math>

Here is some MathJax HTML (we can copy three different MathML fragments from the below HTML and then paste each fragment into Word; Word will correctly render and display each math fragment):

<!DOCTYPE html>
<html>
<head>
<title>MathJax MathML Test Page</title>
<!-- Copyright (c) 2010-2015 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<script type="text/javascript" src="../MathJax.js?config=MML_HTMLorMML-full"></script>

</head>
<body>

<p>
When
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>a</mi><mo>&#x2260;</mo><mn>0</mn>
</math>,
there are two solutions to
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>a</mi><msup><mi>x</mi><mn>2</mn></msup>
  <mo>+</mo> <mi>b</mi><mi>x</mi>
  <mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn>
</math>
and they are
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mi>x</mi> <mo>=</mo>
  <mrow>
    <mfrac>
      <mrow>
        <mo>&#x2212;</mo>
        <mi>b</mi>
        <mo>&#x00B1;</mo>
        <msqrt>
          <msup><mi>b</mi><mn>2</mn></msup>
          <mo>&#x2212;</mo>
          <mn>4</mn><mi>a</mi><mi>c</mi>
        </msqrt>
      </mrow>
      <mrow> <mn>2</mn><mi>a</mi> </mrow>
    </mfrac>
  </mrow>
  <mtext>.</mtext>
</math>
</p>

</body>
</html>


Please see the following links for more information:

https://bugs.documentfoundation.org/show_bug.cgi?id=47414

and

http://listarchives.libreoffice.org/global/users/msg03980.html
Comment 7 rk601 2015-07-14 14:58:57 UTC
Created attachment 117237 [details]
MathJax generates MathML

Follow these steps, MathJax generates MathML:

Go to the following Web Address:

(A) http://mathjs.org/examples/browser/pretty_printing_with_mathjax.html

(B) Right click on the formula, to the right of the "Pretty print:" label. 

(C) From the Pop-Up menu select "Show Math As" command.

(D) Select "MathML Code"

(E) Copy the generated MathML Code

(F) Paste the generated MathML Code into LibreOffice.

(E) LibreOffice will correctly render and display the correct math.
Comment 8 rk601 2015-07-14 15:01:03 UTC
Created attachment 117238 [details]
Copy MathJax generated MathML

Click within the TextArea, select all of the text, and use the Copy command. Within LibreOffice, click on the document and use the Paste command.
Comment 9 Regina Henschel 2015-07-14 18:14:19 UTC
I see, it is nothing special about MathJax, but it is about importing MathML.

This issue covers the same request as issue 47414. Therefore I suggest to close this as duplicate. 

Please get a current daily build http://dev-builds.libreoffice.org/daily/ and look at the new feature for importing MathML. Insert a formula object or start with a formula document, then find the new command "Insert MathML from Clipboard" in the menu Tools. It will import the MathML source generated bei MathJax and those generated from other tools. Content Markup as in your first example in comment 6 is not supported by LibreOffice and there are currently no efforts to implement it.

I know, that the result in converting to StarMath has many problems, especially bug 75171 is still not fixed. And I know, that the current StarMath is not able to reflect all features of MathML.


BTW:
 (B) in comment#7 does not work for me with browser Seamonkey, I have to use Alt+Right-click.

 I have got Word 2010, but no one of your examples in comment#6 will turn into a formula, when pasted into a Word document. I do not find any option for that, there is no "paste special" and nothing in context menu, neither in the text document itself or when in edit mode of a formula.
Comment 10 V Stuart Foote 2016-10-29 19:15:34 UTC

*** This bug has been marked as a duplicate of bug 47414 ***