features: add flag for html module

This commit is contained in:
Noah Hellman 2023-02-05 20:07:20 +01:00
parent f4d8aee4cc
commit 34452a282a
2 changed files with 18 additions and 0 deletions

View file

@ -24,7 +24,14 @@ members = [
"tests/afl", "tests/afl",
] ]
[[bin]]
name = "jotdown"
required-features = ["html"]
doc = false
[features] [features]
default = ["html"]
html = [] # html renderer and minimal cli binary
suite = [] # test suite suite = [] # test suite
suite_bench = [] # bench test suite suite_bench = [] # bench test suite
deterministic = [] # for stable fuzzing deterministic = [] # for stable fuzzing

View file

@ -5,21 +5,30 @@
//! directly generate to some output format. This crate provides an [`html`] module that can be //! directly generate to some output format. This crate provides an [`html`] module that can be
//! used to render the events to HTML. //! used to render the events to HTML.
//! //!
//! # Feature flags
//!
//! - `html` (default): build the html module and a binary that converts djot to HTML.
//!
//! # Examples //! # Examples
//! //!
//! Generate HTML from Djot input: //! Generate HTML from Djot input:
//! //!
//! ``` //! ```
//! # #[cfg(feature = "html")]
//! # {
//! let djot_input = "hello *world*!"; //! let djot_input = "hello *world*!";
//! let events = jotdown::Parser::new(djot_input); //! let events = jotdown::Parser::new(djot_input);
//! let mut html = String::new(); //! let mut html = String::new();
//! jotdown::html::push(events, &mut html); //! jotdown::html::push(events, &mut html);
//! assert_eq!(html, "<p>hello <strong>world</strong>!</p>\n"); //! assert_eq!(html, "<p>hello <strong>world</strong>!</p>\n");
//! # }
//! ``` //! ```
//! //!
//! Apply some filter to a specific type of element: //! Apply some filter to a specific type of element:
//! //!
//! ``` //! ```
//! # #[cfg(feature = "html")]
//! # {
//! # use jotdown::Event; //! # use jotdown::Event;
//! # use jotdown::Container::Link; //! # use jotdown::Container::Link;
//! let events = //! let events =
@ -32,10 +41,12 @@
//! let mut html = String::new(); //! let mut html = String::new();
//! jotdown::html::push(events, &mut html); //! jotdown::html::push(events, &mut html);
//! assert_eq!(html, "<p>a <a href=\"https://example.net\">link</a></p>\n"); //! assert_eq!(html, "<p>a <a href=\"https://example.net\">link</a></p>\n");
//! # }
//! ``` //! ```
use std::fmt::Write; use std::fmt::Write;
#[cfg(feature = "html")]
pub mod html; pub mod html;
mod attr; mod attr;