Bug Hunting Session
Bug 66278 - MathML export does not distinguish between inline and display equations
Summary: MathML export does not distinguish between inline and display equations
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: All All
: medium normal
Assignee: Frédéric Wang
URL:
Whiteboard: target:4.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-27 21:23 UTC by Frédéric Wang
Modified: 2013-07-01 14:34 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Wang 2013-06-27 21:23:17 UTC
Mathematical formulas can generally be "inline" like this x = 1 + 2 = 3 that is inside a paragraph of text or "display" like this

                        ∑_{i=1}^n i = n(n+1)/2

that is in their own centered paragraph. The rendering is also slightly different, e.g. in inline mode operators like sums or integrals are draw bigger, scripts are placed differently etc

LaTeX and MathML are able to make this distinction but Math does not (or at least I have not found anything). There should be an option or something to specify whether the formula is in inline or display mode.

For MathML export, this would only be attaching display="block" to the <math> root when writing display equations (and nothing otherwise).
Comment 1 Frédéric Wang 2013-06-28 13:52:58 UTC
There is actually an option Format => Text to do that. The MathML export still needs to be modified to take that option into account.
Comment 2 Frédéric Wang 2013-06-28 15:25:14 UTC
I've submitted a patch for review:
https://gerrit.libreoffice.org/#/c/4607/

For some reason, the XHTML export created a new <math> node and copied the children of math/semantics, skipping the annotation. I've modified that to export the whole math element (in particular the display attribute) but I kept that its semantics child and annotation elements are skipped. Actually, I only export the fist child of semantics, so that will be essentially the same since the semantics created by Math contains only one StarMath annotation element.

How to test the changes:

1) In Math
  1a) create a new formula "sum from {i=1} to n i = {n(n+1)} over 2" ; in the menu, uncheck the option "Format => Text mode" and save it in mml format.
  1b) create a new formula "sum from {i=1} to n i = {n(n+1)} over 2" ; in the menu, check the option "Format => Text mode" and save it in mml format.
  1c) The first file should have display="block" attached to the math element but the second should not.

2) In Writer
  2a) Create a new document and do Insert => object => formula and type a formula as in 1a)
  2b) In the same document, do Insert => object => formula and type a formula as in 1b)
  2c) Do file => export => XHTML
  2d) The exported XHTML file should have one formula with display="block" and one without that attribute. You can open the page in Firefox to see the rendering differences (that you should have seen in LibreOffice too).

Note: for some reason in 2), I get <img> of formulas exported, but that seems a separate bug.
Comment 3 Commit Notification 2013-07-01 13:48:33 UTC
Frederic Wang committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1ef63d0842dab4154c5ca2fc42e416950bd7459a

 fdo#66278 - MathML export: distinguish inline/display equations.



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.