mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.19k stars 29 forks source link

feat: render typst/latex/mermaid asynchronously #273

Closed mfontanini closed 2 months ago

mfontanini commented 2 months ago

This changes rendering of typst/latex/mermaid (now called "third party renders") to execute asynchronously. This wasn't needed for typst/latex as they're so fast you can't even tell it's rendering, but the mermaid CLI requires spinning up a browser (!!!) so it can take a couple of seconds to render. This causes the presentation experience, especially during development, to become very clunky as changing the presentation file just stalls presenterm for 2 seconds per chart until they're all rendered.

This changes that so that charts are rendered asynchronously by a pool of 2 threads (which I will make configurable in another PR). This now means you can:

https://github.com/mfontanini/presenterm/assets/969090/9580bec8-9b6e-44b3-8920-09d7956176b1

mfontanini commented 2 months ago

@mikavilpas I'd appreciate if you could give this a test and see if you find any quirks. The one thing I am aware of is that the errors, specifically for mermaid, are very long so lines overflow and they end up looking not so great (see the attached video, which is worse considering the window is tiny).

mikavilpas commented 2 months ago

Just tried this out - the difference is like night and day. Multithreading seems to work (2 graphs seem to get rendered in one go now). Caching works too, as does the loading indicator.

Great result, I'm really impressed!