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

Set the font-style to normal even for full-width numbers and symbols in Japanese. #3274

Open
insoohyeon opened this issue Aug 21, 2024 · 1 comment
Labels
Accepted Issue has been reproduced by MathJax team v3

Comments

@insoohyeon
Copy link

I am using markdown-it-mathjax3 version 4.3.2 and mathjax-full version 3.2.0.
When I input full-width numbers and symbols in Japanese, they are displayed in italic.
Is there a way to set the font-style to normal for full-width characters, other than forcing it with CSS?
image

<g data-mml-node="math"><g data-mml-node="mi"><text data-variant="italic" transform="scale(1,-1)" font-size="884px" font-family="serif" font-style="italic">2</text></g><g data-mml-node="mi" transform="translate(1000,0)"><text data-variant="italic" transform="scale(1,-1)" font-size="884px" font-family="serif" font-style="italic">x</text></g></g>
@dpvc
Copy link
Member

dpvc commented Aug 23, 2024

For characters that aren't specifically defined as having a meaning in MathJax (like ^ and _), there are two places that determine what TeX class is used: the RANGES list at

https://github.com/mathjax/MathJax-src/blob/8565f9da973238e4c9571a86a4bcb281b1d98d9b/ts/core/MmlTree/OperatorDictionary.ts#L83

and the operator dictionary (OPTABLE) starting at

https://github.com/mathjax/MathJax-src/blob/8565f9da973238e4c9571a86a4bcb281b1d98d9b/ts/core/MmlTree/OperatorDictionary.ts#L171

The RANGES list breaks down the unicode codepoints into groups of characters that are given the same TeX class and what MathML element type to use for them. This is a rough grouping, and is not a perfect mapping of characters to classes, but is meant as a means of getting most things into an acceptable form. This allows, for example, Latin and Greek letters to be put into mi elements, while arrows can be put into mo elements. Since these are broad groups of characters, not every one in these ranges may be properly typed.

In your case, the Halfwidth and Fullwidth forms are marked to be placed in <mi> elements, and a single character in an <mi> is set in italics. One solution would be to refine the RANGES array to make better choices within that Unicode block. An alternative would be to use a TeX pre-filter to map the Fullwidth character to their ASCII equivalents. Another approach would be to create a TeX extension that defines the characters in this range to give them the correct MathML elements and attributes.

Unfortunately, markdown-it-mathjax3 does provide enough configuration options to be able to patch this without modifying the code. Are you willing to modify either the markdown-it-mathjax3 index.ts file (and recompile it)? If so, I should be able to tell you what you need to do.

As a workaround for now, you could use \text{...} around these characters, which will cause them to be rendered as you would like.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team v3 labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team v3
Projects
None yet
Development

No branches or pull requests

2 participants