-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support MathJax for chat messages! #1945
Comments
Thanks for the feature request - agreed this would be very cool. What On 10/08/2016 19:38, Jesse Maes wrote:
|
I'm definitely most used to seeing TeX notation for inline math. As far as I know it's the most commonly used and versatile of those three - I've never found anything it couldn't write down. It's also the only one I've used though, so maybe I'm biased there. |
As a CS student with a friend circle of massively nerdy people (math, physics, programming etc) I certainly would have some uses for this, although it's by no means critical. +1 for TeX |
As a DSP engineer I would much appreciate this feature, as sharing math with remote co-workers and friends has been rather painful for a long time. |
So... When are we going to have it? :) |
It could be worthwhile looking into Khan Academy's KaTeX as a speedy, lightweight alternative to MathJax. |
As far as encoding the math in the message event goes, I think that it makes sense to send it as MathML (obviously in a Pros of sending MathML as opposed to sending the raw LaTeX wrapped in an element:
Cons of sending MathML:
This would all also depend on what can be used to do math on iOS and Android. Note: MathML allows embedding the original LaTeX source via annotations (BTW, a note about KaTeX: it is much faster than MathJax, but also doesn't support as much LaTeX as MathJax does. What we do on our site at work is that for each chunk of math, we first run it through KaTeX, and if it errors, then we run MathJax on it.) |
Robotics engineer here, yes please! LaTeX as default would definitely be most sensible I reckon; I don't think any of my colleagues know MathML or ASCIImath. Every single one knows LaTeX. |
As a CS researcher, I would highly appreciate this feature. Including math formulas in our daily conversations is very common among my colleagues. It would be nice if we could do it instantly in chat flow. |
I would love to see this! |
I would too!!!! But we have no choice but throw ourselves on the generousity and creativity of the internetz for this one... Patches welcome!!! |
Just throwing a possible dep: https://www.npmjs.com/package/react-mathjax |
I made a proof of concept where the client renders math formulas between Ideally, there should be a room-specific option for turning this on and off (probably off by default), and for specifying different delimiters, but I don't know how to do that. I was also playing with the idea that the sender generates an already formatted message ( |
From an inter-client compatibility standpoint transforming to html on the way out makes sense to me? In that if (not riot) client B can render html then if riot with KaTeX sends html it will display as html and not latex source. |
@Cadair for consistency the HTML transform is always done by the sender |
@t3chguy sure, that makes sense. @hgustafsson was saying that that approach isn't working. |
yeah, currently the subset of allowed HTML is very strict, it may need to be loosened or another format being added to support it, currently the format is a custom html one, adding another would be pretty simple |
@Cadair @t3chguy I agree that this would be the best, but all markup was removed by the html sanitizer. I'm not confident enough with the security implications to change the allowed tags and attributes in The result of, for example, <span class="katex-display">
<span class="katex">
<span class="katex-mathml">
<math><semantics><mrow><mi>cos</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">\cos(x)</annotation></semantics></math>
</span>
<span class="katex-html" aria-hidden="true">
<span class="strut" style="height: 0.75em;"></span>
<span class="strut bottom" style="height: 1em; vertical-align: -0.25em;"></span>
<span class="base">
<span class="mop">cos</span>
<span class="mopen">(</span>
<span class="mord mathit">x</span>
<span class="mclose">)</span>
</span>
</span>
</span>
</span> Unfortunately, all the work I did in this direction was when |
then make an alternate format which is done client side, formatted_body being the LaTeX formatting and render clientside, assuming that the KaTeX implementation is sane and 100% consistent |
Any progress in it? |
Please don't use KaTeX. |
In my experience, MathJaX covers much more LaTeX than KaTeX does, but KaTeX still covers the vast majority of what most people need. However KaTeX is much faster than MathJaX (though I believe the MathJaX developers have been working on improving speed lately). Also, MathJaX would randomly fail some times when we had a lot of math. So what we did was we rendered math in KaTeX, and if KaTeX was unable to render it, then we fell back to MathJaX. |
My experience matches @uhoreg's, and I would urge whoever ends up developing this to consider using KaTeX by default. KaTeX is much faster, and does not have the annoying reflowing issues. MathJax's performance made it almost unusable on my old Android phone. KaTeX also seems to cover the vast majority of what people normally need (at least in physics and compsci). New commands are constantly being added as the project is very active. |
This issue needs someone to work through all of these things and write out a proposal.
|
I think Tex would ideally be transmitted in its raw format using extensible events. |
While I agree, there is no need to block this on that proposal becoming reality. |
Any updates on LaTeX being supported? |
Here's a demo which compares Katex and Latex performance. Also I think having a delimiter for inputting Latex outside of Markdown mode is unnecessary. Mathquill looks really nice. |
matrix-org/matrix-spec-proposals#2191 is a counter-proposal to matrix-org/matrix-spec-proposals#1722 that uses LaTeX instead of MathML. |
lots of experimentation going on currently on this between @thosgood, @Cadair, myself with input from @uhoreg. Approaches are split between experiments with render-at-receiver-client (matrix-org/matrix-react-sdk#3251), render-at-sender-client, and render-at-sender-mediarepo (or combinations of all 3). Before I lose it, https://jsfiddle.net/8Logkhr5/35/ is a POC for render-at-sender-client via MathJax. |
Sorry to bump this but I was wondering what the status of this feature is at and when we can expect it to land on develop? |
From the user perspective, I would really like to see this feature in develop in the following weeks (my university is using Matrix to chat during lessons). How can I help ? May I rebase matrix-org/matrix-react-sdk#3251 in Another way to render LaTeX is Matrix would be to have a bot uploading the rendered LaTeX but I find this approach non user-friendly. |
I've played around with a bot that responds to messages with the rendered image, but it really wasn't very pleasing to use, as you say. (There was another bot a while back that also did this (much better than mine), but I think the general consensus was that it was not really the best solution to this specific need). If you wish to advance this project a bit more, then I suggest dropping by |
We must decide on a protocol first - #1945 (comment) seems to be nice I agree on the fallback issue - matrix-org/matrix-spec-proposals#1722 (comment) - as for security, we may initially limit their usage to those having proper safeguards, and later roll in extras #1945 (comment) @uhoreg I want to participate in GSoC and would love to contribute towards this issue |
Hi, This is of little relevance for an actual implementation in riot but may be of interest for some people who don't want to wait. Cheers, |
I've mentioned this a bunch of times in the other pull request, but have apparently forgotten to do so here: this test build is actually up and running at https://pigeon.digital , and I think it's currently being used quite a bit, and I haven't had any error complaints so far! Please feel free to use it, but just note that you have to enable KaTeX rendering in your user settings, and make sure that the 'maths' toggle is turned on in the composer. (There are some per-room settings, but these don't do anything). ![Uploading Screenshot 2020-04-12 at 16.22.13.png…]() |
Great! |
wouldn't it be good to make a bot that creates png's to involve bridge users and users with other clients? |
Great! I tried it out on https://pigeon.digital and it worked well, though I was unable to edit a post while keeping the katex formatting. Specifically,
|
@thosgood Any progress on this? pigeon.digital seems down to me. |
@Esokrates For me, this room works. This is where issues are discussed. The good news is that they are close to it! |
The current PR to watch seems to be matrix-org/matrix-react-sdk#5244 |
bump, matrix-org/matrix-react-sdk#5244 has been merged! |
As mentioned above, we now have experimental LaTeX support available via a labs flag on Develop / Nightly builds. 🎉 Please try it out and file new issues with any feedback, as that will help us understand what's left before making this generally available. |
So I just tried it out. For that, I went on https://riot.im/develop/ and I enabled the option by going in See some bugs here #15846 (comment) |
@tobiasBora Element can't load |
@lon91ong check the browser console, either an extension/firewall is blocking something or your browser is missing a required feature. |
Is this not yet available on the desktop client? I'm running element-desktop 1.7.34-1 from the Manjaro repos and I am not able to see this feature anywhere. On the general Matrix chat a user told me that I would be able to manually configure this somewhere, in a config file, but I can't seem to find where. |
This is implemented but experimental therefore you need to enable it in a config file. Feel free to ask in the Element Web/Desktop room for help with that |
It would also be very cool to have it for the ios-app. |
Any idea how to use this feature in 2022? The url https://riot.im/develop/ does not exist anymore and this feature does not appear in the experimental features (labs) in https://app.element.io/: I can only see "Threads" and "The new search". |
riot.im/develop is now develop.element.io |
This is a feature request, which I'll admit is probably not too important for most users.
I think it would be really amazing if text in between
$dollar signs$
could be rendered as inline math formulas using MathJax, similar to what you see on some of the stackexchange sites. It's also common to use$$double dollar signs$$
to denote full equation blocks.This may obe an easy addition, seeing as markdown is already supported. With names like "matrix" and "vector", there's bound to be at least a small subset of users who actually use this chat client to talk about math! It's hopefully at least worth considering, anyway.
The text was updated successfully, but these errors were encountered: