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

Format and clean up MathML #34430

Merged
merged 16 commits into from
Jul 9, 2024
Merged

Format and clean up MathML #34430

merged 16 commits into from
Jul 9, 2024

Conversation

pepelsbey
Copy link
Member

@pepelsbey pepelsbey commented Jun 26, 2024

Description

  • Block-level MathML is marked with display="block"*
  • Inline-level MathML is properly inlined
  • Most of the formulas are annotated
  • Old xmlns attributes are removed
  • Non-typical formatting is cleaned up
  • Prettied also took care of some files I touched

* this will help with styling, but that’s another task.

Motivation

MathML clean-up project.

@pepelsbey pepelsbey requested review from a team as code owners June 26, 2024 14:10
@pepelsbey pepelsbey requested review from fred-wang, sideshowbarker and estelle and removed request for a team June 26, 2024 14:10
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:WebAPI Web API docs Content:JS JavaScript docs Content:Learn Learning area docs Content:SVG SVG docs Content:Media Media docs Content:MathML MathML docs Content:Games Games docs labels Jun 26, 2024
@github-actions github-actions bot added the size/xl [PR only] >1000 LoC changed label Jun 26, 2024
@pepelsbey pepelsbey requested review from dipikabh and bsmth June 26, 2024 14:10
Copy link
Contributor

github-actions bot commented Jun 26, 2024

Preview URLs (88 pages)
Flaws (23)

Note! 83 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/RTCIceCandidateStats/priority
Title: RTCIceCandidateStats: priority property
Flaw count: 1

  • macros:
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Web/API/RTCRtpCodecParameters

URL: /en-US/docs/Web/API/RTCAudioSourceStats
Title: RTCAudioSourceStats
Flaw count: 1

  • macros:
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Web/API/RTCRtpCodecParameters

URL: /en-US/docs/Web/API/RTCAudioSourceStats/totalAudioEnergy
Title: RTCAudioSourceStats: totalAudioEnergy property
Flaw count: 2

  • macros:
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Web/API/RTCRtpCodecParameters
    • /en-US/docs/Web/API/RTCInboundRtpStreamStats/totalAudioEnergy does not exist

URL: /en-US/docs/Web/API/DOMMatrix
Title: DOMMatrix (WebKitCSSMatrix)
Flaw count: 18

  • macros:
    • /en-US/docs/Web/API/DOMMatrix/invertSelf does not exist
    • /en-US/docs/Web/API/DOMMatrix/is2D does not exist
    • /en-US/docs/Web/API/DOMMatrix/multiplySelf does not exist
    • /en-US/docs/Web/API/DOMMatrix/preMultiplySelf does not exist
    • /en-US/docs/Web/API/DOMMatrix/translateSelf does not exist
    • and 13 more flaws omitted

URL: /en-US/docs/Web/API/WebXR_Device_API/Movement_and_motion
Title: Movement, orientation, and motion: A WebXR example
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/XRWebGLLayer/viewport does not exist
External URLs (4)

URL: /en-US/docs/Web/CSS/transform-function/matrix3d
Title: matrix3d()


URL: /en-US/docs/Web/MathML/Element/menclose
Title: <menclose>


URL: /en-US/docs/Web/MathML/Examples/MathML_Pythagorean_Theorem
Title: Proving the Pythagorean theorem

(comment last updated: 2024-07-09 22:11:11)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@Josh-Cena
Copy link
Member

For SVG, there's no better way to hand-adjust the content than to manually write it. But MathML is fully reproducible from the TeX source code, which is conveniently embedded via <annotation>, if you ever hand-adjust it, you are just going to make it out of sync with the TeX. It's the same idea as Mermaid-generated SVGs, which I hope you've never hand-adjusted. The workflow should always be like "write TeX -> plug it into TeXZilla -> paste the output here, with no formatting and everything on the same line".

@pepelsbey
Copy link
Member Author

MathML is fully reproducible from the TeX source code, which is conveniently embedded via <annotation>

I wish that would be the case. In many cases, the <annotation> is missing. Also, when I try to create MathML from TeX or TeX from MathML, tools often fail to convert for various reasons. So, I started to trust the MathML source more than the annotations while working on this task.

@Josh-Cena
Copy link
Member

In many cases, the <annotation> is missing.

We should add them, then, otherwise our capability to edit them is severely limited.

Also, when I try to create MathML from TeX or TeX from MathML, tools often fail to convert for various reasons.

In my experience TeXZilla is very stable. We should recommend it (it's made by @fred-wang).

I still don't think you should edit MathML by hand very often. There are a lot of fine tunings to equations such as kernings, offsets, and use of Unicode symbols that are usually missed if you don't do it algorithmically.

Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few edit suggestions for the prose touched. For the rest, I am deferring to Frédéric Wang's expertise :)

pepelsbey and others added 5 commits July 3, 2024 17:03
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
@Josh-Cena
Copy link
Member

Thanks 👍 I'm happy as long as they are collapsed!

Are the Prettier comments necessary? I don't think Prettier touches XML markup in Markdown.

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the capacity to review other pages (the diff is hard to read on GH and slow to render locally), but I have one suggestion for JS.

@pepelsbey
Copy link
Member Author

Are the Prettier comments necessary? I don't think Prettier touches XML markup in Markdown.

@Josh-Cena Unfortunately, Prettier is trying to replace x_2 with x*2 in annotations, and since they have to be literal to be reproducible, I can’t x\_2 them. So, only ignoring helps.

@Josh-Cena
Copy link
Member

I see.

@mdn mdn deleted a comment from github-actions bot Jul 9, 2024
@mdn mdn deleted a comment from github-actions bot Jul 9, 2024
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied the Math.log1p change to Math.expm1 for consistency. Merge it when you like.

@pepelsbey pepelsbey merged commit 4f263d8 into mdn:main Jul 9, 2024
8 checks passed
@pepelsbey pepelsbey deleted the math-block-inline branch July 9, 2024 22:41
@pepelsbey
Copy link
Member Author

Thank you everyone!

evelinabe pushed a commit to evelinabe/mdn-content that referenced this pull request Jul 12, 2024
* Format and clean up MathML

* Update files/en-us/web/css/transform-function/matrix3d/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Clean up annotations

* Apply suggestions from code review

Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>

* Apply suggestions from code review

Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>

* Apply suggestions from code review

Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>

* Fix annotations

* Collapse block math, add/fix annotations

* Update formula from the spec

* Fix annotations

* Hide annotation from Prettier

* Revert some changes

* Fix exp1m

* Collapse and add annotations

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:Games Games docs Content:JS JavaScript docs Content:Learn Learning area docs Content:MathML MathML docs Content:Media Media docs Content:SVG SVG docs Content:WebAPI Web API docs size/xl [PR only] >1000 LoC changed
4 participants