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

SVG-output does not style merror #387

Closed
pkra opened this issue Feb 8, 2013 · 8 comments

Comments

Projects
None yet
3 participants
@pkra
Copy link
Member

commented Feb 8, 2013

merror is not styled in SVG-output.

<math xmlns="http://www.w3.org/1999/xhtml" display="block">
  <merror>
    <mrow>
      <mi>A</mi>
      <mo>/</mo>
      <mn>0</mn>
    </mrow>
  </merror>
</math>
@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Feb 11, 2013

Reading the source, it seems that we only style mtext children of merror elements (there is a FIXME message saying that this should be improved). Actually, we don't even have any toSVG function for merror elements. We can probably do something similar to the HTML-CSS output, i.e make toSVG generate a <g> (or <rect>) with an merror class. Then in jax/output/SVG/config.js, style this merror class with stroke colors etc However, style inheritance in the SVG output may be a bit different..

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 11, 2013

The merror inherhits the toSVG method from the mbase class. So it does have one, it just hasn't had to override it.

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Feb 11, 2013

Yes, I meant we don't override the defaut toSVG, so we don't do anything specific for merror, except the special case for mtext.

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 11, 2013

As I remember, the problem was adding the border and background color, since that required an additional SVG element (as Fred suggests). I'm not sure the desired effect can be handled completely through CSS, as the rectangle used for the border and background would need its size to depend on the contents, and I don't think you can manage that through pure CSS. (SVG doesn't have anything that corresponds to padding, for example). So that's why I had to hard-code the styling for the merror's mtext, but perhaps it could be done in the merror directly instead.

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2013

Perhaps the thing to do would be to make the merror.toSVG create a SVG rectangle with border and background and determine the rectangle size from its content. However, we still have the problem that the text color might not be set easily via CSS inheritance only. Moreover, that seems even more complicated if we want to do as suggested by the FIXME comment i.e. make the merror entirely stylisable in the config file.

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 12, 2013

Yes, doing the rectangle in merror was what I had in mind (and taking it out of mtext). You could get the border color and size, and background color, via CSS, but I don't see how to do padding that way (without using something like getComputedStyle). The text color can be done via CSS for stroke and fill (but see below).

The HTML-CSS output jax mirrors the MathML structure in its span structure, and uses class names to allow styling. But this adds a lot of complexity to the DOM, and that turned out to slow down the math processing. So the SVG jax (by default) reduces its tree structure as much as it can. That means it doesn't retain the same MathML nesting structure. But there is a configuration parameter (addMMLclasses) that will cause the SVG output to keep the MathML structure and add classes like the HTML-CSS output, so that you can style it.

That should allow you to style the merror class if you want.

@ghost ghost assigned dpvc Apr 18, 2013

@pkra pkra added this to the Bugfix Version milestone Mar 6, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Mar 16, 2014

@dpvc dpvc added Ready for Review and removed Investigate labels Mar 16, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Mar 18, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Mar 18, 2014

=> Merged.

@dpvc dpvc closed this Mar 18, 2014

dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Apr 21, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 21, 2014

=> In Test Suite.

MathMLToDisplay/Presentation/GeneralLayout/merror/issue387.html

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.