Skip to content

Consider defining "cramped" as a CSS property? #164

Closed

Description

@fred-wang

cc @rwlbuis @emilio

See https://mathml-refresh.github.io/mathml-core/#cramped-elements and #134

To know if an element is cramped, we basically need to browse the list of ancestors.

We could maybe instead more efficiently handle this by defining cramped style as a boolean CSS property:

  mroot,
  msqrt,
  mfrac > *:n-child(2),
  msub > *n-child(2),
  msubsup > *:n-child(2),
  munderover > *:n-child(2),
  mover[accent="true" i] > *:n-child(2),
  munderover[accent="true" i] > *n-child(3) {
        cramped: true /* bikeshed on the names... */
  }

This will allow people to force cramped style in MathML or their custom layout.

As discussed in #134 and similarly to the discussion with scriptlevel, this assumes we exclude the case when the "accent" property is determined from the operator dictionary / text content of the core operator.

Activity

  1. added
    MathML Core
    need resolution
    need specification update
    need tests
    opentype / tex
    on Oct 30, 2019
  2. NSoiffer commented on Nov 10, 2019

    @NSoiffer
    Contributor

    If we go with my suggestion in #134, the last two lines should be removed and this issue goes away.

  3. fred-wang commented on Nov 12, 2019

    @fred-wang
    Author

    Consensus from 2019/11/11: Remove special case for overscripts.

    This means we can implement it as a CSS property.

    In a previous meeting, @bkardell pointed out that we should explain in English what "cramped" means. Apparently there is one cf definition 2 of https://www.dictionary.com/browse/cramped

  4. changed the title [-]Consider defining a "cramped" as a CSS property?[/-] [+]Consider defining "cramped" as a CSS property?[/+] on Dec 19, 2019
  5. fred-wang commented on Jan 21, 2020

    @fred-wang
    Author

    I simplified a bit the way the definition of cramped is written: https://mathml-refresh.github.io/mathml-core/#dfn-cramped

    • Current definition uses "second in-flow child" so I don't think that works with CSS (we can probably change it, we have the same issue with script-level increment anyway).
    • Current definition does not include (post?)subscripts of mmultiscripts (following Gecko). These are probably more difficult to describe with CSS.

    Anyway, I don't think making cramped a CSS property is something urgent.

  6. fred-wang commented on Mar 13, 2020

    @fred-wang
    Author

    I simplified a bit the way the definition of cramped is written: https://mathml-refresh.github.io/mathml-core/#dfn-cramped

    * Current definition uses "second in-flow child" so I don't think that works with CSS (we can probably change it, we have the same issue with script-level increment anyway).
    
    * Current definition does not include (post?)subscripts of mmultiscripts (following Gecko). These are probably more difficult to describe with CSS.
    

    Anyway, I don't think making cramped a CSS property is something urgent.

    Even if we don't define cramped as a CSS property yet, addressing the two points above would be helpful to make cramped more aligned with the rest of the LayoutNG code.

  7. NSoiffer commented on Mar 23, 2020

    @NSoiffer
    Contributor

    [updated]
    At the MathML core meeting today, there was some confusion (by me and others) about what cramped style is. Looking at TeX, cramped style:

    • only affects super script positioning.
    • is (initially) acquired in a sub script, an accent (in TeX, "math accent" and overline), the denominator in a fraction, and in a sqrt/radical.
    • is inherited once acquired.

    In the meeting, the question arose as to whether multiscripts need to set in a cramped style. I think the answer is "yes", but since multiscripts want to set all of their sub/superscripts at the same vertical offset (respectively), I'm not sure cramped style makes sense for the multiscript superscripts to use a cramped style since they want to be raised a little above normal so that a "+" or other symbol doesn't cause one superscript to shift up but not another. On the other hand, since multiscripts can look at all the scripts, it could set them all in a cramped style if all of them use the same vertical offset. So the answer really comes down to what the layout rules are for multiscripts.

    Note: see #134 (comment) for details on how TeX does cramped computation.

  8. davidcarlisle commented on Mar 23, 2020

    @davidcarlisle
    Collaborator
  9. fred-wang commented on Mar 23, 2020

    @fred-wang
    Author

    Where Gecko changes the cramped style: https://dxr.mozilla.org/mozilla-central/search?q=NS_MATHML_COMPRESSED

    mmultiscripts will definitely use the scriptshiftup parameters for the layout of all the superscripts. However, the question is whether it changes the cramped style for subscripts, and this will then affect how the layout of superscript is done for any descendants (at arbitrary deep level) of these subscripts.

  10. NSoiffer commented on Mar 23, 2020

    @NSoiffer
    Contributor

    I believe that cramped style should be set for the subscripts in multiscripts. Hopefully that is doable as per @fred-wang's idea in the call today.

    After my comment about about looking at all of the children to determine alignment, I looked at the MathML 3 and core specs. One of the few things where MathML 3 says something about layout is that all the sub/superscripts (respectively) are aligned. The core spec respects that, although I think the wording can be improved:

    SubShift (respectively SuperShift) is calculated by taking the maximum of all subshifts (respectively supershifts) of each subscript/superscript pair as described in § 3.4.2.4 Base with subscript and superscript.

    The rest of the section then uses SubShift (respectively SuperShift). The issue I have is that "SubShift" is defined earlier ($3.4.2.3) and this part of the spec redefines it, which can cause confusion. E.g., here's part of the description of layout:

    Place the subscript (respectively superscript) so its alphabetic baseline is shifted away from the alphabetic baseline by SubShift (respectively SuperShift) towards the line-under (respectively line-over).

    It is easy to miss that those value's meaning was changed a screen above. I think using "MaxSubShift" (and "MaxSuperShift") would avoid any confusion. The same is true for "line-ascent" and "line-descent".

    Returning to this issue, I agree that nothing special wrt to superscript positioning and cramped style needs to happen with mmultiscripts -- the initial layout can follow the rules for msubscript. If taking the max among all the children doesn't change the shift amount from a default cramped layout, that's fine.

  11. fred-wang commented on Mar 24, 2020

    @fred-wang
    Author

    Here is an example using ~ and n-th child. We can do the same with color replaced with a cramped property.

    <math>
      <mmultiscripts>
        <mn>01</mn>
        <mi>02</mi>
        <mo>03</mo>
        <mtext>04</mtext>
        <mn>05</mn>
        <mo>06</mo>
        <mtext>07</mtext>
        <mn>08</mn>
        <mi>09</mi>
        <mprescripts/>
        <mo>11</mo>
        <mtext>12</mtext>
        <mn>13</mn>
        <mi>14</mi>
        <mo>15</mo>
        <mtext>16</mtext>
        <mn>17</mn>
        <mi>18</mi>
      </mmultiscripts>
    </math>
    <style>
      mmultiscripts > *:nth-child(even)  {
          color: blue;
      }
      mmultiscripts > mprescripts ~ *:nth-child(even)  {
          color: inherit;
      }
      mmultiscripts > mprescripts ~ *:nth-child(odd)  {
          color: blue;
      }
    </style>
    
  12. 15 remaining items

  13. fred-wang commented on May 22, 2020

    @fred-wang
    Author
  14. removed
    need resolution
    need specification update
    need tests
    on May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MathML Coreopentype / tex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions