diff --git a/Cargo.lock b/Cargo.lock index 8ff3b38..c58b5f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,11 +69,6 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bitflags" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "0.9.1" @@ -481,10 +476,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pulldown-cmark" -version = "0.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.1.0" +source = "git+https://github.com/maghoff/pulldown-cmark.git#eec135668e6961c00a20cca4e3e5f6602ec68983" dependencies = [ - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -581,7 +576,7 @@ dependencies = [ "libsqlite3-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.1.0 (git+https://github.com/maghoff/pulldown-cmark.git)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "r2d2 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "r2d2-diesel 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -945,7 +940,6 @@ dependencies = [ "checksum bart_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "39fdc9035ac29aeb14993e2cdae217de7ccc9f9960eae0c5a12d541ca11c6af1" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" @@ -998,7 +992,7 @@ dependencies = [ "checksum odds 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "c3df9b730298cea3a1c3faa90b7e2f9df3a9c400d0936d6015e6165734eefcba" "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum pulldown-cmark 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7c04a8bb38f80717527edea39c82378c2ef13ecdbc914cbd90653a2e24afdf" +"checksum pulldown-cmark 0.1.0 (git+https://github.com/maghoff/pulldown-cmark.git)" = "" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum r2d2 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2c8284508b38df440f8f3527395e23c4780b22f74226b270daf58fee38e4bcce" "checksum r2d2-diesel 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6b921696a6c45991296d21b52ed973b9fb56f6c47524fda1f99458c2d6c0478" diff --git a/Cargo.toml b/Cargo.toml index db45fcd..82f8bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ default-features = false version = "0.1" [dependencies.pulldown-cmark] -version = "0.0.11" +git = "https://github.com/maghoff/pulldown-cmark.git" default-features = false [dependencies.static_resource_derive] diff --git a/src/rendering.rs b/src/rendering.rs index a5a21a1..2662d5a 100644 --- a/src/rendering.rs +++ b/src/rendering.rs @@ -1,32 +1,8 @@ -use pulldown_cmark::{Event, Parser, html}; - -struct EscapeHtml<'a, I: Iterator>> { - inner: I, -} - -impl<'a, I: Iterator>> EscapeHtml<'a, I> { - fn new(inner: I) -> EscapeHtml<'a, I> { - EscapeHtml { inner } - } -} - -impl<'a, I: Iterator>> Iterator for EscapeHtml<'a, I> { - type Item = Event<'a>; - - fn next(&mut self) -> Option { - use pulldown_cmark::Event::{Text, Html, InlineHtml}; - - match self.inner.next() { - Some(Html(x)) => Some(Text(x)), - Some(InlineHtml(x)) => Some(Text(x)), - x => x - } - } -} +use pulldown_cmark::{Parser, html, OPTION_ENABLE_TABLES, OPTION_DISABLE_HTML}; pub fn render_markdown(src: &str) -> String { - let opts = ::pulldown_cmark::OPTION_ENABLE_TABLES; - let p = EscapeHtml::new(Parser::new_ext(src, opts)); + let opts = OPTION_ENABLE_TABLES | OPTION_DISABLE_HTML; + let p = Parser::new_ext(src, opts); let mut buf = String::new(); html::push_html(&mut buf, p); buf