diff options
author | Jan-Erik Rediger <janerik@fnordig.de> | 2020-04-22 12:36:30 +0200 |
---|---|---|
committer | Jan-Erik Rediger <janerik@fnordig.de> | 2020-04-22 12:36:30 +0200 |
commit | cb51e351b9e7e511dbe83d608709434f3af773d1 (patch) | |
tree | 527a3b0f4248f13228372b59ebaeec9a913b1665 | |
parent | 694dbafed3f0e7d7ad1d049ab6199f2eed51e3ec (diff) |
Upgrade dependencies to fix nested HTML/markdown
-rw-r--r-- | Cargo.lock | 22 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/lib.rs | 37 |
3 files changed, 51 insertions, 12 deletions
@@ -665,8 +665,8 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mdbook 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark-to-cmark 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark-to-cmark 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -983,11 +983,22 @@ dependencies = [ ] [[package]] +name = "pulldown-cmark" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "pulldown-cmark-to-cmark" -version = "2.0.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1783,7 +1794,8 @@ dependencies = [ "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" "checksum pulldown-cmark 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c205cc82214f3594e2d50686730314f817c67ffa80fe800cf0db78c3c2b9d9e" -"checksum pulldown-cmark-to-cmark 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf89659b1da0800e093162bc6f9305d896393af721cc88ffdb86a4b20760fe89" +"checksum pulldown-cmark 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c2d7fd131800e0d63df52aff46201acaab70b431a4a1ec6f0343fe8e64f35a4" +"checksum pulldown-cmark-to-cmark 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f80851bae4714721298e6d05a0e1454055985ce5d82c4d01bf6905f8c5a382a" "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" @@ -10,8 +10,8 @@ edition = "2018" [dependencies] mdbook = "0.3" -pulldown-cmark = "0.6.1" -pulldown-cmark-to-cmark = "2.0.1" +pulldown-cmark = "0.7.0" +pulldown-cmark-to-cmark = "4.0.0" env_logger = "0.7.1" log = "0.4" clap = "2.33" @@ -1,8 +1,8 @@ use mdbook::book::{Book, BookItem, Chapter}; use mdbook::errors::{Error, Result}; use mdbook::preprocess::{Preprocessor, PreprocessorContext}; -use pulldown_cmark::{Event, Parser, Tag, Options}; -use pulldown_cmark_to_cmark::fmt::cmark; +use pulldown_cmark::{CodeBlockKind::*, Event, Options, Parser, Tag}; +use pulldown_cmark_to_cmark::cmark; pub struct Mermaid; @@ -45,7 +45,7 @@ fn add_mermaid(content: &str) -> Result<String> { opts.insert(Options::ENABLE_TASKLISTS); let events = Parser::new_ext(content, opts).map(|e| { - if let Event::Start(Tag::CodeBlock(code)) = e.clone() { + if let Event::Start(Tag::CodeBlock(Fenced(code))) = e.clone() { if &*code == "mermaid" { in_mermaid_block = true; mermaid_content.clear(); @@ -60,7 +60,7 @@ fn add_mermaid(content: &str) -> Result<String> { } match e { - Event::End(Tag::CodeBlock(code)) => { + Event::End(Tag::CodeBlock(Fenced(code))) => { assert_eq!( "mermaid", &*code, "After an opening mermaid code block we expect it to close again" @@ -112,12 +112,12 @@ Text A --> B </pre> + Text"#; assert_eq!(expected, add_mermaid(content).unwrap()); } - #[test] fn leaves_tables_untouched() { // Regression test. @@ -139,4 +139,31 @@ Text"#; assert_eq!(expected, add_mermaid(content).unwrap()); } + + #[test] + fn leaves_html_untouched() { + // Regression test. + // Don't remove important newlines for syntax nested inside HTML + + let content = r#"# Heading + +<del> + +*foo* + +</del> +"#; + + // Markdown roundtripping removes some insignificant whitespace + let expected = r#"# Heading + +<del> + +*foo* + +</del> +"#; + + assert_eq!(expected, add_mermaid(content).unwrap()); + } } |