diff --git a/Cargo.toml b/Cargo.toml index 453d138..1f37437 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ toml = "0.4" unicode-segmentation = "1.0" unicode-width = "0.1" xi-unicode = "0.1.0" +pulldown-cmark = { version = "0.1.0", optional = true, default-features = false } enumset = "0.3.3" [dependencies.bear-lib-terminal] @@ -75,6 +76,7 @@ termion-backend = [ "chan", "chan-signal", ] +markdown = ["pulldown-cmark"] [lib] name = "cursive" diff --git a/src/utils/markup/markdown.rs b/src/utils/markup/markdown.rs new file mode 100644 index 0000000..d34edcf --- /dev/null +++ b/src/utils/markup/markdown.rs @@ -0,0 +1,172 @@ +//! Parse markdown text. +//! +//! Needs the `markdown` feature to be enabled. + +extern crate pulldown_cmark; + +use self::pulldown_cmark::{Event, Tag}; +use std::borrow::Cow; +use theme::{Effect, Style}; +use utils::lines::spans::Span; + +/// Parse markdown string into spans of styled text. +pub struct Parser<'a> { + first: bool, + stack: Vec