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

Maths support #3251

Closed
wants to merge 28 commits into from
Closed

Maths support #3251

wants to merge 28 commits into from

Conversation

@thosgood
Copy link

@thosgood thosgood commented Jul 27, 2019

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 <matrix-math> (or <matrix-math-display>) 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

@thosgood
Copy link
Author

@thosgood thosgood commented Jul 27, 2019

closed while refactoring code to be more in keeping with proposals

Loading

res/img/math.svg Outdated Show resolved Hide resolved
Loading
@thosgood
Copy link
Author

@thosgood thosgood commented Aug 21, 2019

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

Loading

@dkout
Copy link

@dkout dkout commented Jan 26, 2020

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

Loading

@thosgood
Copy link
Author

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

Loading

@Moebiusgeometer
Copy link

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

Loading

@thosgood
Copy link
Author

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

Loading

@eMPee584
Copy link

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

Loading

@behrmann
Copy link

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

Loading

@thosgood
Copy link
Author

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

Loading

@behrmann
Copy link

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

Loading

@thosgood
Copy link
Author

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

Loading

@behrmann
Copy link

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

Loading

@Adrien-Luxey
Copy link

@Adrien-Luxey 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!

Loading

@thosgood
Copy link
Author

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

Loading

@behrmann
Copy link

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

Loading

@thosgood
Copy link
Author

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

Loading

@behrmann
Copy link

@behrmann 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 <relevant branch> und push it here via git push --force-with-lease <name of your github remote> 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.

Loading

@polwel
Copy link

@polwel polwel commented Jul 29, 2020

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

Loading

@thosgood
Copy link
Author

@thosgood thosgood commented Jul 29, 2020

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

Loading

@thosgood
Copy link
Author

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

Loading

@polwel
Copy link

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

Loading

@jonathancross
Copy link

@jonathancross jonathancross commented Sep 6, 2020

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

Loading

@thosgood
Copy link
Author

@thosgood thosgood commented Sep 22, 2020

this has been superseded by #5244 :-)

Loading

@ArniDagur
Copy link

@ArniDagur ArniDagur commented Dec 6, 2020

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

Loading

@jryans
Copy link
Member

@jryans jryans commented Dec 11, 2020

Yes, looks like we can close this now.

Loading

@jryans jryans closed this Dec 11, 2020
@sunwoo-kim
Copy link

@sunwoo-kim sunwoo-kim commented Oct 13, 2021

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

Loading

@SimonBrandner
Copy link
Collaborator

@SimonBrandner SimonBrandner commented Oct 13, 2021

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

For Android, see vector-im/element-android#2133

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet