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

Fixes issue https://github.com/mathjax/MathJax/issues/3120 #1028

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ts/input/tex/TexParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ export default class TexParser {
str = '\\' + str;
}
// These are the cases to handle sub and superscripts.
if (node.attributes.get(TexConstant.Attr.LATEX) === '^' && str !== '^') {
if (node.attributes.get(TexConstant.Attr.LATEX) === '^' &&
str !== '^' && str !== '\\^') {
if (str === '}') {
this.composeBraces(node.childNodes[2]);
} else {
Expand All @@ -572,7 +573,8 @@ export default class TexParser {
}
return;
}
if (node.attributes.get(TexConstant.Attr.LATEX) === '_' && str !== '_') {
if (node.attributes.get(TexConstant.Attr.LATEX) === '_' &&
str !== '_' && str !== '\\_') {
Copy link
Member

Choose a reason for hiding this comment

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

I think you need a similar fix for ^ in line 561 above, in case anyone creates a macro \^ similar to the \_ one.

Copy link
Member Author

Choose a reason for hiding this comment

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

At the moment that can't really happen as latex computation happens after the macro replacement.
But I am not really happy with that anyway, so I've added the case.
PTAL.

if (str === '}') {
this.composeBraces(node.childNodes[1]);
} else {
Expand Down