Preview Markdown in the Terminal with Bash [Hackaday]

View Article on Hackaday

Markdown has become an extremely popular way to document source code and other projects, thanks in no small part to how well web-based services like GitHub render it. Just sprinkle a few extra characters into a regular text file, and all the sudden it looks like you know what you’re doing. Unfortunately, there are some places where markdown won’t actually render, and you’ll be stuck looking at those extra characters.

But thanks to MarCLIdown, the terminal doesn’t have to be one of those places. Written by [NihaAlGhul], this simple tool takes a given markdown file and spits out a fairly impressive rendering — and you don’t even need to have one of those fancy new GPU-accelerated terminals. Most impressively, the whole thing is implemented as a single Bash script.

How does it work? Some would say it’s magic. Others would point out the inline Perl, conditionals statements, and line after line of regular expressions. Ultimately, we’d argue they’re the same thing.

Definitely Dark Magic

As you can probably imagine not everything is supported by MarCLIdown, but the list of what’s currently working is already quite impressive. Headers, check boxes, lists, block quotes, links, all work and look pretty much as you’d expect. The biggest omission at this point is probably tables, but even that isn’t really a deal breaker.

MarCLIdown isn’t the first tool to try and visualize markdown in the terminal. Readers may already be familiar with glow, which is more mature and admittedly has the edge in terms of capability. But the fact that [NihaAlGhul] managed to get this far with just a single Bash script is a proper hack, and one we think worthy of some special consideration.



Leave a Reply