Skip to content

Glow for Mere Mortals

A surprising share of the text a programmer reads now arrives as Markdown: the README at the root of every project, the notes in a documentation folder, the changelog, the ticket exported from the tracker. In a terminal, that text is usually shown raw — cat it, and you read the asterisks, the hash marks and the table pipes along with the words. Glow is a terminal Markdown reader from the Charm project: it takes a Markdown document and renders it the way a web page would — headings as headings, tables drawn with rules, code blocks coloured, task lists with their boxes ticked — and presents the finished page on your terminal screen.

One rule governs everything it does, and this guide states it in chapter 1 and keeps pointing back to it: the rendering is a reading of the document, not the document. Glow re-flows the text to a width you may not have chosen, replaces some marks with pictures and others with plain text, and leaves a few things out entirely. The file on disk is the only original. Every surprise in this guide — the footnote that is not there, the image that became a line of text, the output that grew twenty-six times bigger in a pipe — is that rule at work.

The lab behind this guide ran the real thing: Glow 3.0.0, the official Linux release binary from the project's GitHub releases, run against specimen documents the lab wrote for the purpose — walking-club trail notes with a table and a task list, a packing list, a meeting notice, a page with a photograph in it. Against them the lab took the rendered page apart escape code by escape code; proved that piped output drops to a plain style and that forcing colour into a pipe multiplies its size; proved with a stand-in "pager spy" exactly what the pager is handed, on a terminal and off one; measured every built-in style by the byte; found the width is 80 on every terminal, wide or narrow, until you change it; fetched a README from GitHub two ways and got the same bytes back both times; drove the file browser and its built-in pager under a pretend terminal that answers the questions real terminals answer, and rebuilt their screens afterwards with a terminal emulator; and timed the ten seconds Glow waits when a terminal does not answer its questions at all.

What the lab could not do, it did not fake. Its pretend terminal could not be persuaded to report a light background, so the claim that the automatic style chooses light on a light terminal rests on the project's documentation, and the text says so. The package installs for each operating system are likewise documented-only: the lab ran the project's own release binary. criteria.md keeps the full ledger of what was run and what was only read.

What this guide covers

  • What Glow is — the reading and the document, where a rendered page earns its keep in a terminal, and the one rule
  • The moving parts — the source picker, the parser, the renderer and its styles, the width step, and the three exits
  • Installing Glow — the release file the lab used, the package routes, and the version check
  • Your first read — one document three ways: printed straight, handed to a pager, opened in the built-in pager
  • The parts of a page — headings, code, tables, task lists, links and images taken apart escape by escape, and where the rendering parts company with GitHub's
  • Pipes and stdin — the plain style a pipe gets, the cost of forcing colour, and the pipe that silently overrules your file
  • The pager — -p, the PAGER variable, and what the pager spy's evidence shows
  • Styles — the styles that exist, the ones that do not, what auto actually does, and custom styles from a JSON file
  • Width and wrapping — the 80-column default nobody asked your terminal about, and -w to change it
  • Reading from afar — URLs, the GitHub shorthand, and the network caveat that comes with both
  • The file browser — no argument at all: the document list, the built-in pager, hidden files, and line numbers
  • Making it yours — the configuration file, what it can and cannot overrule, and one quirk of --config the lab caught
  • The neighbours — bat for source, mdcat, the browser for full fidelity, and when each is the right reader
  • Limits — footnotes, images, the extension rule, and the rest of what the reading leaves out
  • Troubleshooting — the plain pipe, the ten-second wait, the ignored file, the ignored setting, in symptom-and-fix form
  • Glossary — the terms, collected in one place

What it doesn't cover

Writing Markdown — the language itself has its own guide in this series, pointed to in chapter 13, and this one starts where a document already exists. Editing documents: Glow is a reader, and chapter 13 explains when the editor is the right tool instead. Writing your own rendering engine or theme system is likewise out; making a custom style by editing a copy of a stock one is covered, at survey level, in chapter 8. Glow's long-gone stash feature and its shell completions get a mention and no more.

How to use this guide

Read chapter 1 for the rule and chapter 2 for the map of parts; everything after that is a part being opened. Chapter 4 is best done with a terminal open and a Markdown file of your own — the page makes sense the moment you can point at it. Chapters 6 and 14 are the two that change how you read every later surprise: why the pipe won over your file, and what the reading leaves out. The lab's specimen documents live in glow-lab/fixtures/, its helper scripts (answer-terminal.py, final-screen.py, pager-spy.sh, render.sh) beside them, and every claim's evidence in glow-lab/transcripts/; its distilled commands are examples/commands.txt and its notes examples/lab-notes.txt.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.