Skip to content

Commit

Permalink
Update pulldown-cmark to next breaking version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Enyium committed Feb 14, 2023
1 parent 02d7942 commit 2a4ec9f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 33 deletions.
12 changes: 6 additions & 6 deletions crates/mdman/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/mdman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions crates/mdman/src/format/man.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions crates/mdman/src/format/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -223,7 +223,7 @@ impl<'e> TextRenderer<'e> {
self.flush();
self.hard_break();
}
Tag::Heading(_n) => {}
Tag::Heading(..) => {}
Tag::BlockQuote => {
self.indent -= 3;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/mdman/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn header_text<'e>(parser: &mut EventIter<'e>) -> Result<CowStr<'e>, 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),
Expand Down
10 changes: 2 additions & 8 deletions crates/mdman/tests/compare/expected/formatting.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions crates/mdman/tests/compare/expected/formatting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2a4ec9f

Please sign in to comment.