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

Processing \$ 123 \$ results in an unattended result. #3330

Closed
small-lovely-cat opened this issue Feb 11, 2025 · 2 comments
Closed

Processing \$ 123 \$ results in an unattended result. #3330

small-lovely-cat opened this issue Feb 11, 2025 · 2 comments
Labels
Expected Behavior This is how MathJax works

Comments

@small-lovely-cat
Copy link

small-lovely-cat commented Feb 11, 2025

Issue Summary

When trying to process \$ 123 \$, the renderer returns 123 as inline formula, rather than the attended $123$

Steps to Reproduce:

See above.

Technical details:

The text is first processed by Parsedown (Markdown engine), then Mathjax.

  • MathJax Version: 2.7
  • Client OS: Windows 11 24H2
  • Browser: Edge 133.0.3065.0

I am using the following MathJax configuration:

	MathJax.Hub.Config({ 
		tex2jax: {
			inlineMath: [["$","$"], ['\\(','\\)']],
			processClass: "classToProcess",
			ignoreClass: "classToIgnore",
		},
		skipTags: ['script', 'noscript', 'style', 'textarea', 'pre','code','a'],
		showProcessingMessages: false,
		messageStyle: "none",
		TeX: { equationNumbers: {autoNumber: "AMS"} },
	});

Even when adding processEscapes:true, nothing happened.

and loading MathJax via

<script src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML&noContrib"></script>
@small-lovely-cat
Copy link
Author

It seems that parsedown has some conflicts with mathjax.
Wondering if the problem still exists

@dpvc
Copy link
Member

dpvc commented Feb 11, 2025

Yes, Markdown of any flavor uses backslashes for its own processing (to prevent the usual effect of the following character), and usually that means that the backslash is removed and the following character is inserted into the HTML document without the backslash. That is likely the source of your problem. You might be able to use \\$ in your parsedown source in order to get \$ in the resulting web page (right now, you are just getting a $ without the backslash). You will probably need to add processEscapes: true to the tex2jax section of your configuration as well.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants