deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

readm3 0.3.0 adds markdown editing and Reddit flavor support to the terminal

readm3 0.3.0 turns the terminal markdown reader into a lightweight editor, swaps its regex parser for marked, and adds dialect handling for GitHub alerts and Reddit spoilers.

readm3 0.3.0 adds markdown editing and Reddit flavor support to the terminal

A reader learns to edit

readm3, a terminal markdown viewer that pairs a file browser with a rendered document pane, has shipped version 0.3.0 with the ability to edit the files it displays. According to the dev.to announcement, editing works by pressing e, typing, and pressing esc; because the reader and the editor operate on the same buffer, the preview has already re-rendered by the time the user returns to it. There is no separate rendering path to keep in sync, which the author identifies as the part that typically breaks in editors with a live preview pane.

The editing surface stays deliberately small. ctrl+s saves, and quitting with unsaved work prompts first. Pressing enter continues whatever list the cursor sits in — the next bullet, the next number, or an unchecked box for a task item — and pressing it again on an empty item closes the list. There is no text selection and no cut and paste. The tool is meant for small corrections and added paragraphs, not for replacing a real editor.

Marked replaces the regex pile

Until now, parsing was handled by a few hundred lines of handwritten regex code, which mishandled reference links, nested lists and bare URLs — and every fix meant writing yet another expression. Version 0.3.0 moves parsing to marked. The stated reason is weight rather than features: marked implements CommonMark plus GFM with no dependencies of its own, taking readm3 from one dependency to two. By comparison, the post notes that markdown-it would have meant seven, and a remark/micromark pipeline somewhere between twenty and forty packages — a heavy load for a tool whose appeal is starting instantly in a terminal.

Only the parsing layer changed. The layout code — text wrapping, code-block gutters, table sizing — is untouched, so the project's site at readm3.com renders through the same functions the terminal build uses, and there is still only one renderer. Adopting marked also resolved reference links, nested and loose lists, bare-URL autolinks and hard line breaks as a side effect.

Flavors that cannot all be on at once

marked ships none of GitHub alerts, footnotes, :emoji: shortcodes, or the syntax Reddit has added over the years, so readm3 implements those as its own tokenizer extensions, again without new dependencies. They sit behind a --flavor switch offering commonmark, github (the default), reddit or all, because the dialects genuinely conflict.

The announcement gives two examples. 2^32 is just a number in a README, but on Reddit it means 2 to the 32nd, rendered as a superscript — enable that globally and every exponent in every technical document silently changes meaning. >!spoiler!< is trickier still: in CommonMark, on GitHub and elsewhere, a line starting with > is a blockquote, so the text parses as a quote holding the remainder, whereas Reddit reads it as a spoiler. Getting that right required a block-level extension that takes ownership of the line before marked's blockquote tokenizer can process it.

A few details fell out of the work. Superscripts use real Unicode glyphs when every character has one, so mc^2 becomes mc², and keep the caret when they do not, because Unicode has no superscript q. Spoilers are drawn as solid blocks rather than text disguised with a matching background color, so they stay hidden when output is piped elsewhere or run with --color never.

A bug only a real terminal could find

Driving the finished interface in a real pseudo-terminal, the author pressed ? for help while in edit mode and watched a question mark land in the document. The status bar had been advertising ? as the help key, a leftover from reader mode; help has since moved to ctrl+g. No unit test would have caught it, because the buffer behaved correctly and inserted the keystroke it received. The release ships with 144 tests, reported passing on Node 22, Node 24 and Bun under Linux, macOS and Windows, and installs with bun add -g @profullstack/readm3.

Why it matters

Terminal markdown tooling usually forces a choice between a viewer that renders but cannot change anything and an editor with no preview. readm3 0.3.0 collapses that into a two-pane tool light enough to open instantly, and its flavor switch is a working demonstration of why universal dialect support fails: markdown variants are mutually incompatible, and treating them as one format silently corrupts documents. For anyone maintaining READMEs or writing on Reddit from the terminal, it fills a narrow niche with unusual care.

  • #markdown
  • #terminal
  • #cli
  • #open-source
  • #node-js

Related posts