Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some MathML that fails #1293

Closed
Omikhleia opened this issue Nov 29, 2021 · 4 comments · Fixed by #2151
Closed

Some MathML that fails #1293

Omikhleia opened this issue Nov 29, 2021 · 4 comments · Fixed by #2151
Assignees
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages
Milestone

Comments

@Omikhleia
Copy link
Member

SILE 0.12

Math input:

<sile>
<mathml>
<mtable><mtr><mtd><mi>A</mi></mtd></mtr><mtr><mtd><mi>B</mi></mtd></mtr></mtable>
<mi>C</mi>
<mtable><mtr><mtd><mi>D</mi></mtd></mtr><mtr><mtd><mi>E</mi></mtd></mtr></mtable>
</mathml>
</sile>

Expected:

A D
 C
B E

Observed

Error detected:
	/usr/share/sile/core/length.lua:96: attempt to index local 'self' (a nil value)
stack traceback:
	/usr/share/sile/core/length.lua:96: in function '__add'
	packages/math/base-elements.lua:486: in function 'shape'
	packages/math/base-elements.lua:309: in function 'shapeTree'
	/usr/share/sile/packages/math/typesetter.lua:117: in function 'handleMath'
...

At line 486, self.children[i - 1].relY is nil for i == 2 (and indeed not initialized above in the case i == 1 ? However setting it there to 0 avoids the crash, but all items are then stacked vertically...

(MathML is hard, maybe I am doing it wrong ? the above MathML snippet was generated with the demo at https://demo.wiris.com/mathtype/en/developers.php and and also shows up correctly in https://www.mathmlcentral.com/Tools/FromMathML.jsp)

@ctrlcctrlv
Copy link
Member

Hey, I think you're doing it wrong, but am not sure, I have not a lot of experience with MathML. In my understanding, MathML is supposed to be used to “describe the layout structure of mathematical notation whereas content markup provides the underlying mathematical meaning and is not supposed to be rendered by the MathML parser”. “The intent of Content Markup is to provide an explicit encoding of the underlying mathematical meaning of an expression, rather than any particular rendering for the expression.

That's not to say you're causing this bug, but I think that an <mi/> between <mtable/>'s is undefined behavior?? So you're supposed to have multiple <math>'s? That would explain why no child other than the first is considered. Maybe I'm reading it wrong, sorry if I am. :-)

@OlivierNicole
Copy link
Member

OlivierNicole commented Dec 2, 2021

This code should, in fact, be accepted, so this is a bug. Currently, when a mathml tag has several children, SILE should typeset them stacked vertically (although the MathML spec says that it should be horizontal like in an mrow, so we'll need to change that). And the above code shouldn't be a problem. I'll look into it.

Edit: replaced wrong word.

@OlivierNicole OlivierNicole self-assigned this Dec 2, 2021
@OlivierNicole OlivierNicole added the bug Software bug issue label Dec 2, 2021
@alerque alerque moved this to To do in Math Jun 24, 2022
@alerque alerque added this to Math Jun 24, 2022
@alerque alerque added this to the v0.x.y milestone Dec 13, 2022
@Omikhleia Omikhleia added the modules:packages Issue relates to core or 3rd party packages label Mar 26, 2023
@Omikhleia
Copy link
Member Author

Omikhleia commented Nov 1, 2024

Currently, when a mathml tag has several children, SILE should typeset them stacked vertically (although the MathML spec says that it should be horizontal like in an mrow, so we'll need to change that). And the above code shouldn't be a problem.

References:

  • MathML Core (WD Nov. 2023) §2.1.1: "... the element ... the layout algorithm of the mrow element is used to produce a math content box ..." = mrow implied.
  • MathML4 (WD)1 §2.2: The math element can contain an arbitrary number of child elements. They render by default as if they were contained in an mrow element.
  • Exact same sentence in MathML3 (April 2014 ) = an mrow was always implied, indeed.

I'll look into it.

I'll do it in #2151 - It's a one liner...

Footnotes

  1. First WD Sep. 2022, Last Working Draft was published... yesterday.

@Omikhleia Omikhleia assigned Omikhleia and unassigned OlivierNicole Nov 1, 2024
@Omikhleia Omikhleia moved this from To do to In progress in Math Nov 1, 2024
Omikhleia added a commit to Omikhleia/resilient-types that referenced this issue Nov 2, 2024
@Omikhleia
Copy link
Member Author

Be my guest:
Image

Omikhleia added a commit to Omikhleia/resilient-types that referenced this issue Nov 2, 2024
@Omikhleia Omikhleia modified the milestones: v0.x.y, v0.15.6 Nov 2, 2024
@alerque alerque closed this as completed in 1f1a1a0 Nov 2, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Math Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants