Hacker News new | past | comments | ask | show | jobs | submit login
Glow: Render Markdown on the CLI (github.com/charmbracelet)
142 points by behnamoh on Dec 9, 2022 | hide | past | favorite | 39 comments



Here's the snippet I'm using:

    markdown () {
       pandoc $1 | lynx -stdin
    }

usage:

    $ markdown README.md
I don't often use pandoc or lynx so might check out glow instead, but I thought some of you might find this approach simpler in case you already have these tools installed.


Hey, you reminded me, I once experimented with pandoc's conversion script- you can write a lua script that handles the different markdown styles - to just output escape sequences for different colors or bold/italics depending on the header level, so that you could just translate the markdown into something prettier in your shell.

Your approach is more sensible, I had fun playing with the lua script though. Pandoc will spit out a reference script that formats the output as html so it it pretty easy to work off of


You need quotes around "$1" otherwise `markdown "my file.md"` won't work because of the whitespace.


ah, good catch, cheers!


And you could swap pandoc with multimarkdown. Achieves the same.


But it doesn't have pizzazz! :-)


cheeky chooky


Rendering markdown in the terminal[1] was also recently added to the Logfile Navigator (https://lnav.org). It was partially inspired by Glow. There are some extra features in lnav's implementation, like a breadcrumb bar so that you can jump to different sections of the document.

(You might question why a log file viewer needs markdown support... It's used mainly to make the builtin help text look nicer. But, it can also be used in other places, like adding comments to log messages and generating reports. It's even used to implement an interactive tutorial[2].)

[1] - https://lnav.org/2022/08/06/markdown-support.html [2] - https://lnav.org/2022/09/01/playground.html


"Glow works with the Charm Cloud to allow you to store any markdown files in your own private collection." So are we to presume that Charm Cloud is always going to be an intermediary between the user and their private collection? Seems like a vulnerable position place to be when using sensitive info captured in Markdown.


Run it yourself if you’re concerned =)

https://github.com/charmbracelet/charm


render any markdown you like, charm cloud or not.

you don't have to use their cloud, but they have one if you want to, and I'm sure it works nice with their stuff.


OTOH, I can already use pygmentize + less (via a .lessfilter) to render Markdown in the terminal. https://pygments.org/docs/cmdline/


yes, there is more than one way to solve a problem, usually.


Interesting, I'm a bit concerned about pushing arbitrary things to a third party on just pressing s though. I know there's talk of encryption but still, that's a much bigger thing than just rendering markdown.


It looks like there's a config flag that disables all network activity, including to/from their cloud.


Vim already does a lot of this between syntax highlighting and the fact that markdown is designed to be readable as text. I think it's an interesting space though.

One thing that would be cool is image support for terminals that support them.

I'm also curious (tangentially) if there are any terminals that support different fonts and sizes (at the same time)?


2x wide and 2x tall fonts were commonly supported on old terminals, though not commonly used. I bet xterm supports both today.

edit: yep. see https://en.wikipedia.org/wiki/Vttest


Very interesting, thanks!

In case anyone is interested, I just checked, and xterm supports it, terminal on ubuntu does not, nor does iterm2 on mac nor termux on android


I have a very nice tool for checking out the GitHub pull requests I'm assigned to review that uses this to preview the description. Way nicer than anything else I tried in that it can do emojis (not sure if they're encoded as shortcodes or what), tables, etc.


GitHub's command line tool does a pretty good job of this, it does emoji too.


I use that to get the markdown in the list of PRs assigned to me, then I use fzf (fuzzy finder) to choose between them with Glow for the previewing. I think I tried previewing the PR with GH and because it would fetch each PR description anew it wasn't good for arrowing between the PRs like I wanted.


It uses the same library as glow (glamour) -

https://github.com/cli/cli/blob/e876b229634b02d40bdfbb15844d...


I'd love to see how the markup is actually rendered. The README has an animated gif, but it goes by so fast that I really can't see how anything is rendered. Screenshots would be fine for this purpose, why the bling?


A few years ago I wrote markcat, a cli toot to process markdown but more focused on readability. To this day I do `markcat README.md` a lot .

https://github.com/BubuAnabelas/markcat/


Thanks, this looks much better.

Glow does too much. I don't care about using their cloud, a new pager, or a TUI for that matter. Just render Markdown and let me view it with my pager of choice.


If you like the sound of glow, check out lowdown. Renders to colorized term or man page, in addition to odf, latex, html & pdf

https://kristaps.bsd.lv/lowdown/


I recently tried it. The CLI works great, but there is one super basic feature missing in the TUI that makes me not want to use it and that is search inside a document. There is already a FR on Github, but it got no attention so far.


if it’s still open, I think I’ll take a stab at this in the near future…


uhm... but wasn't md designed to be readable as is? what do you guys miss from "less mydoc.md"?


Unless I'm a character inside the Matrix, I prefer visual converters.


How is the analogy of this tool, rendering markdown in the CLI, has to do with uploading markdown files to a cloud service? Seems out of scope.


What does it do exactly?

E.g. is it only changing the text’s color / font style? Or is it also doing something more, like positioning or spacing?


I feel like I’ve boomeranged from loving CLI/TUI interfaces to native UI to web/html interfaces, back to native UI and then now I’m all about the TUI/CLI again with musikcube.


Real-world web/HTML UI's tend to suck. But a well-made, lightweight, accessible web UI can be quite effective much like a TUI.


I think what I like in a UI tends to be common in TUIs, but what I enjoy in a UI isn't necessarily attached to any of the categories you mention.

What do you feel is uniquely appealing about UIs in those different categories that has your excitement pinging between them?


For me:

terminal: beautiful simplicity & efficiency -- everything is a stream of bytes, output is characters displayed on a regular grid

web: bang-for-buck experience -- hard to beat for middling interactivity plus high development velocity

native: maxed out capacity for experience & interactivity


on mac, pointing to one file doesn't page the output. I can't get the output paged using `less`, it loses all the formatting and color. starting the TUI (no args) and then choosing the file works fine, however.

less --version

less 608 (PCRE2 regular expressions)


are you using `less -r` to pass through raw ansi code?

it also looks like it has a `-p` option for a pager

> CLI output can be displayed in your preferred pager with the -p flag. This defaults to the ANSI-aware less -r if $PAGER is not explicitly set.


yes, was using `less -r`

but `glow -p file.md` is working great! thanks




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: