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

AsciiMath doesn't use the correct display style #2520

Closed
dpvc opened this issue Sep 3, 2020 · 4 comments
Closed

AsciiMath doesn't use the correct display style #2520

dpvc opened this issue Sep 3, 2020 · 4 comments
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Milestone

Comments

@dpvc
Copy link
Member

dpvc commented Sep 3, 2020

AsciiMath in v3 doesn't seem to set the inherited properties correctly, as the output is in inline-mode rather than the displaystyle that is the default, despite the fact that there is an mstyle that sets the displaystyle attribute properly. Something in the translation from the old internal MathML to the new is going wrong.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate v3 labels Sep 3, 2020
@dpvc dpvc self-assigned this Sep 4, 2020
@dpvc dpvc removed their assignment Sep 4, 2020
@dpvc dpvc added this to the 3.1.1 milestone Sep 4, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Sep 12, 2020
Handle AsciiMath configuration properly, in particular, displaystyle.  (mathjax/MathJax#2520)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Sep 12, 2020
@dpvc dpvc added Fixed v3.1 and removed Merged Merged into develop branch labels Nov 30, 2020
@dpvc dpvc closed this as completed Nov 30, 2020
@DanielJGeiger
Copy link

In some sense this bug remains. I am using MathJax 3.2.0 in Excalidraw PR #2993. AsciiMath always renders in display mode, disregarding the display option.

I tried changing displaystyle: true to displaystyle: false in js/input/asciimath/mathjax2/legacy/jax/input/AsciiMath/config.js. Then some scripts in MathJax-demos-node would respect the display option. But some would not.

@dpvc Any suggestions where to check for the real culprit? I would gladly submit a bugfix PR once a proper solution is found.

@dpvc
Copy link
Member Author

dpvc commented May 16, 2022

@DanielJGeiger, the following file:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<title>AsciiMath configuration</title>
<script>
MathJax = {
  loader: {load: ['input/asciimath', 'output/chtml']},
  asciimath: {displaystyle: false}
}
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js"></script>
</head>
<body>

`sum_{n=0}^infty xn`

</body>
</html>

produces

asciimath-non-display

for me, while switching display to true produces

asciimath-display

so the display option does seem to work for me.

My only suggestion is that the configuration is not being read, which means either it is not being inserted into the page, or it is added after MathJax already starts up, in which case it won't have any effect. I looked at the PR you linked to, but could not find the configuration at all, nor any calls to MathJax, so I wasn't able to figure out what was wrong.

@DanielJGeiger
Copy link

@DanielJGeiger, the following file:

@dpvc Thanks. That example falls into one of the cases where I have seen the display option work. The script direct/am2chtml is an example from MathJax-demos-node where it does not work, unless I make the change mentioned earlier.

My only suggestion is that the configuration is not being read, which means either it is not being inserted into the page, or it is added after MathJax already starts up, in which case it won't have any effect. I looked at the PR you linked to, but could not find the configuration at all, nor any calls to MathJax, so I wasn't able to figure out what was wrong.

My apologies. The relevant file in the linked PR is src/textlike/math/index.tsx, and the relevant method is loadMathJax.

@dpvc
Copy link
Member Author

dpvc commented May 17, 2022

OK, I think I was not understanding the issue properly. It isn't the AsciiMath displaystyle configuration option that isn't working, it is the display option of the MathDocument's convert() method that you are complaining about.

Because AsciiMath doesn't actually have both display and non-display modes (it always uses wither one or the other based on the displaystyle document configuration option), the display option to convert() has no effect for AsciiMath. You are correct in pointing that out.

It is possible, however, to switch the global mode in the AsciiMath input jax using

MathJax.InputJax.AsciiMath.AM.Augment({displaystyle: false});

(or true), so you could modify this line to include that. Or perhaps better would be to subclass AsciiMath and insert it there. Something like

class MyAsciiMath<N, T, D> extends AsciiMath<N, T, D> {
  public compile(math: MathItem<N, T, D>, document: MathDocument<N, T, D>) {
    MathJax.InputJax.AsciiMath.AM.Augment({displaystyle: math.display});
    return super.Compile(math, document);
  }
}

so that convert() will do this automatically based on the display option.

@dpvc dpvc added the Code Example Contains an illustrative code example, solution, or work-around label May 17, 2022
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 Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants