henriklovhaug / md-tui

Markdown renderer in the terminal
GNU Affero General Public License v3.0
206 stars 13 forks source link

Non-interactive mode #140

Closed maxigaz closed 3 months ago

maxigaz commented 3 months ago

I've been using glow as a markdown previewer inside vifm. I've just discovered md-tui, and I really like it so far.

To my knowledge, vifm can only use a tool as a previewer if it outputs something straight to stdout, and then, vifm acts like a pager, so the output can be scrolled up and down, just like in less. I'm not entirely sure how glow works, but I think it detects whether it was called through a pipe or not, and based on that, opens a file in either interactive and non-interactive mode.

Could md-tui also have the option to output rendered straight to stdout?

Also, thank you for the software!

henriklovhaug commented 3 months ago

The render workflow of md-tui is really tied to ratatui. It's the library which handles the colouring during rendering and uses the terminal in alternate mode. To use this program without the keyboard handling, link functionality, or search, it's just a formatter basically. At that point, in my opinion, glow does a better job.

Pipe detection is not hard to achieve, but it would loose all colouring without a major rewrite.

maxigaz commented 3 months ago

The main reason I considered md-tui as a viable alternative is because it performs much better based on my (limited) testing. For instance, I have a markdown file that is around 700 kB in size. While it takes glow more than 10 seconds to open it (in both modes), md-tui opens it instantly.

But I understand if this is a 'wontfix'.

henriklovhaug commented 3 months ago

The parsing is a lot faster as long you don't have images it needs to fetch over the internet than Glow. Maybe mdcat is a good alternative