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

TeX in the message list #46

Open
gnprice opened this issue Mar 31, 2023 · 4 comments · May be fixed by #1335
Open

TeX in the message list #46

gnprice opened this issue Mar 31, 2023 · 4 comments · May be fixed by #1335
Assignees
Labels
a-content Parsing and rendering Zulip HTML content, notably message contents beta feedback Things beta users have specifically asked for
Milestone

Comments

@gnprice
Copy link
Member

gnprice commented Mar 31, 2023

Zulip's Markdown flavor supports TeX for mathematical notation, using KaTeX. This will be one of the more complex message-content features for us to support.

The way this works for web and for the existing RN-based mobile client is:

  • KaTeX consists of some JavaScript code to convert TeX into HTML, and then some CSS to style that HTML. The KaTeX-generated HTML also has some per-element style attributes.
  • The server takes care of the conversion to HTML, by running the KaTeX JS code on Node. That HTML goes into the message's HTML content.
  • Then the web and RN-mobile clients ship with KaTeX's CSS, and include that in their styles.
  • Those clients also ship with the KaTeX JS code. They use that for local echo.

What I think we'll want to do in Flutter is:

  • Skip TeX for local echo, and just show the source TeX. That seems fine.
    • If we implement a "preview" feature for before sending a message, then it'll be important to get the actual rendering there… but even the web app relies on the server for its preview feature. So we'll do the same.
  • Then we'll consume KaTeX HTML and convert it into Flutter widgets, just like we consume other kinds of Zulip content HTML and convert it into Flutter widgets, in lib/model/content.dart and lib/widgets/content.dart.

Converting the HTML to Flutter widgets will involve having code in lib/widgets/content.dart that is written to correspond to the KaTeX CSS, just like much of the existing code there is written to correspond to the Zulip markdown-content CSS.

That CSS is a few hundred lines of code. It's written in Less; but looking at the compiled output, it's not much longer than that source, and most of the difference is highly repetitive. So the real amount of information there is about what's in that one source file. That file is also highly stable over time — just as one might hope, given that TeX itself is famously extremely stable — with the last non-NFC change 20 months ago, in 2021-07.

So while this won't be a small subproject, it's one where I'm pretty confident we can do it well.

@gnprice gnprice added the m-beta label May 26, 2023
@gnprice gnprice added this to the Beta milestone May 27, 2023
@gnprice gnprice added a-content Parsing and rendering Zulip HTML content, notably message contents and removed m-beta labels May 27, 2023
@gnprice gnprice modified the milestones: Beta, Launch Sep 22, 2023
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Jun 26, 2024
The dark-theme color, like the light-theme one, doesn't have a
source in Figma or the web app. I just chose it from some quick
testing on my iPhone. (As the comment says, we'll drop the color
when we support katex properly, zulip#46.)
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Jun 28, 2024
The dark-theme color, like the light-theme one, doesn't have a
source in Figma or the web app. I just chose it from some quick
testing on my iPhone. (As the comment says, we'll drop the color
when we support katex properly, zulip#46.)
@chrisbobbe
Copy link
Collaborator

We got a request for this as beta feedback in the Google Play Console:

Looks like there's no Latex support yet. This makes it a non-starter for our purposes unfortunately. Are there plans to bring that in soon?

@chrisbobbe
Copy link
Collaborator

And again today:

Math doesn't work, glitches with links. I'll try again another time (love Zulip generally).

@chrisbobbe chrisbobbe added the beta feedback Things beta users have specifically asked for label Dec 20, 2024
@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Dec 27, 2024

In the Lean community we asked how disappointed people would be if the app were rolled out to all users before full support for TeX.

One user answered "heavily disappointed"; others reacted to that message suggesting they disagree.

A different user "wouldn't mind" the current state, and another added:

I mean, I'm old enough to remember when people wrote latex in sci.math.research in their posts and it was just displayed like that anyway.

@chrisbobbe
Copy link
Collaborator

See discussion with an idea from Tim:

So I think it would be possible to write the Flutter app logic to convert MathML into display rather than working with the HTML.

@rajveermalviya rajveermalviya self-assigned this Jan 19, 2025
@rajveermalviya rajveermalviya linked a pull request Feb 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-content Parsing and rendering Zulip HTML content, notably message contents beta feedback Things beta users have specifically asked for
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants