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

mathjax_config ignored #263

Closed
asmeurer opened this issue Oct 8, 2020 · 11 comments · Fixed by #390
Closed

mathjax_config ignored #263

asmeurer opened this issue Oct 8, 2020 · 11 comments · Fixed by #390
Labels
more-info-required More information is required to fix the issue

Comments

@asmeurer
Copy link
Contributor

asmeurer commented Oct 8, 2020

Describe the bug

Something between 0.11.2 and 0.12.1 broke the reading of mathjax_config in conf.py. This broke the math rendering in my document. See Quansight-Labs/ndindex#89.

To Reproduce

Steps to reproduce the behavior:

Build the ndindex docs with Myst 0.11.2 and 0.12.1 and compare slices.html. When built with 0.12.1, the math does not render. This is because the MathJax config is not read correctly. See Quansight-Labs/ndindex@e88befd#diff-67d11508f54b1191e72d9abd23652cbe, which is the difference in the file.

Expected behavior

The ndindex repo is here https://github.com/Quansight/ndindex

@asmeurer asmeurer added the bug Something isn't working label Oct 8, 2020
@asmeurer
Copy link
Contributor Author

Any updates on this? I just tested the master branch, and this is still an issue. I've been pinning myst-parser to 0.11.2 because of this.

@chrisjsewell
Copy link
Member

Have you read https://myst-parser.readthedocs.io/en/latest/using/syntax.html#mathjax-and-math-parsing?
and could you give an example of a snippet from the source (markdown) file that is no longer rendering correctly thanks

@asmeurer
Copy link
Contributor Author

Wait, this behavior is intentional? I guess I can fix this by adding myst_update_mathjax=False to my conf.py. But I don't understand why myst does this. The page you reference says:

Since such parsing is already covered by the plugins above, MyST-Parser disables this behaviour by overriding the mathjax_config['tex2jax'] option with:

That doesn't make any sense to me. Why is myst ignoring the mathjax config? To me it makes more sense for it to reuse the same config as RST by default.

@chrisjsewell
Copy link
Member

Because you should not be relying on MathJax to parse source text; it should be handled by the markdown parser, otherwise you end up with parsing errors, such as faulty escaping, which is exactly why this was introduced.

If you are enclosing you're latex in dollar signs then this should not be an issue.

If you can provide me with some example text then I can tell you whether there should be an issue or not.

@chrisjsewell
Copy link
Member

Why is myst ignoring the mathjax config?

To clarify, it is not ignoring the configuration, it is altering it.
The configuration you added is still there

@asmeurer
Copy link
Contributor Author

I do use dollar signs. I put the reproducer in the OP.

@chrisjsewell
Copy link
Member

It would be really helpful to have a minimal working example of the issue.
That is just not clear to me from the OP

@chrisjsewell
Copy link
Member

I think I see the issue now:

<div style="text-align:center">
<code style="font-size: 16pt;">a[3:5] == ['d', 'e']</code>
$$
\begin{aligned}
\begin{array}{r c c c c c c c}
a = & [\mathtt{\textsf{'}a\textsf{'}}, & \mathtt{\textsf{'}b\textsf{'}}, & \mathtt{\textsf{'}c\textsf{'}}, & \mathtt{\textsf{'}d\textsf{'}}, & \mathtt{\textsf{'}e\textsf{'}}, & \mathtt{\textsf{'}f\textsf{'}}, & \mathtt{\textsf{'}g\textsf{'}}]\\
\color{red}{\text{index}}
    & \color{red}{0\phantom{,}}
    & \color{red}{1\phantom{,}}
    & \color{red}{2\phantom{,}}
    & \color{blue}{3\phantom{,}}
    & \color{blue}{4\phantom{,}}
    & \color{red}{5\phantom{,}}
    & \color{red}{6\phantom{,}}\\
\end{array}
\end{aligned}
$$
</div>

Because it's enclosed in the div, this whole block is just being passed as raw HTML throughout the whole of sphinx, it's never "identified" as latex
For example, if you tried to build this as a PDF all of it would be omitted.

So yes in this case you would need to use myst_update_mathjax=False

@chrisjsewell
Copy link
Member

chrisjsewell commented Dec 19, 2020

Well or just use \[...\] instead of $$...$$ and then mathjax will identify it.

Probably even just removing the dollar signs would work

@chrisjsewell
Copy link
Member

I'd say this is a pretty niche use case (wrapping math in raw html), but one that myst_update_mathjax=False is there to handle

@chrisjsewell
Copy link
Member

Obviously let me know if that helped 🤞

@chrisjsewell chrisjsewell added more-info-required More information is required to fix the issue and removed bug Something isn't working labels Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-info-required More information is required to fix the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants