Expand description
CommonMark for the terminal, built on pulldown_cmark.
The level texts are written for Rich: paragraphs are wrapped by hand in the source and are expected to reflow, headings are left-aligned, and code blocks hold box-drawing trees that must survive untouched. The renderer therefore works in two steps. The parser events are first collected into a small block tree; the tree is then laid out for a given width, which makes hanging indents trivial: a list item or block quote simply lays out its children at a smaller width and prefixes the resulting lines.
| Markdown | Rendering |
|---|---|
| paragraph | reflowed; soft breaks become spaces, hard breaks stay |
#, ## | the heading in bold underline followed by ──── to the full width |
### and deeper | the heading text in bold (h4 dim, h5/h6 italic) |
*em*, **strong**, `code` | italic, bold, bold cyan; a code span is not split across lines while it fits on one |
- item | • marker in bold yellow, continuation lines indented under the text |
1. item | right-aligned numbers, same hanging indent; nested lists indent further |
| fenced or indented code | verbatim, never wrapped, indented by two spaces |
> quote | every line prefixed with ▌ , text in magenta |
Blocks are separated by exactly one blank line, items of a list by none. Raw HTML is shown as
text. Control characters in the input are replaced, so a document can never write escape
sequences of its own, and ⚠️ is shown as the bare ⚠ (see
normalize_emoji). Tables and the other CommonMark extensions
are not enabled.
Functions§
- render_
markdown - Renders CommonMark to terminal lines,
term.widthcolumns wide. - split_
pages - Splits intro text into pages at lines that consist of exactly
---.