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

Add LaTeX/MathML support #822

Closed
bogdan-kulynych opened this Issue Apr 4, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@bogdan-kulynych

It would be great if Mastodon client could render mathematical equations in the toots. This can be very easily accomplished for web clients by including the MathJax script (62 Kb).

@RaitoBezarius

This comment has been minimized.

Show comment
Hide comment
@RaitoBezarius

RaitoBezarius Apr 4, 2017

After "working" on this issue a bit.
Some pointers are:

I wonder if we could have a MathJax function which would turn a string of LaTeX to a bunch of DOM nodes.

Last concern: what about theming? How to integrate MathJax theme into Mastodon properly?

After "working" on this issue a bit.
Some pointers are:

I wonder if we could have a MathJax function which would turn a string of LaTeX to a bunch of DOM nodes.

Last concern: what about theming? How to integrate MathJax theme into Mastodon properly?

@swaldie swaldie added the enhancement label Apr 4, 2017

@RaitoBezarius

This comment has been minimized.

Show comment
Hide comment
@RaitoBezarius

RaitoBezarius Apr 4, 2017

After fighting with MathJax, I tried KaTeX and got this nice result with exactly two line changes:

http://screencloud.net/v/BAG8q

Basically, all that remains is:

  • Load KaTeX dynamically using options.

  • Hook in status_content.jsx a soft renderer which will output the same content if KaTeX throw or is unavailable else will return DOM nodes as strings (just filter out the <p> and unwanted data, check for ( ), etc…)

  • Handle styling issues (when the mathematics overflows, wrapping them, etc…)

  • PROFIT!!! 🎉

Also, it would be nice to handle new commands or aliases, how that would be persisted through an instance?
IMHO, ideally, I see two steps:

  • Persist aliases on the local instance (we could easily imagine different aliases for different themed instances: statisticians, analysts, etc…)
  • Protocol extension: Announce aliases to other instances to ensure compatibility. "Hey, this message is using these aliases, use them and not the ones on your instance!"

@bogdan-kulynych What do you think?

After fighting with MathJax, I tried KaTeX and got this nice result with exactly two line changes:

http://screencloud.net/v/BAG8q

Basically, all that remains is:

  • Load KaTeX dynamically using options.

  • Hook in status_content.jsx a soft renderer which will output the same content if KaTeX throw or is unavailable else will return DOM nodes as strings (just filter out the <p> and unwanted data, check for ( ), etc…)

  • Handle styling issues (when the mathematics overflows, wrapping them, etc…)

  • PROFIT!!! 🎉

Also, it would be nice to handle new commands or aliases, how that would be persisted through an instance?
IMHO, ideally, I see two steps:

  • Persist aliases on the local instance (we could easily imagine different aliases for different themed instances: statisticians, analysts, etc…)
  • Protocol extension: Announce aliases to other instances to ensure compatibility. "Hey, this message is using these aliases, use them and not the ones on your instance!"

@bogdan-kulynych What do you think?

@bogdan-kulynych

This comment has been minimized.

Show comment
Hide comment
@bogdan-kulynych

bogdan-kulynych Apr 4, 2017

@RaitoBezarius
Looks great!
There's a gem for KaTeX. It can then be included as a sprockets conditional require in application_public.js. Probably user_params can be used directly in the require.

Aliases seems to be quite an advanced functionality. Why not start with basic maths support for this issue?

@RaitoBezarius
Looks great!
There's a gem for KaTeX. It can then be included as a sprockets conditional require in application_public.js. Probably user_params can be used directly in the require.

Aliases seems to be quite an advanced functionality. Why not start with basic maths support for this issue?

@Gargron

This comment has been minimized.

Show comment
Hide comment
@Gargron

Gargron Jun 29, 2017

Member

I enjoy the fact that there is an instance which implements this (mathstodon), however including the Latex browser rendering runtime for everybody, even though barely anybody will use it except for very specialized cases, makes me believe we will not accept this into upstream.

Member

Gargron commented Jun 29, 2017

I enjoy the fact that there is an instance which implements this (mathstodon), however including the Latex browser rendering runtime for everybody, even though barely anybody will use it except for very specialized cases, makes me believe we will not accept this into upstream.

@Gargron Gargron closed this Jun 29, 2017

abcang added a commit to pixiv/mastodon that referenced this issue Feb 5, 2018

abcang added a commit to pixiv/mastodon that referenced this issue Mar 6, 2018

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