Is using a web browser really necessary for viewing Markdown? Seems a really inefficient way to view a what's supposed to be a small and minimal language.
Emphasis on "Github flavored", which supports additional extensions to the markdown spec that a TUI can't properly preview. You need some kind of GUI (preferably a browser since it does support some html) in order to properly preview it.
Yes, exactly. For example Mermaid diagrams (that is supported in this project) can't be rendered in TUI (well, technically you can if you use something like Kitty's image protocol, but I think this is being pendant).
As someone said already, Markdown was designed to be compiled to HTML, and browsers are the best HTML renderers we have. While you can technically interpret it semantically and render it without a browser, you would still need to support HTML since Markdown supports embedded HTML (e.g. `<details>` tag is a popular one to hide information). At that point you probably are better off using a browser anyway.
By the way, while browsers can be both CPU and memory hogs, they're not inherently inneficient and it mostly depends on what the website is doing. This project uses minimal JavaScript and no frameworks, and while I didn't measure it I assume this site should be reasonably efficient, both in memory and CPU usage.
i dont know why its a CLI when it could just be a js library? is there a more minimal version of this that can then be used more flexibly everywhere else?
I'm assuming it's because the project isn't meant to "Render" markdown, but provide a preview that works offline. That includes hot reloading when the original file changes, which you can't really do with just a client-side library.
If it was a JS library in addition to providing you a webpage with js in it, it would also need to provide you with a server with a hot reload, and we're back to CLI.
They are using goldmark library with some extensions[0] to render markdown. And there's also GitHub API for rendering markdown[1] if you're curious.
fwiw there are plenty of webserver cli's with reload capability (https://www.npmjs.com/package/live-server or npx serve + chokidar), this is definitely one of those things that can decomposed to single responsibility tools
(nit: hot reload means a specific thing in the js ecosystem and you prob dont mean that)
Is using a web browser really necessary for viewing Markdown? Seems a really inefficient way to view a what's supposed to be a small and minimal language.
Emphasis on "Github flavored", which supports additional extensions to the markdown spec that a TUI can't properly preview. You need some kind of GUI (preferably a browser since it does support some html) in order to properly preview it.
Yes, exactly. For example Mermaid diagrams (that is supported in this project) can't be rendered in TUI (well, technically you can if you use something like Kitty's image protocol, but I think this is being pendant).
Using a GUI framework over a web browser is still much more efficient.
As someone said already, Markdown was designed to be compiled to HTML, and browsers are the best HTML renderers we have. While you can technically interpret it semantically and render it without a browser, you would still need to support HTML since Markdown supports embedded HTML (e.g. `<details>` tag is a popular one to hide information). At that point you probably are better off using a browser anyway.
By the way, while browsers can be both CPU and memory hogs, they're not inherently inneficient and it mostly depends on what the website is doing. This project uses minimal JavaScript and no frameworks, and while I didn't measure it I assume this site should be reasonably efficient, both in memory and CPU usage.
Markdown was designed to compile to HTML and web browsers are designed to render HTML. So I’d say a browser is the only reasonable choice.
i dont know why its a CLI when it could just be a js library? is there a more minimal version of this that can then be used more flexibly everywhere else?
I'm assuming it's because the project isn't meant to "Render" markdown, but provide a preview that works offline. That includes hot reloading when the original file changes, which you can't really do with just a client-side library.
If it was a JS library in addition to providing you a webpage with js in it, it would also need to provide you with a server with a hot reload, and we're back to CLI.
They are using goldmark library with some extensions[0] to render markdown. And there's also GitHub API for rendering markdown[1] if you're curious.
References:
[0]: https://github.com/thiagokokada/gh-gfm-preview/blob/main/int...
[1]: https://docs.github.com/en/rest/markdown?apiVersion=2022-11-...
fwiw there are plenty of webserver cli's with reload capability (https://www.npmjs.com/package/live-server or npx serve + chokidar), this is definitely one of those things that can decomposed to single responsibility tools
(nit: hot reload means a specific thing in the js ecosystem and you prob dont mean that)
Sure, but using Node would mean losing the advantage of this being a single static binary. Not everyone has Node installed already.