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

Rendering issues in MathJax when nested with markdown symbols (*, _) #177

Open
RJ722 opened this issue Sep 1, 2019 · 6 comments

Comments

@RJ722
Copy link

commented Sep 1, 2019

Describe the bug

When symbols like *, _ are nested with the $ symbol, or are used in the same line as math, MathJax does not render them properly.

Steps to reproduce (if necessary)

Steps to reproduce the behavior:

Rendering issues can be seen in the following examples:

.. $ X_1 \in  Y_1 $ ...

... $ X_1 $ and  $ Y_1 $ ... 

... $ X \& Y $ (`$ X \& Y $`) (There is a box enclosing the characters - not sure if it's a feature or a bug.

... $ x*y*z $ ...

$$ x_1 = y_1 $$

Here is a live example . Also, I've attached a screenshot:
Screen Shot 2019-09-01 at 9 49 39 PM

Expected behavior

What should've happened?

Application configuration

  • Single mode or Multi-user mode? Multi-user
  • Database? mysql
  • Open registration? no
  • Federation enabled? yes

Version or last commit:
v0.10.0

@robjloranger

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

Just getting some ideas here.

There are a few hacks we could employ, but maybe we should consider moving to Blackfriday with blackfriday-latex. Although that extension hasn't been updated in the last year.

@robjloranger

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

@RJ722 if you could try wrapping the section of your post containing math in a paragraph tag, I would be interested if things then work as expected.

I.e. <p>...math stuff and talking about math ..</p>

@robjloranger

This comment has been minimized.

Copy link
Member

commented Sep 12, 2019

@thebaer I think the issue here is that our markdown processor is breaking the math blocks.

I will see if blackfriday supports skipping these, if not I think the best way would be to write a blackfriday extension that does exactly that. It shouldn't be too much work as we know what our inline and display delimiters are.

@robjloranger robjloranger self-assigned this Sep 12, 2019

@robjloranger robjloranger added the bug label Sep 12, 2019

@RJ722

This comment has been minimized.

Copy link
Author

commented Sep 12, 2019

Hi @robjloranger, thanks for the response. I currently don't have access to the blog instance, so can't help you out there. 😅


I haven't used blackfriday-latex before, but it looks like it isn't being actively developed right now. Also, since MathJax is so hugely popular, we can expect folks to be more familiar with it's syntax and ask for it's support, which is why I was wondering how complicated the patch for the current thing would look like? If it isn't too much, I would vote for continuing support with MathJax.

Again, thank you for building this wonderful tool! :-)

@robjloranger

This comment has been minimized.

Copy link
Member

commented Sep 12, 2019

No problem, I confirmed that this does seem to fix the problem but introduces a new one. Markdown is then rendered as literal text.

I think our best bet is to parse the post body before rendering the markdown. Whether that is with an extension of blackfriday or our own in house solution, it will not change the MathJax behavior.


This would probably involve parsing the body and wrapping MathJax notation in a span with a class like md-ignore or something, and then having the markdown renderer skip over the contents of those spans as it does with paragraph tags.

@RJ722

This comment has been minimized.

Copy link
Author

commented Sep 12, 2019

I think our best bet is to parse the post body before rendering the markdown. Whether that is with an extension of blackfriday or our own in house solution, it will not change the MathJax behavior.

Ahh, that cleared up my confusion, thanks!

This would probably involve parsing the body and wrapping MathJax notation in a span with a class like md-ignore or something, and then having the markdown renderer skip over the contents of those spans as it does with paragraph tags.

Yeah, that makes total sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.