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 · 13 comments
Open

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

RJ722 opened this issue Sep 1, 2019 · 13 comments

Comments

@RJ722
Copy link
Contributor

RJ722 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

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

@ghost
Copy link

ghost 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.

@ghost
Copy link

ghost 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>

@ghost
Copy link

ghost 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.

@ghost ghost self-assigned this Sep 12, 2019
@ghost ghost added the bug label Sep 12, 2019
@RJ722
Copy link
Contributor Author

RJ722 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! :-)

@ghost
Copy link

ghost 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
Copy link
Contributor Author

RJ722 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.

@marek-lach
Copy link

marek-lach commented Nov 11, 2019

You could investigate switching from blackfriday to https://github.com/gomarkdown/markdown which is a compatible fork that is still being maintained and I think actively focused on solving these Markdown rendering issues...

@ghost ghost removed their assignment Jan 7, 2020
@filippodb
Copy link

filippodb commented Feb 12, 2020

I tried to post some mathJax code on my instance but seems it's not working, see my blog:

https://noblogo.org/writefreely/

and it looks even more a mess on the post page:

https://noblogo.org/writefreely/writefreely-supports-latex-via-mathjax

I activated mathjax on the blog and used some code example from this page:

https://www.mathjax.org/#samples

so the results were different and far from what expected...

tried several times but nothing worked.

@ghost
Copy link

ghost commented Feb 12, 2020

@filippodb is this your own instance? If so what version are you running? You may be experiencing the issue with mathjax not being included #176 if you did not install it manually, this was fixed for v0.10 afaik (see comment). I think that was a manual intervention though so later versions might still be affected.

There is a PR open to address the underlying issue #181.

@filippodb
Copy link

filippodb commented Feb 20, 2020

sorry for the late reply, I didn't expect some questions as the instance noblogo.org is hosted by writefreely on writefreely.host so it has the latest build: 0.11.2 and mathjax is far from working.

@alexcpn
Copy link

alexcpn commented Mar 4, 2020

@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>

This woked perfect ; Here is an example with and without
https://write.as/manlearning/test-mathjx

@milenacrdas
Copy link

milenacrdas commented May 7, 2020

when will the bug be fixed?

@wasanpuzzl
Copy link

wasanpuzzl commented Dec 9, 2020

I'm sorry suddenly, About setting of "Text Rendering (Customize how plain text renders on your blog.)"
"Markdown" that I want to turn off. (Let me set it. It is enough if I can use HTML notation only.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants