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

Implement a subset of mathvariants #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rrrnld
Copy link

@rrrnld rrrnld commented Jan 17, 2022

This pull request implements a subset of MathML's allowed mathvariants. They are implemented with maximum compatibility in mind, so anything that was converted by mathml2latex before continues to be converted as is.

The attribute is implemented for all elements that support it directly as per https://developer.mozilla.org/en-US/docs/Web/MathML/Element. mstyle is not handled, mspace neither (because the implementation at the moment always returns an empty string anyways).

Please note that some mathvariants are left unimplemented: https://w3c.github.io/mathml-core/#dfn-mathvariant. This is done to minimize unexpected outcomes. While you could convert bold-fraktur for example, this wouldn't be rendered correctly in some environments (e.g. Katex). An implementation independent of target-environment might require major changes to the library as far as I can tell.

@rrrnld
Copy link
Author

rrrnld commented Jan 24, 2022

I have created a test suite to get a better visual impression what my PR does, in addition to the tests running on the command line. You can find a gist containing all tests here. The index.html can be placed into lib and served using a web server (for example python3 -m http.server -d lib).

it reimplements a subset of the MathML Test Suite (Main → Testsuite → Characters → Variants) and renders the output of mathml2latex via Katex. This is the result for me in Firefox 96:

Without my patch:
image

With my patch:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants