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

LaTeX support #25

Open
kgv opened this issue Dec 14, 2023 · 9 comments · May be fixed by #45
Open

LaTeX support #25

kgv opened this issue Dec 14, 2023 · 9 comments · May be fixed by #45
Labels
enhancement New feature or request

Comments

@kgv
Copy link

kgv commented Dec 14, 2023

Is LaTeX support planned?

@lampsitter
Copy link
Owner

LaTeX in general i probably too much for this crate. With that said, a subset for math would definitely be nice to have.

@lampsitter lampsitter added the enhancement New feature or request label Dec 14, 2023
@zeozeozeo
Copy link
Contributor

zeozeozeo commented Mar 30, 2024

seems like pulldown_cmark has merged the support for math expressions: pulldown-cmark/pulldown-cmark#734 (it will emit Event::InlineMath and Event::DisplayMath events that we can handle directly)
we could then use MathJax to render it to an SVG and draw it (this crate just shells out to Node or a headless chrome instance)

i think this would be a really cool feature to have, i'll start prototyping on it tomorrow

@lampsitter
Copy link
Owner

It would be really nice. It's just incredibly painful that node or headless chrome must be involved. I would have preferred to avoid that.

@zeozeozeo
Copy link
Contributor

zeozeozeo commented Mar 30, 2024

It would be really nice. It's just incredibly painful that node or headless chrome must be involved. I would have preferred to avoid that.

True, I guess we could embed a JavaScript engine like QuickJS or Duktape and make MathJax run in it? :P
I haven't found any pure Rust TeX -> SVG renderer, aside from Tectonic which seems to only render to HTML
There are also libraries that shell out to ghostscript, but I think Node and Chrome are much more common

@lampsitter
Copy link
Owner

Yeah. Your first suggestion is the most sane option. Maybe this gives me an excuse to add support for mermaid too 🤔

There is definitely a lot to consider. For instance the headless chrome feature in that crate fetches mathjax from CDN and as I would expect most people to use that backend it would mean that it would require internet access to work. At least that would have to be documented.

@zeozeozeo
Copy link
Contributor

zeozeozeo commented Mar 30, 2024

or we can just leave it to the user and make them pass a closure that will render LaTeX into a texture

@lampsitter
Copy link
Owner

I don't think moving the problem to the user is the solution 😆

@zeozeozeo
Copy link
Contributor

I don't think moving the problem to the user is the solution 😆

I think that's the best option, since there's no easy way of rendering LaTeX in Rust. The implementation would also be different when compiling for web, since there you can directly interface with the browsers' JS engine

@lampsitter
Copy link
Owner

I think that's the best option, since there's no easy way of rendering LaTeX in Rust. The implementation would also be different when compiling for web, since there you can directly interface with the browsers' JS engine

True. I did not think about for web.

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

Successfully merging a pull request may close this issue.

3 participants