content icon indicating copy to clipboard operation
content copied to clipboard

Add text-transform: math-auto

Open zhangenming opened this issue 1 year ago • 8 comments

Description

Motivation

It's mentioned below but it's not here so I think it's missing

Additional details

Related issues and pull requests

zhangenming avatar Aug 21 '24 02:08 zhangenming

Preview URLs

External URLs (1)

URL: /en-US/docs/Web/CSS/text-transform Title: text-transform

(comment last updated: 2024-09-11 19:40:33)

github-actions[bot] avatar Aug 21 '24 02:08 github-actions[bot]

https://drafts.csswg.org/css-text/#intro

But according to the full text of the specification there is no mention of this option so I want to know what is going on thanks

Or do I need to remove this option

zhangenming avatar Aug 21 '24 02:08 zhangenming

If math-auto is not in the specification, maybe we should give a hint

zhangenming avatar Aug 21 '24 03:08 zhangenming

When I said "examples" I meant an example on this page, but interactive examples are of course welcome :)

Could you update the values list right below this code too? And an example section.

Josh-Cena avatar Aug 21 '24 06:08 Josh-Cena

I'm not confident that I can guarantee that the addition to the example will be appropriate

zhangenming avatar Aug 21 '24 07:08 zhangenming

Maybe check https://w3c.github.io/mathml-core/#new-text-transform-values? The idea is to map normal ASCII letters to math italic characters.

Josh-Cena avatar Aug 21 '24 16:08 Josh-Cena

i can't Not sure what to do need more help

zhangenming avatar Aug 22 '24 01:08 zhangenming

I originally conceived of the following example:

<div>
  (sin&hairsp;<span>x</span>)<sup>2</sup> + (cos&hairsp;<span>x</span>)<sup>2</sup> = 1
</div>
div {
  text-transform: math-auto;
}

But in fact, using proper MathML markup, we get the same result out of the box:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <semantics>
    <mrow>
      <mo stretchy="false">(</mo>
      <mo lspace="0em" rspace="0em">sin</mo>
      <mspace width="0.16666666666666666em"></mspace>
      <mi>x</mi>
      <msup>
        <mo stretchy="false">)</mo>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mo stretchy="false">(</mo>
      <mo lspace="0em" rspace="0em">cos</mo>
      <mspace width="0.16666666666666666em"></mspace>
      <mi>x</mi>
      <msup>
        <mo stretchy="false">)</mo>
        <mn>2</mn>
      </msup>
      <mo>=</mo>
      <mn>1</mn>
    </mrow>
    <annotation encoding="TeX">(\sin\,x)^2+(\cos\,x)^2=1</annotation>
  </semantics>
</math>

@fred-wang What is the intended use case of text-transform: math-auto, outside of being able to specify mi?

Josh-Cena avatar Aug 22 '24 01:08 Josh-Cena

@Josh-Cena This italicization is something defined in MathML 3, when we wrote MathML Core it was suggested to expose the internal magic, so this is essentially what this CSS text-transform value is doing. I imagine, this could be used for italicization in math markup using HTML markup only, or to easily cancel italicization on single-char mi, but not sure these are strong use cases.

fred-wang avatar Sep 02 '24 07:09 fred-wang

Yes, I imagined that this was implemented only so that MathML rendering can reuse CSS machinery, but it seems there's no real use case that can't be solved using MathML natively?

Josh-Cena avatar Sep 02 '24 14:09 Josh-Cena

@Josh-Cena right, I'm not really aware of other use cases.

fred-wang avatar Sep 02 '24 14:09 fred-wang

I've added some description and an example based on my understanding. @fred-wang Could you review? Thanks!

Josh-Cena avatar Sep 02 '24 14:09 Josh-Cena