diff --git a/Cargo.toml b/Cargo.toml index 7bb7456..c59bb97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,14 @@ members = [ "tests/afl", ] +[[bin]] +name = "jotdown" +required-features = ["html"] +doc = false + [features] +default = ["html"] +html = [] # html renderer and minimal cli binary suite = [] # test suite suite_bench = [] # bench test suite deterministic = [] # for stable fuzzing diff --git a/src/lib.rs b/src/lib.rs index 40eb0ba..a8fd3d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,21 +5,30 @@ //! directly generate to some output format. This crate provides an [`html`] module that can be //! used to render the events to HTML. //! +//! # Feature flags +//! +//! - `html` (default): build the html module and a binary that converts djot to HTML. +//! //! # Examples //! //! Generate HTML from Djot input: //! //! ``` +//! # #[cfg(feature = "html")] +//! # { //! let djot_input = "hello *world*!"; //! let events = jotdown::Parser::new(djot_input); //! let mut html = String::new(); //! jotdown::html::push(events, &mut html); //! assert_eq!(html, "

hello world!

\n"); +//! # } //! ``` //! //! Apply some filter to a specific type of element: //! //! ``` +//! # #[cfg(feature = "html")] +//! # { //! # use jotdown::Event; //! # use jotdown::Container::Link; //! let events = @@ -32,10 +41,12 @@ //! let mut html = String::new(); //! jotdown::html::push(events, &mut html); //! assert_eq!(html, "

a link

\n"); +//! # } //! ``` use std::fmt::Write; +#[cfg(feature = "html")] pub mod html; mod attr;