Adding Maths support for Chat

AI-generated summary

The discussion revolves around the addition of math support in Discourse Chat. Anton_Akhmerov reported that math rendering is not working in chat, despite being correctly rendered in post previews and posts. Alexander suggested that Discourse Chat uses a different rendering method, which might not support all Markdown features. However, Anton_Akhmerov found a previous discussion indicating that it is a supported feature.

The conversation was moved to the #feature request category by Falco, as enabling plugins in chat requires planning, writing, and testing.

joffreyjaffeux pushed support for math rendering in chat, but noted that the plugin would need multiple changes to avoid jumpiness. panic pointed out that the current implementation only works for MathJax, and joffreyjaffeux agreed that a patch for KaTeX is needed, which is currently pending in a pull request.

I have a recently upgraded discourse instance (discourse 92bb728fe5, discourse-math f9cf94d2). I have configured discourse-math to use katex, but the problem appears with mathjax too. I observe that math is rendered correctly in post previews, in posts themselves, but not in chats. Below are the screenshots:



image

2 Likes

I may be wrong, but I think that Discourse Chat does not use the same “rendering method” as in topics and posts, I haven’t tested it well but I think it barely supports some features of Markdown

This was a topic of discussion before, and judging by the responses it is a supported feature.

1 Like

Moved to Contribute > Feature request as enabling each Customization > Plugin or Customization > Theme component in chat is a new feature that needs to be planned, written and tested as we don’t automatically apply all the same markdown cooking of posts.

8 Likes

I pushed support for this in chat:

https://github.com/discourse/discourse-math/commit/6f59c4691239223d20e0723918375b0a3ac6ede0

This plugin would need multiple changes to avoid jumpyness, but that will have to wait.

9 Likes

It seems that it only works for MathJax. Maybe we need another patch for KaTeX?

1 Like

Indeed, that should do it:

https://github.com/discourse/discourse-math/pull/88

Will merge it next week.

3 Likes