Thoughts on LibreOffice Math

Frédéric WANG fred.wang at free.fr
Sun Jun 23 23:17:02 PDT 2013


Hi all,

My name is Frédéric Wang and as some you may have noticed, I've recently 
contributed some patches for the LibreOffice Formula Editor. For those 
who don't know me: I work for the MathJax project, I've been 
contributing to the Mozilla MathML project for several years and I 
recently started to do some developments on MathML in WebKit too.

Some people on the MathJax user list reported issues with the 
mathematical formulas generated with LibreOffice and it turned out that 
the exported MathML code is currently quite bad. Hence I looked into the 
LibreOffice Math a few days ago, reported bugs and submitted a few 
patches. I'd like to share my thoughts on the situation and future of 
LibreOffice Math. Thomas Lange a message a long time ago about how Math 
could evolved: 
http://www.mail-archive.com/dev@sw.openoffice.org/msg00200.html. First, 
I note the following requirements:

1) Some people like the current Math semi-WYSIWYG interface and are 
familiar with the StarMath syntax. So this interface should be preserved 
anyway.
2) Some people would like a complete WYSIWYG editor.
3) Some people would like a LaTeX input mode to enter mathematical 
formulas (like in Abiword)
4) Some people (at least the MathML & MathJax communities) would like 
MathML import/export and copy and paste, like in Microsoft Word. It is 
also a requirement of the ODT format.
5) Some people would like a high quality rendering (e.g. for printing, 
to export to SVG etc). This is subjective but that would mean at least 
the quality level of documents generated by Microsoft Word or LaTeX.

Currently, LibreOffice Math is centered around its StarMath syntax and 
internal tree structure, which make 1) possible and there is already an 
experimental visual editor to do 2). As I read the code, the MathML 
export is not very good but that can be improved. However, importing 
from more expressive language like LaTeX or MathML seems very hard and 
makes 3) and 4) unlikely. I didn't look at the rendering code, but 
Khaled Hosny mentioned on bug 32362 that it would have to be rewritten 
from scratch and I suspect one issue is the StarMath internal tree.

I'd like to propose to center LibreOffice Math around the MathML syntax 
(and corresponding DOM structure) instead:

* I hope I can improve the code to get a decent MathML export and thus 
1) and 2) could be preserved. It would still be possible to keep the UI 
to work directly on the MathML DOM.
* For 3), there are many LaTeX to MathML converters like itex2MML (used 
in Abiword), BlahTeX, MathJax etc that could be integrated in LibreOffice.
* This would obviously make 4) easy. MathML has a <semantics> element 
which is currently used to store the StarMath syntax and could be used 
to store LaTeX too. Davide Carlisle also has an XSLT stylesheet to 
convert MathML code to LaTeX.
* Microsoft Word uses an XML language for mathematics similar to MathML 
so it should be possible to get 5). Khaled Hosny mentioned a fork of 
GtkMathView that has support for Open Type MATH and can produce a good 
rendering. It takes MathML as input and can export PNG or SVG images.

-- 
Frédéric Wang
maths-informatique-jeux.com/blog/frederic


More information about the LibreOffice mailing list