-
Notifications
You must be signed in to change notification settings - Fork 58
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
Markdown Extension to include LaTeX support #6
Comments
I will look into this! If there's a crate/tool that can turn latex expressions into images, then it should be fairly straightforward to add here. We'd just need a step that takes |
I think if you're willing to have a temporary folder instantiated, it could be very cool and worthwhile to have the ability to summon the native PDFLaTeX renderer and pass the generated document through ImageMagick to get a fully rendered LaTeX image, especially for the scientists who I feel like are pretty likely to be attracted to a utility like this (like in my case). However, for nice and compact solution, the https://docs.rs/mathjax/latest/mathjax/ crate seems to closely approximates what is already done by GitHub-Flavored Markdown, and you could leave the responsibility of rendering more complex LaTeX expressions to people to handle on their own. I'm personally biased toward solution 1 (or a mix of the two) but mostly because it would be really frickin awesome, but otherwise either sounds pretty chill and and awesome enhancement to have! |
Great, thanks for the pointers. I'll look into this after I fix outstanding issues, this would be a great addition for sure. |
Alright so I looked a bit into this. My thoughts on each of these: MathjaxThis is as simple as integration could get. The output of the render operation for that crate gives you a
pdflatex + convertThis works quite nicely as well. I followed this idea (let me know if there's a better way to do this!) and it seems to work fine. How this could work would be we'd have a template .tex file, and then whenever we find a code block that contains latex the template file gets the user defined latex code replaced, written somewhere, then Notes on this one:
What are people's thoughts on this? |
I am honestly quite a fan of this |
What about using the tectonic engine? It's written in Rust, and can be embedded as a Rust dependency in the project. |
Yeah that's worth exploring too. I was also considering typst which, while not LaTeX, will let you write formulas. I managed to make this work in like 2 lines of typst the other day + I only had to install a single tool, while I had to use a bunch of boilerplate and install a bunch of stuff to make the pdflatex one work. |
Yeah, installing tex nowadays is really painful comparing to other modern tools. Tectonic aims to be easy to install and use and still produce latex output. |
Could an interchangable backend, perhaps a plugin-friendly interface be suitable for future steps with this and other potential connections to external applications? |
I don't really want to go this route until there's enough use cases that makes this worthwhile. For now I think it makes sense to use the best tool available here, which may be tectonic given besides being a single tool, it can be installed in every platform easily. I have some stashed code that already works to some extent here but I need to pick it back up and polish it. I'll get to this again soon. |
Would it be possible to get a sneak peek at this rough code, say so I could give a presentation tomorrow with it? If not, that's very understandable. Also, I think I agree with this assessment, Tectonic could be (hopefully) quite seamless integration. |
lol no, sorry, it's a bit too early. I'm prioritizing other stuff for now but I'll get to this soon. What I had was pretty crappy, as in, the size of the rendered formula was tiny. You can generate images and embed them if you want to use presenterm for now |
That's fair, thank you for the response, and for all your hard work on this project! |
After #75 the latest code in master currently supports rendering latex (and typst!). I ended up using typst as the rendering engine. It is so much simpler to use and it generates a png image directly so there's no need to go through the I'll write docs on this but for now if you want to test it, install
This gets replaced by an image. There's some customization you can make like colors in the theme: typst:
colors:
background: ff0000
foreground: 00ff00 If the output looks too tiny vertically, you can edit the configuration in typst:
ppi: 400 # or higher values This is a bit unfortunate but basically because the image gets rendered in multiple of terminal rows (e.g. 1 row or 2, not 1.5) if your image is too small vertically it looks a bit squished. The default ppi (300) works for me but it probably depends on your font size. Please let me know if it doesn't work. PS: I considered tectonic but a) it also has the intermediate PDF step and b) I had issues running it both via the pre-compiled binary and via PS2: I need to work on the default styles and probably add some caching here but at least it's working (but let me know otherwise!) |
Closing this. Docs are here |
Thank you so much! |
Would it be possible to introduce some mathematical expression support? I have seen unicode rendering done in the past of math expressions, but perhaps even some iterm/sexel magic could be done to embed equations.
Thank you for all your work on this project, by the way! It's quite phenomenal!
The text was updated successfully, but these errors were encountered: