Skip to main content

Crate termmd

Crate termmd 

Source
Expand description

termmd renders Markdown for terminals that are better than we usually give them credit for.

The crate is organised as a pipeline. Each stage has a single job and hands a plain data structure to the next one, which keeps the interesting parts (layout, images, the pager) testable without a terminal attached:

source text -> markdown::parse -> Document (IR)
            -> render::render   -> Screen (styled lines + image placements)
            -> output           -> bytes on a terminal

The Screen in the middle is the important boundary: both the “just print it” path and the interactive pager consume the same value, so what you see when you scroll is exactly what you get when you pipe.

Re-exports§

pub use markdown::Document;
pub use theme::Theme;

Modules§

cli
Command-line interface, and the settings resolution behind it.
config
The config file: ~/.config/termmd/config.toml.
images
Loading, sizing and encoding images for terminals that can show them.
markdown
Markdown parsing: from source text to a tree we can lay out.
pager
The interactive viewer.
render
Layout: from a Document to positioned, styled lines.
source
Reading input documents, and merging several of them into one page.
term
Everything that depends on what the terminal on the other end can actually do.
theme
Named style roles, and the built-in light and dark themes.