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 markdown;
25pub mod mermaid;
26mod raster;
27pub mod sanitize;
28#[cfg(all(test, feature = "cli"))]
29mod snapshot;
30#[cfg(feature = "cli")]
31pub mod terminal;
32mod text;
33pub mod theme;
34
35/// Runs the Rust snippets of `docs/library.md` as doctests, so the guide compiles against the API it describes.
36#[cfg(doctest)]
37#[doc = include_str!("../docs/library.md")]
38struct LibraryGuide;