Skip to content
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

feat(math): Support the MathML operator dictionary and many TeX-like aliases #2167

Merged
merged 15 commits into from
Nov 23, 2024

Conversation

Omikhleia
Copy link
Member

@Omikhleia Omikhleia commented Nov 14, 2024

WIP for now, still things to check and fix, but most of the stuff is starting to work well... So it's good "saving checkpoint" to share.

Good to go, IMHO 🚀

First commit

  • Lots of refactoring in the atom / types logic... and some code clean-up.
  • The operator dictionary table (for MathML), and most of the TeX-like commands (for that syntax), are now based on the W3C xml-entities unicode.xml with the diff patch from this issue applied.1
    • It ticks yet another checkbox in Math operators: stretchy or not stretchy #2148 🐱
    • Lots of "big"-operators and extra integrals are now supported
      Eg. \coprod, \bigcupdot, \intclockwise and all their friends do the expect magic.
    • Lots of additional TeX-like commands (\circ, \pod, etc. to just mention a few) are supported.
    • More "stretchy" operators work (... but not all yet, and proper support for accents will come later....)
    • "form" attribute on MathML mo and a first take at "embellished" operators (paving the way for another checkbox in Epic: Unsupported MathML elements and attributes #2138 eventually, though we are not there yet...)

Subsequent commits

Ah, the operator table makes many things better, but others are worse...

  • fix(math): Spacing rules must distinguish binary and unary operators --> Needed consequence of making the minus-hyphen (U+002D) equivalent to the minus sign (U+2212) for math purposes. An occasion to also kill an old issue...
  • fix(math): The (escaped) percent is an ordinary atom in TeX-like syntax --> The former behavior had it encoded as a binary operator, it's now aligned with what (La)TeX would produce.
  • fix(math): A period must be allowed in TeX-like math syntax for numbers --> Decimals 0.123 later seen as <mn>0.123</mn> instead of <mn>0</mn><mo>.</mo><mn>123</mn> (with period as punctuation in MathML, possibly affecting spacing)
  • Some tests have been re-aligned / cleaned after analysis = all math tests are passing again.

Then..

  • fix(math): Improve spacing rules on limit-like operators --> Includes a refactor...
  • ... and more refactoring follows on those atom types with too many names ^^ = KISS 😽 a thing shall have one name only.
  • feat(math): Add pre-defined TeX-like operator functions (cos, sin, etc.) --> Bonus cake 🍰
  • docs(math): Update description of atoms and TeX-like pre-defined constructs

Issues addressed

Closes #1642

Closes #2169

Parts of some other issues are mentioned above. We're getting closer.

Footnotes

  1. The converter/extractor (in XSLT 1.0 i.e. xsltproc-compatible) from unicode.xml to our Lua structures is included too in the PR.

@Omikhleia Omikhleia added the enhancement Software improvement or feature request label Nov 14, 2024
@Omikhleia Omikhleia self-assigned this Nov 14, 2024
@Omikhleia Omikhleia requested a review from a team as a code owner November 14, 2024 01:00
@Omikhleia Omikhleia marked this pull request as draft November 14, 2024 01:06
@Omikhleia Omikhleia added this to the v0.15.7 milestone Nov 14, 2024
@Omikhleia Omikhleia force-pushed the feat-operator-table branch 2 times, most recently from 73d745a to 91a69bc Compare November 16, 2024 17:55
packages/math/atoms.lua Outdated Show resolved Hide resolved
@Omikhleia Omikhleia marked this pull request as ready for review November 16, 2024 22:19
@Omikhleia Omikhleia requested a review from alerque as a code owner November 16, 2024 22:19
@Omikhleia
Copy link
Member Author

@alerque Good for review, in my opinion.
I have a few other commits that build upon this nice baby, but they are more controversial and I'll likely open dedicated issues before pushing a proposal.

@Omikhleia Omikhleia marked this pull request as draft November 17, 2024 12:22
@Omikhleia
Copy link
Member Author

Omikhleia commented Nov 17, 2024

@alerque Good for review, in my opinion. I have a few other commits that build upon this nice baby, but they are more controversial and I'll likely open dedicated issues before pushing a proposal.

Oh wait, on a second thought (when I annotated the "unused" atom types above...) I just realized we can clear it up a bit here, with a good gain: bigOperator is ill-named from the start, it's corresponding to TeX mathop (with respect to spacing rules) and all of a sudden something becomes much clearer.

packages/math/atoms.lua Outdated Show resolved Hide resolved
@Omikhleia Omikhleia marked this pull request as ready for review November 17, 2024 18:41
@Omikhleia
Copy link
Member Author

Now this is much better, with bonus cakes 🍰 and tests 🧪

…erator

In TeX, `\%` is a regular ("ord") atom. The test assumed it was
a binary ("bin") operator. Let's wrap it into a `<mo atom="bin">`
for the same result (i.e. surrounding spacing).
…onary

The MathML code was using U29F5 (reverse solidus), and the supposedly
identical TeX-like code uses "setminus", which formerly mapped it to
the reverse solidus. It was changed in unicode-math in 2023 to correctly
map to U2216 - and our new operator dictionary table follows that
change. So the test is adapted to use U2216 too now, and the test
results also need to be regenerated.
On that occasion, the MathML code is also ajusted to use `<mrow>`
elements in sub-expressions, so the sizes of parentheses is in line
with the TeX-line examples.
Including another small refactor / clarification on our atom types.
We had too many intermediary types (TeX's names mathxxx, our shorthands,
internal values). We got rid from the TeX's math-prefixed named in our
new table of symbols and operators, but it was still confusing.
@alerque alerque force-pushed the feat-operator-table branch from 0d1a3ea to d5b432d Compare November 18, 2024 19:28
@alerque
Copy link
Member

alerque commented Nov 18, 2024

Force push so far just to fix Lua style (BTW stylua 2.0.0 has been released that works with this project's style options). No chance for deeper review yet.

@alerque alerque force-pushed the feat-operator-table branch from d1ff17e to 48c2011 Compare November 23, 2024 13:20
@alerque alerque enabled auto-merge November 23, 2024 13:29
@alerque alerque merged commit f0ddaed into sile-typesetter:master Nov 23, 2024
21 checks passed
@Omikhleia Omikhleia deleted the feat-operator-table branch November 23, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement or feature request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Outdated math example in user manual 0.15.6 binary/unary operator in TeX-like math mode
2 participants