5 ms·
Glow: Render Markdown on the CLI
- booi 4y agoI 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.
- pxc 4y agoI 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?
- infogulch 4y agoFor 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
- zozbot234 4y agoReal-world web/HTML UI's tend to suck. But a well-made, lightweight, accessible web UI can be quite effective much like a TUI.
- 1-more 4y agoI 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.
- petepete 4y agoGitHub's command line tool does a pretty good job of this, it does emoji too.
- 1-more 4y agoI 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.
- ehershey 4y agoIt uses the same library as glow (glamour) - https://github.com/cli/cli/blob/e876b229634b02d40bdfbb15844d4d3e9f121c27/pkg/markdown/markdown.go#L4 https://github.com/cli/cli/blob/e876b229634b02d40bdfbb15844d...
- dimator 4y agoon 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)
- 7362398724 4y agoare 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.
- dimator 4y agoyes, was using `less -r` but `glow -p file.md` is working great! thanks
- version_five 4y agoVim 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)?
- naikrovek 4y ago2x 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 https://en.wikipedia.org/wiki/Vttest
- version_five 4y agoVery 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
- rpastuszak 4y agoHere'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.
- xcdzvyn 4y agoBut it doesn't have pizzazz! :-)
- aaws11 4y agocheeky chooky
- version_five 4y agoHey, 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
- luckman212 4y agoYou need quotes around "$1" otherwise `markdown "my file.md"` won't work because of the whitespace.
- rpastuszak 4y agoah, good catch, cheers!
- tempodox 4y agoAnd you could swap pandoc with multimarkdown. Achieves the same.
- IanCal 4y agoInteresting, 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.
- cglong 4y agoIt looks like there's a config flag that disables all network activity, including to/from their cloud.
- kickingvegas 4y ago"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.
- naikrovek 4y agorender 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.
- kickingvegas 4y agoOTOH, I can already use pygmentize + less (via a .lessfilter) to render Markdown in the terminal. https://pygments.org/docs/cmdline/ https://pygments.org/docs/cmdline/
- naikrovek 4y agoyes, there is more than one way to solve a problem, usually.
- chucky_z 4y agoRun it yourself if you’re concerned =) https://github.com/charmbracelet/charm https://github.com/charmbracelet/charm
- wwarner 4y agoIf 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/ https://kristaps.bsd.lv/lowdown/
- bubuanabelas 4y agoA 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/ https://github.com/BubuAnabelas/markcat/
- imiric 4y agoThanks, 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.
- dotancohen 4y agoI'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?
- tstack 4y agoRendering markdown in the terminal[1] was also recently added to the Logfile Navigator (https://lnav.org 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 https://lnav.org/2022/08/06/markdown-support.html [2] - https://lnav.org/2022/09/01/playground.html https://lnav.org/2022/09/01/playground.html
- _ZeD_ 4y agouhm... but wasn't md designed to be readable as is? what do you guys miss from "less mydoc.md"?
- mekster 4y agoUnless I'm a character inside the Matrix, I prefer visual converters.
- mgrandl 4y agoI 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.
- truemotive 4y agoif it’s still open, I think I’ll take a stab at this in the near future…
- thih9 4y agoWhat 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?
- worldsavior 4y agoHow 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.