{{ message }}

# Maths support#3251

Closed
wants to merge 28 commits into from
Closed

# Maths support#3251

wants to merge 28 commits into from

## Conversation

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

 Linked to vector-im/element-web#10428 Added support for mathematics rendering using KaTeX (see vector-im/element-web#1945 (comment)). Edit: Now enabling maths mode replaces anything wrapped in dollar signs with the same thing wrapped in  (or ) tags in the formatted_body. Enabling KaTeX rendering (as an account option) then uses KaTeX to render anything between such tags. This is an improvement over the previous commit, where the distinction between math mode and arbitrary org.matrix.custom.html content was non-existent. Now things really can be changed to fit any proposals very easily (fallbacks, KaTeX vs. MathJax, delimiter choices, etc. etc.). The only remaining 'bug' is that I haven't yet implemented per-room KaTeX rendering settings. Signed-off-by: Tim Hosgood timhosgood@gmail.com The text was updated successfully, but these errors were encountered:
added 14 commits Jul 22, 2019
 let spans have the katex class 
 755bfaf 
 last-minute KaTeX rendering 
 affc69e 
 regex fun 
 36aba90 
 broken some things, added others 
 7fbbd79 
 katex rendering settings sort of work (but not on a room-by-room basis) 
 38ae1fc 
 css is a bit better now 
 986498d 
 "one" thing missing now... sending with org.matrix.custom.html format… 
 b3d627b 
… when isMathEnabled
 ok, this works, but just need to default it to being off 
 154a4b1 
 new math.png 
 50c31a1 
 message composer now remember math state (and defaults to off) (almost) 
 1538b42 
 ok fixed that problem 
 c20fba8 
 for some reason, per-room KaTeX settings don't work... 
 12ccefc 
 cannot get room-account settings to work 
 f23aedb 
 removed per-room-account katex setting 
 70ffd6b 
mentioned this pull request Jul 27, 2019
mentioned this pull request Jul 27, 2019
closed this Jul 27, 2019

### thosgood commented Jul 27, 2019

 closed while refactoring code to be more in keeping with proposals

added 4 commits Jul 28, 2019
 send math in matrix tags 
 a67540b 
 sending math now plays nicely with markdown 
 ad86a8f 
 fixed logic + almost everything works 
 f57e18b 
 can now send math without markdown enabled 
 306a9ed 
reopened this Jul 28, 2019
mentioned this pull request Jul 28, 2019
 fixed math mode not being enabled when markdown on 
 ffb596f 
reviewed
res/img/math.svg Outdated Show resolved Hide resolved
added 3 commits Aug 9, 2019
 fixed math.svg 
 ff36572 
 removed small unnecessary changes 
 46084df 
 lazy regexing 
 18b6990 

### thosgood commented Aug 21, 2019

 this has now entered testing at www.pigeon.digital , and the last commit fixes some problems reported by users

added 3 commits Sep 19, 2019
 factored out the fallback rendering ready for whatever solution we find 
 5cbf349 
 added display option 
 98ac7d5 
 removed fallback factoring 
 b148fff 

### dkout commented Jan 26, 2020

 Hey all, Are there any updates for this feature? Would be very useful to have! :)

### thosgood commented Jan 26, 2020

 i haven't had any time to update this to work with the new message composer, and i'm not sure if much has been done since the last discussion in the room... i'd also love to finish this off but have really lost the swing of things, and can't remember where things were left off

### Moebiusgeometer commented Mar 19, 2020

 Is anyone able to make this work as a test in the coming weeks as it was done previously above? I am a mathematics PhD at Paris-Saclay. We are all locked in at home now due to COVID-19. I would like to get students and teachers on Riot to continue courses, study groups, etc. Getting this running soon would be super helpful for many Universities worldwide in those days, even if buggy! I am unfortunately unable to do it for sure, but I promise to promote Riot (Matrix) to as many Universities and Professors I have contact to if someone manages to get it done.

### thosgood commented Mar 19, 2020

 Is anyone able to make this work as a test in the coming weeks as it was done previously above? I am a mathematics PhD at Paris-Saclay. We are all locked in at home now due to COVID-19. I would like to get students and teachers on Riot to continue courses, study groups, etc. Getting this running soon would be super helpful for many Universities worldwide in those days, even if buggy! I am unfortunately unable to do it for sure, but I promise to promote Riot (Matrix) to as many Universities and Professors I have contact to if someone manages to get it done. There is a demo build running at https://pigeon.digital that should work fine. I believe it was recently used at a conference that wanted to do some remote interaction. Unless there's a massive rush of traffic, it should continue to work as a temporary solution, but I'm glad to hear that there's still interest in the mathematics community for this!

### eMPee584 commented Apr 3, 2020

 How much funding would this need to complete? Our uni is going to put up a moderate matrix support budget..

### behrmann commented Apr 28, 2020

 I haven't looked into this much further, then simply trying to rebase this on the current develop branch, since my JS-fu is basically non-existent, but this branch rebases almost cleanly, with only a trivial conflict in src/HtmlUtils.js and the need to bump the Katex version in package.json and have yarn fix the yarn.lock. I'd really love to see this land, how can I help to make this happen?

### thosgood commented Apr 28, 2020

 The last I heard was that this was going to be a Google Summer of Code project for somebody, because the team (very understandably) wanted any solution to not be simply for Riot, but for Matrix clients as a whole, which makes things quite a bit more difficult.

### behrmann commented Apr 29, 2020

 @thosgood Thanks for the information! I just read the GSoC proposal and this PR is listed as a partial implementation. That is because it is only client side and there is no server endpoint that would generate a fallback (e.g. an image) or is there anything else missing? I guess most LaTeX users would be happy with the LaTeX code as fallback, as that is what (most of them) they are typing right now already.

### thosgood commented Apr 29, 2020

 @behrmann No server fallback is the main thing missing here, yes. Not to mention that the message sent is just some custom type that mixes together a few different suggestions, whereas the "final" proposal might end up using extensible events or something like this (but this, again, seems to be a bit up in the air still). I agree that, at least as a first goal, LaTeX implementation should really be aimed at the sort of people who use LaTeX often, i.e. not worrying too much if the fallback is just the code itself. Adding better fallbacks/better input methods (some WYSIWYG bar or something) seems like something that should come afterwards, to me.

### behrmann commented May 29, 2020

 It seems like the Project unfortunately wasn't picked up by a student for the summer of code, or I am unable to find it on the page. I'd still be happy if this would land, just as a stop gap until a more formal MSC is approved, as this would be quite a killer feature for the natural sciences.

### Adrien-Luxey commented Jul 15, 2020

 The latest Element.io blog post references this issue, as a feature that will be implemented to ease the feelings of people disagreeing with the name change: https://element.io/blog/welcome-to-element/ So I guess LaTeX math support is on the roadmap after all!

### thosgood commented Jul 15, 2020

 just as a small note, the current version of pigeon.digital uses the latest (pre-Element) build of Riot, i.e. with the new composer, and with all LaTeX rendering options hidden from the user (and all enabled by default), following user feedback

### behrmann commented Jul 15, 2020

 @thosgood Sounds excellent. Do you know if the work is based in this PR or whether it is happening separately (I didn't see any other open PR). Would you be open to updating this PR (and the accompanying riot/element PR) to the version you seem to have in production? I'd love to give it a spin.

### thosgood commented Jul 15, 2020

 @behrmann not too sure: all discussion (that I know of) is taking place in the pigeon.digital room. I could try updating this PR, but I think I'd be lost in git hell for a while in trying to do so... honestly, the changes that I had to make to the latest Riot release were so tiny: include the katex package, run the KaTeX renderer on any message with the org.matrix.custom.html format, and make sure that any message with a pair of $ in it would be sent as this format. There is some extra playing around to be done with regexes to try to fix some problems that come from unmatched $s and how they interact with markdown things etc, but I didn't spend much time on fixing these, since these are the sorts of things that should be done on the same level as the markdown engine, and I didn't want to have to understand that yet 🙃

### behrmann commented Jul 16, 2020

 @thosgood You can simply rename thosgood:develop via git branch -m develop develop_v0 and then checkout the one with your current version as the new develop git checkout -c develop  und push it here via git push --force-with-lease develop. This should get you around the Git hell part. I think Github nowadays is also able to show different versions of a PR like Gitlab.

### polwel commented Jul 29, 2020

 I just gave the pigeon.digital build a test drive. Nice work! Though editing messages seems to be broken.

### thosgood commented Jul 29, 2020

 yeah, editing messages required a bit more finesse, and was never something that I gave much time to.

### thosgood commented Jul 29, 2020

 as a warning, I think the pigeon.digital site will be unavailable soon, since the domain registration runs out, and I don't currently have the funds to renew it. when this happens though, i will definitely update this pull request with the latest version!

### polwel commented Jul 29, 2020

 yeah, editing messages required a bit more finesse, and was never something that I gave much time to. Fair enough. Editing will be important though. I never seem to be able to get long LaTex expressions right on the first try.

### jonathancross commented Sep 6, 2020

 @thosgood This has conflicts that need tp be resolved. Would be great to get a status update too. :-)

mentioned this pull request Sep 22, 2020

### thosgood commented Sep 22, 2020

 this has been superseded by #5244 :-)

### ArniDagur commented Dec 6, 2020

 I guess this should be closed as #5244 has been merged?

### jryans commented Dec 11, 2020

 Yes, looks like we can close this now.

closed this Dec 11, 2020

### sunwoo-kim commented Oct 13, 2021

 Are there any plans to bring Maths support to iOS and/or Android?