diff --git a/crates/mdman/Cargo.lock b/crates/mdman/Cargo.lock index 50948b5eca4..bb67460dd96 100644 --- a/crates/mdman/Cargo.lock +++ b/crates/mdman/Cargo.lock @@ -17,9 +17,9 @@ checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "opaque-debug" @@ -269,9 +269,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.7.2" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55" +checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" dependencies = [ "bitflags", "memchr", diff --git a/crates/mdman/Cargo.toml b/crates/mdman/Cargo.toml index bae299f4525..28c8518e620 100644 --- a/crates/mdman/Cargo.toml +++ b/crates/mdman/Cargo.toml @@ -8,7 +8,7 @@ description = "Creates a man page page from markdown." [dependencies] anyhow = "1.0.31" handlebars = { version = "3.2.1", features = ["dir_source"] } -pulldown-cmark = { version = "0.7.2", default-features = false } +pulldown-cmark = { version = "0.9.2", default-features = false } same-file = "1.0.6" serde_json = "1.0.56" url = "2.2.2" diff --git a/crates/mdman/src/format/man.rs b/crates/mdman/src/format/man.rs index 1962be2fe55..5df81787122 100644 --- a/crates/mdman/src/format/man.rs +++ b/crates/mdman/src/format/man.rs @@ -3,7 +3,7 @@ use crate::util::{header_text, parse_name_and_section}; use crate::EventIter; use anyhow::{bail, Error}; -use pulldown_cmark::{Alignment, Event, LinkType, Tag}; +use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag}; use std::fmt::Write; use url::Url; @@ -122,10 +122,10 @@ impl<'e> ManRenderer<'e> { self.output.push_str(".sp\n"); } } - Tag::Heading(n) => { - if n == 1 { + Tag::Heading(level, ..) => { + if level == HeadingLevel::H1 { self.push_top_header()?; - } else if n == 2 { + } else if level == HeadingLevel::H2 { // Section header let text = header_text(&mut self.parser)?; self.flush(); @@ -255,7 +255,7 @@ impl<'e> ManRenderer<'e> { Event::End(tag) => { match &tag { Tag::Paragraph => self.flush(), - Tag::Heading(_n) => {} + Tag::Heading(..) => {} Tag::BlockQuote => { self.flush(); // restore left margin, restore line length diff --git a/crates/mdman/src/format/text.rs b/crates/mdman/src/format/text.rs index 2c6a4ff1747..ae07985a607 100644 --- a/crates/mdman/src/format/text.rs +++ b/crates/mdman/src/format/text.rs @@ -3,7 +3,7 @@ use crate::util::{header_text, unwrap}; use crate::EventIter; use anyhow::{bail, Error}; -use pulldown_cmark::{Alignment, Event, LinkType, Tag}; +use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag}; use std::fmt::Write; use std::mem; use url::Url; @@ -116,24 +116,24 @@ impl<'e> TextRenderer<'e> { self.flush(); } } - Tag::Heading(n) => { + Tag::Heading(level, ..) => { self.flush(); - if n == 1 { + if level == HeadingLevel::H1 { let text = header_text(&mut self.parser)?; self.push_to_line(&text.to_uppercase()); self.hard_break(); self.hard_break(); - } else if n == 2 { + } else if level == HeadingLevel::H2 { let text = header_text(&mut self.parser)?; self.push_to_line(&text.to_uppercase()); self.flush(); self.indent = 7; } else { let text = header_text(&mut self.parser)?; - self.push_indent((n as usize - 2) * 3); + self.push_indent((level as usize - 2) * 3); self.push_to_line(&text); self.flush(); - self.indent = (n as usize - 1) * 3 + 1; + self.indent = (level as usize - 1) * 3 + 1; } } Tag::BlockQuote => { @@ -223,7 +223,7 @@ impl<'e> TextRenderer<'e> { self.flush(); self.hard_break(); } - Tag::Heading(_n) => {} + Tag::Heading(..) => {} Tag::BlockQuote => { self.indent -= 3; } diff --git a/crates/mdman/src/util.rs b/crates/mdman/src/util.rs index e85f22093a7..a4c71ad38af 100644 --- a/crates/mdman/src/util.rs +++ b/crates/mdman/src/util.rs @@ -31,7 +31,7 @@ pub fn header_text<'e>(parser: &mut EventIter<'e>) -> Result, Error> e => bail!("expected plain text in man header, got {:?}", e), }; match parser.next() { - Some((Event::End(Tag::Heading(_)), _range)) => { + Some((Event::End(Tag::Heading(..)), _range)) => { return Ok(text); } e => bail!("expected plain text in man header, got {:?}", e), diff --git a/crates/mdman/tests/compare/expected/formatting.1 b/crates/mdman/tests/compare/expected/formatting.1 index dbd24526289..120859287c6 100644 --- a/crates/mdman/tests/compare/expected/formatting.1 +++ b/crates/mdman/tests/compare/expected/formatting.1 @@ -66,14 +66,8 @@ With a second paragraph inside it .sp .RS 4 \h'-04'\(bu\h'+02'Milk -.sp -.RS 4 -\h'-04' 5.\h'+01'Don't start at one. -.RE -.sp -.RS 4 -\h'-04' 6.\h'+01'tamarind -.RE +5. Don't start at one. +6. tamarind .RE .RE .sp diff --git a/crates/mdman/tests/compare/expected/formatting.txt b/crates/mdman/tests/compare/expected/formatting.txt index 865b714b630..87bbb87dc12 100644 --- a/crates/mdman/tests/compare/expected/formatting.txt +++ b/crates/mdman/tests/compare/expected/formatting.txt @@ -43,11 +43,7 @@ LISTS o Eggs - o Milk - - 5. Don't start at one. - - 6. tamarind + o Milk 5. Don't start at one. 6. tamarind 2. Second element