-
Notifications
You must be signed in to change notification settings - Fork 102
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
Mathvariant fixes #2292
Mathvariant fixes #2292
Conversation
…nt cannot be handled by pure Unicode
@@ -729,15 +731,18 @@ sub stylizeContent { | |||
$class = ($class ? $class . ' ' : '') . 'ltx_font_oldstyle'; } | |||
elsif ($font =~ /smallcaps/) { | |||
$class = ($class ? $class . ' ' : '') . 'ltx_font_smallcaps'; } | |||
elsif ($variant) { # Any left-over mathvariant? Punt to CSS | |||
$class = ($class ? $class . ' ' : '') . 'ltx_mathvariant_' . $variant; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this check also unset $variant = undef;
after it is moved to a class value?
As it is, I see that one of the tests has both a class and mathvariant attribute, as in:
<mtext class="ltx_mathvariant_italic" mathvariant="italic">
But in MathML Core the only prescribed use of mathvariant is for the normal
value. So the class
addition should suffice. That was my suggestion in #2051 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, well as I understood the original issue, and the implications of the (eventually) linked mozilla issue, it was that Core will ignore (most) mathvariants, and that Full may ignore it, and that CSS could be used as a fallback. Moreover, that browsers should be able to cope with there being both CSS and mathvariant.
Keeping the mathvariant at least records for MathML-Full agents which don't support CSS that the token was (apparently) intended to belong to a certain semantic class. Removing it seems somehow wrong, even though in the current scheme of things it is likely always to be ignored (but harmless?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is ignored in practice, keeping it until there is some actual issue caused by it is likely harmless, as you say. And indeed it is a MathML Full use.
I've heard rumors of hypothetical MathML Full agents without CSS support, but I wonder if/when we'll have some to test with...
Linking the current MathML Core text on mathvariant just in case:
The mathvariant attribute, if present, must be an ASCII case-insensitive match of normal.
No further comments on the PR, looks good to merge.
…s on formatting chars (eg. InvisibleTimes,etc)
Following offline discussions, simplified the |
lib/LaTeXML/Post/MathML.pm
Outdated
if ((defined $u_text) && ($u_text ne '')) { # didn't remap the text ? Keep text & variant | ||
$text = $u_text; | ||
$variant = ($plane1hack && ($variant ne $u_variant) && ($variant =~ /^bold/) | ||
? 'bold' : undef); } # Possibly keep variant bold | ||
# Use class (css) to patchup some weak translations | ||
if (!$font) { } | ||
if ($text =~ /^\p{Format}*$/) { # Formatting (eg. InvisibleTImes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this regex is a little odd - does it mean starting with \p{Format}
or empty? If so, you can replace the *$
with ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I clarified the comment; should mean that the text contains only formatting characters, or is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Good to merge.
Tiny regex quibble, but it's just a minor performance-related note.
First step, clean up erroneous, missing and/or redundant font declarations which lead to erroneous or redundant mathvariant declarations in the MathML. Typically happens when the appropriate font is not propagated while synthesizing symbols.
Then add classes, like
ltx_mathvariant_italic
, for cases where the mathvariant cannot be handled by remapping the Unicode.Fixes #2021
Fixes #2051