Closed bkardell closed 5 months ago
I wonder whether it would be possible to modify the current proposal to also say
"If the specified value of text-transform is math-auto and the inherited is not none then computed value is the inherited value"
that is
<div><div style="text-transform: math-auto">sin</div></div>
<div><div style="text-transform: math-auto">x</div>
<div style="text-transform: math-fraktur">
<div style="text-transform: math-auto">x</div>
</div>
would respectively produce upright sin, slanted x and fraktur x. This would allow to implement MathML's behavior
<math><mi>sin</mi></math>
<math><mi>x</mi></math>
<math mathvariant="fraktur"><mi>x</mi></math>
without tweaking too much the UA stylesheet.
cc @faceless2
This would be easily doable with a custom TextTransform::ApplyValue (chromium):
void TextTransform::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
auto text_transform = To
This is following on from https://github.com/mathml-refresh/mathml/issues/204. The solution proposed there is to have the following in the UA stylesheet:
mi {
text-transform: math-auto;
}
*[mathvariant] mi {
text-transform: none;
}
But that only works if the "mathvariant" attribute is used to set the transform (the "mathvariant" attribute is a presentational hint that sets text-transform
with a specificity of [author,0]). If the transform is set directly CSS using text-transform
, as you've done with the <div>
in the first block of examples, it won't work, which I presume is why you're proposing this approach?
Well, we could certainly implement it, it would fix the problem and I don't think it would break anything else - so it works for me, although we're the smallest fish in this particular pond.
@rwlbuis thanks! @faceless2 Yes, I'd prefer to have a purely CSS approach which works in other context if possible, rather than introducing a MathML-specific rule in the UA sheet.
I haven't checked, but think this is also how Gecko's internal -moz-mathvariant CSS property implements the auto italic.
OK, I tentatively added the special case for math-auto to the proposal so that it can be discussed in the CSSWG meeting.
The CSS Working Group just discussed text-transform values for MathML
, and agreed to the following:
RESOLVED: Add math-auto to text-transform
Similar to what @fantasai said in https://github.com/w3c/csswg-drafts/issues/5389#issuecomment-694361232 ; I've also been wondering whether the word "italic" should be in included in the math-auto name.
Can we make sure this gets edited into the spec @fred-wang / @fantasai? It's weird to implement things that aren't yet on a draft...
@emilio My reply is the same as https://github.com/w3c/csswg-drafts/issues/5389#issuecomment-1015306703
This is now defined in https://w3c.github.io/mathml-core/#new-text-transform-values. Once that gets republished to TR, we probably should just add a reference to it from css-text. Given the specialized use-case, it seems best for this to live in the MATHML spec.
Alright, so the math-auto
value is now defined in MathML, while css-text covers the grammar and has a cross reference to MathML for the definition of the value. We can always revisit this later if we'd prefer a different arrangement, but for now, this seems solved.
(Part of #5384 - MathML Core related CSS)
Note: This was previously introduced last year, given the noise and confusion generated, I am opening a new issue to hopefully explain and answer questions more directly (you don't need the background of these issues, it would take some time to consume them and they are incomplete, but they are #3745 and a larger topic on text-transforms, design and theory in #3775)
Background
The rendering of mathematical text employs common conventions that allow authors to express and readers to understand their meaning. Sometimes this involves how they are laid out, but often it is in the particulars of character's rendering. To this end, Unicode defines a range for Mathematical Alphanumeric Symbols and particular stylistic variants which can convey additional local contextual value and convey meaning. As one example: it is possible for an equation to employ two variants of the same character representing different things, as in the example below from Unicode of a well known equation requiring this. At the top is how it is intended to be understood, with distinctly rendered H's and below is how it would be (incorrectly/confusingly) be understood without this distinction.
This is quite a complex topic for a wide range of reasons and various distinctions can be more or less important at various levels. Because of this, Unicode has added support for thousands of numerical 'symbols', including invisibles, allowing decent encoding of mathematics as text with its own 'alphabet', even where there is look-alike overlap, for example, Mathematical sigmas are not the same as related Greek letters despite their recognizable appearance in much the same way that in everyday text
O
and0
or1
andl
are distinct characters, and their applications and have various uses/treatments (see https://en.wikipedia.org/wiki/Sigma#Science_and_mathematics and https://en.wikipedia.org/wiki/Sigma#Mathematical_Sigma)Why transforms?
MathML offered structure and markup oriented solutions which didn't require access to characters in Plane 1 of Unicode. In a very general way, the structures provided by MathML are useful in that they fit the DOM/markup model, allow styling, and you can thus lay good default rules upon them: Single character identifiers (
<mi>
) for example are rendered as italics by default according to normal conventions. Thus, the following MathML...Would render with the identifiers
x
andy
as italic mathematical identifiers as:MathML allows that you can override these as necessary or provide the additional distinctions. Because of where it fits in history, MathML co-evolved a solution of overiding by providing an attribute called
mathvariant
which allowed values of what are now the Unicode variant names. For example, if we want to express an equation about a real number alaThe Fraktur R is in Plane 1. In addition to allowing authors to eventually use the unicode character (
ℜ
), MathML historically provided themathvariant
allowing authors (and tools) to express this asAs in the example from Unicode (provided in Backgound) above, this may, or may not be critically significant for a given case - but it is important that this distinction is maintained as text as much as possible for copy/paste operations or for speech subsystems. While the spec recommends that authors use the unicode characters directly where it is important, since a large corpus of millions of MathML equations exist, and numerous tools for creating it currently rely on understanding the
mathvariant
attribute, it must be maintained and supported.Based on 3 implementations experience, MathML-Core accomplshes this largely by mapping this legacy attribute to CSS's infrastructure and
text-transform values
.The specifics
MathML-Core largely codifies the mapping and seeks to expose this to authors and increase interoperability, it extends CSS Text L3 with new values for
text-transform
that play this role in mapping alphanumeric text to the equivalent Mathematical Alphanumeric Symbols asmath-auto
is the default value for text-transform of MathML elements. It follows convention and automatically renders single letter identifiers with mathematical italics, and others normally.Proposal details at https://mathml-refresh.github.io/mathml-core/#new-text-transform-values Tentative tests are at https://github.com/web-platform-tests/wpt/pull/16922