Skip to main content

mrk/
lib.rs

1//! Render Markdown beautifully in the terminal.
2//!
3//! The renderer behind the `mrk` command: it turns Markdown into a [`Document`](document::Document) of styled lines,
4//! with code highlighted and Mermaid diagrams drawn as text or as PNG pictures. It never prints; writing the document
5//! to a terminal is [`terminal`]'s job, behind the default `cli` feature.
6//!
7//! ```
8//! use mrk::document::{self, Settings};
9//! use mrk::markdown;
10//!
11//! let mut settings = Settings::default();
12//! settings.width = 40;
13//! let rendered = markdown::render("# Notes\n\n- one\n- two\n", &settings);
14//! print!("{}", document::printable(&rendered));
15//! ```
16//!
17//! Print only through [`sanitize`], `Line::printable` or `document::printable`: Markdown is untrusted input and a
18//! terminal interprets escape sequences. The guide is `docs/library.md` in the repository.
19#![cfg_attr(docsrs, feature(doc_cfg))]
20
21pub mod code;
22pub mod diff;
23pub mod document;
24pub mod link;
25pub mod markdown;
26pub mod mermaid;
27mod raster;
28pub mod sanitize;
29#[cfg(all(test, feature = "cli"))]
30mod snapshot;
31#[cfg(feature = "cli")]
32pub mod terminal;
33mod text;
34pub mod theme;
35
36/// Runs the Rust snippets of `docs/library.md` as doctests, so the guide compiles against the API it describes.
37#[cfg(doctest)]
38#[doc = include_str!("../docs/library.md")]
39struct LibraryGuide;