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 element-hq/element-web#10428

Added support for mathematics rendering using KaTeX (see element-hq/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

closed while refactoring code to be more in keeping with proposals

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

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

@dkout
Copy link

dkout commented Jan 26, 2020

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

@thosgood
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

@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
Copy link
Author

@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
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

@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
Copy link
Author

@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
Copy link

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

@polwel
Copy link

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
Copy link
Author

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

@thosgood
Copy link
Author

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
Copy link

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
Copy link

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

@thosgood
Copy link
Author

this has been superseded by #5244 :-)

@ArniDagur
Copy link

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

@jryans
Copy link
Collaborator

jryans commented Dec 11, 2020

Yes, looks like we can close this now.

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

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

@SimonBrandner
Copy link
Contributor

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

For Android, see element-hq/element-android#2133

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

Successfully merging this pull request may close these issues.

None yet