-
Notifications
You must be signed in to change notification settings - Fork 380
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
MSC1722: Support for displaying math(s) in messages #1722
Conversation
FWIW, to me, the question of whether to use LaTeX or MathML boils down to: would we rather make clients deal with the potential security nightmare of processing a Turing-complete language, or would we rather use a format that displays horribly for clients that don't understand it? |
MathML should also be listed as a supported input for KaTeX: KaTeX/KaTeX#593 |
That issue seems to be about rendering to MathML, rather than rendering from MathML. I don't see anything about using MathML as an input to KaTeX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the detail into the alternatives here. Based on the information presented, Presentation MathML does seem to be the right answer, I think.
Summarizing some considerations with MathML vs LaTeX:
MathML and LaTeX both have advantages and disadvantages. I think that the answer to which one is the best to use depends on the relative weights assigned to different factors. |
So for fallbacks, I'm strongly inclined to want a thumbnail (optionally) as a fallback mechanism for dumb clients at the risk of it looking a little unclean. That might help solve the ugliness around MathML fallbacks, although admittedly clients need to know to display the fallback (extensible events where art thou?). Looking at the langauges side by side though, I am deeply concerned with how verbose MathML is and it would likely bother folks to have to write a load of XML for a similar string of LaTeX. That's actually quite a major drawback for me as I don't see client's willing to spend a long time implementing complex UIs (at least initially) and this might severely reduce the pacticality of this event. |
Hey @uhoreg, do you have a status update for this? |
I've been focusing on E2E stuff lately. I'll probably try to poke at this again in Feb. |
However, this only works for certain notation when using only the subset of | ||
HTML allowed by Matrix, and requires that users have a font installed that | ||
supports the necessary characters. Most importantly, one cannot write | ||
matrices using this method, and failing to support matrices in a protocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣
What about treating LaTeX as an input method for MathML, in the same vein that markdown is an input method for HTML-formatted messages? |
I am partial towards implementing it at client side. We just transfer the Math as LaTeX which saves bandwidth, and we leave it upto the client whether it wants to render it as Math or just leave it as it it. This way it works at least for those who are used to communicating mathematical expressions regularly.
There are other approaches listed at cben/mathdown/wiki/math-in-markdown, Yihui Xie / 2018-07-22 and one working example at Upmath.me. |
We're not going to debate delimiters in here, because in this part of the Math support, we're not going to be using plain text delimiters. The plain text message format should be left as-is by clients, and the HTML format should use HTML-like tags. If we use embed LaTeX in messages, it will probably be something like Preferring LaTeX over MathML due to bandwidth considerations is fine, but there are a lot of other considerations, which we need to weigh bandwidth usage against. I like LaTeX too, but there are many reasons why it could end up being problematic. I'd love it if someone could come up with a compelling case as to why LaTeX is objectively better than MathML that addresses all the downsides of LaTeX. |
[…] this would be super sweet to have right here right now 🤣 |
can support LaTeX, asciimath, and MathML inputs) and KaTeX (which can support LaTeX | ||
inputs). | ||
* Firefox and WebKit support MathML natively (though not perfectly, especially | ||
with Content MathML), but Chrome and IE/Edge do not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://mathml.igalia.com/news/2019/10/31/mathml-in-chromium-upstream-process-started/
https://bugs.chromium.org/p/chromium/issues/detail?id=6606
Igalia started the upstreaming process for native MathML support in Chromium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh. Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.igalia.com/chats/ecosystem-health-ii
Can we actually make something that’s interoperable here?” At the time the MathML spec was very hand wavy, you know, the test suite was not very rigorous. And so we just pointed at the guidelines we already had for what bar do we apply when deciding whether something was mature enough to ship. And, frankly, we were worried that Igalia was under estimating how much work it was going to take to get some subset of MathML to that bar, and we we were worried that people would have, you know, some different expectations that, you know… Maybe if they could do a little bit of work, they could get to that bar… and that they would be disappointed when it came to an intent to ship. And so, we tried to spell it very clearly where we saw the risks with trying to meet that high bar that we have for interoperability. And now, the consensus is pretty clear that Igalia really stepped up, right? We were clear on what it would take to ship MathML, Igalia did the hard thankless work… With Google employees reviewing many of things the patches - but Igalia did a lot of work to meet that bar… and I think, you know, I think the jury is still out on, well.. I don’t know what the current frames are looking like, but I fully expect MathML to ship at some point and it’ll ship in Chrome at the same time… Even though from Google’s business perspective, it probably wouldn’t have been a good return on investment for us to do it… But I’m thrilled that Igalia was able to do it, even though our judgment would have been not worth it.
Sounds like great news.
I am strongly in favour of transporting raw TeX math notation, instead of MathML. For me, it boils down to the question: In a plain text environment (e.g. command line IRC clients), how do people communicate math? In my experience, for simple things, people use "programming syntax", e.g. Thus, I would imagine that the developer of a terminal-only Matrix client would like to display maths in raw TeX notation, if not simplifying to "programming syntax" whenever possible (e.g. If maths is transferred using MathML instead TeX as one might expect, the maintainer of said terminal client would have to implement a converter from MathML to TeX, which AFAIK is a non-trivial task. Even if implemented, I'm also concerned that a TeX -> MathML -> TeX round-trip may not be entirely lossless. Since the sender's client probably uses TeX to input math, they probably expect that any clients that can't display TeX would just receive the same TeX code they sent verbatim; a lossy conversion from TeX to MathML and back is not what they'd expect or want. Regarding security, I feel like talking about the turing completeness of LaTeX the monolithic typesetting framework is not especially relevant to a discussion regarding TeX as maths notation. The common subset of LaTeX's maths notation that libraries such as MathJax and KaTeX support is not Turing complete. Furthemore, MathML has actually been the culprit behind numerous security vulnerabilities. Just last week, for example, I read about a bug in DOMPurify that used MathML to enable cross-site scripting. Google even dropped support for MathML from its Chromium browser, citing security and maintainability concerns. |
This MSC should probably be closed. The momentum is definitely behind the counter proposal for LaTeX: #2191 with WIP implementations for element-web and -android. |
Rendered
I keep switching between preferring MathML or LaTeX. This proposal proposes MathML, but investigates LaTeX as an alternative enough to hint as to what a fully worked-out LaTeX proposal might look like.
This proposal is related to element-hq/element-web#1945