Skip to content

Supporting calc(100% + 0.333em) in the width attribute of <mpadded> #306

@tmke8

Description

@tmke8

<mpadded> is only really useful for horizontal spacing when it's possible to add something to the width. For example, if one sets lspace on <mpadded> but does not change the width, then the lspace eats into the width of the content.

MathML 3 had the width="+0.333em" notation for this (with + as the prefix) but this was apparently replaced by a new notation in MathML 4, see this example:

<mrow>
  <mi>x</mi>
  <mpadded lspace="0.3em" width="calc(100% +0.6em)">
    <mi>y</mi>
  </mpadded>
  <mi>z</mi>
</mrow>

The problem for MathML Core here is that the 100% here refers to the width of the child, and not to the width of the parent, as is the case in CSS.

But there is actually a solution in CSS, with the newly proposed calc-size function. The following actually works correctly in Chrome (which is the only browser currently implementing calc-size):

<math display="block">
  <mi>x</mi>
  <mpadded lspace="0.16667em" style="width: calc-size(min-content, size + 0.33333em)">
    <mi>sin</mi>
  </mpadded>
  <mi>θ</mi>
</math>

So, I think the spec should be either changed so that:

  1. width on <mpadded> accepts any CSS value (currently only allows length-percentage), so that the new calc-size() can be used there
  2. support for calc(100% + 0.333em) is explicitly hard-coded in the spec and is internally translated to calc-size()
  3. (as David says below) width accepts calc-size() in addition to length-percentage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions