Crate prettify_cmark [−] [src]
Pretty-printing for CommonMark documents.
Simple API
For simple use-cases, the prettify
function
can be used to parse and pretty-print a CommonMark document.
use prettify_cmark::prettify; let output = prettify("Lorem __ipsum__ dolor `sit` amet!"); assert_eq!(output, "Lorem **ipsum** dolor `sit` amet!")
Advanced API
For more advanced use-cases, this crate is designed to work well together
with the pulldown-cmark
crate.
It provides a PrettyPrinter
which wraps
around an output type (such as String
), and into which events can be
pushed that have been obtained from pulldown-cmark
.
use pulldown_cmark::Parser; use prettify_cmark::PrettyPrinter; let events = Parser::new("Lorem _ipsum_ dolor `sit`."); let mut printer = PrettyPrinter::default(); printer.push_events(events).unwrap(); assert_eq!(printer.into_inner(), "Lorem *ipsum* dolor `sit`.")
Reexports
pub extern crate pulldown_cmark; |
Structs
PrettyDisplay |
Wrapper that will pretty print the wrapped document when formatted
via |
PrettyPrinter |
Event-driven pretty printer for CommonMark documents. |
Functions
prettify |
Parses a CommonMark document and returns it as a pretty printed string. |