Skip to content

Commit

Permalink
Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFre…
Browse files Browse the repository at this point in the history
…dnet

Update pulldown-cmark version to 0.9

Fixes #92206.

r? `@camelid`
  • Loading branch information
bors committed Dec 31, 2021
2 parents e670844 + 4e2024c commit 8ed935e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
17 changes: 14 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ dependencies = [
"clippy_utils",
"if_chain",
"itertools 0.10.1",
"pulldown-cmark",
"pulldown-cmark 0.9.0",
"quine-mc_cluskey",
"regex-syntax",
"rustc-semver",
Expand Down Expand Up @@ -2154,7 +2154,7 @@ dependencies = [
"log",
"memchr",
"opener",
"pulldown-cmark",
"pulldown-cmark 0.8.0",
"regex",
"serde",
"serde_derive",
Expand Down Expand Up @@ -2813,6 +2813,17 @@ dependencies = [
"unicase",
]

[[package]]
name = "pulldown-cmark"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548"
dependencies = [
"bitflags",
"memchr",
"unicase",
]

[[package]]
name = "punycode"
version = "0.4.1"
Expand Down Expand Up @@ -4615,7 +4626,7 @@ dependencies = [
"expect-test",
"itertools 0.9.0",
"minifier",
"pulldown-cmark",
"pulldown-cmark 0.9.0",
"rayon",
"regex",
"rustdoc-json-types",
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ path = "lib.rs"

[dependencies]
arrayvec = { version = "0.7", default-features = false }
pulldown-cmark = { version = "0.8", default-features = false }
pulldown-cmark = { version = "0.9", default-features = false }
minifier = "0.0.41"
rayon = "1.3.1"
serde = { version = "1.0", features = ["derive"] }
Expand Down
17 changes: 9 additions & 8 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
}

let event = self.inner.next();
if let Some((Event::Start(Tag::Heading(level)), _)) = event {
if let Some((Event::Start(Tag::Heading(level, _, _)), _)) = event {
let mut id = String::new();
for event in &mut self.inner {
match &event.0 {
Expand All @@ -560,7 +560,8 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0));
}

let level = std::cmp::min(level + (self.heading_offset as u32), MAX_HEADER_LEVEL);
let level =
std::cmp::min(level as u32 + (self.heading_offset as u32), MAX_HEADER_LEVEL);
self.buf.push_back((Event::Html(format!("</a></h{}>", level).into()), 0..0));

let start_tags = format!(
Expand Down Expand Up @@ -773,7 +774,7 @@ crate fn find_testable_code<T: doctest::Tester>(
tests.add_test(text, block_info, line);
prev_offset = offset.start;
}
Event::Start(Tag::Heading(level)) => {
Event::Start(Tag::Heading(level, _, _)) => {
register_header = Some(level as u32);
}
Event::Text(ref s) if register_header.is_some() => {
Expand Down Expand Up @@ -1053,7 +1054,7 @@ impl Markdown<'_> {
let mut replacer = |broken_link: BrokenLink<'_>| {
links
.iter()
.find(|link| &*link.original_text == broken_link.reference)
.find(|link| link.original_text.as_str() == &*broken_link.reference)
.map(|link| (link.href.as_str().into(), link.new_text.as_str().into()))
};

Expand Down Expand Up @@ -1134,7 +1135,7 @@ impl MarkdownSummaryLine<'_> {
let mut replacer = |broken_link: BrokenLink<'_>| {
links
.iter()
.find(|link| &*link.original_text == broken_link.reference)
.find(|link| link.original_text.as_str() == &*broken_link.reference)
.map(|link| (link.href.as_str().into(), link.new_text.as_str().into()))
};

Expand Down Expand Up @@ -1168,7 +1169,7 @@ fn markdown_summary_with_limit(
let mut replacer = |broken_link: BrokenLink<'_>| {
link_names
.iter()
.find(|link| &*link.original_text == broken_link.reference)
.find(|link| link.original_text.as_str() == &*broken_link.reference)
.map(|link| (link.href.as_str().into(), link.new_text.as_str().into()))
};

Expand Down Expand Up @@ -1311,10 +1312,10 @@ crate fn markdown_links(md: &str) -> Vec<MarkdownLink> {
};

let mut push = |link: BrokenLink<'_>| {
let span = span_for_link(&CowStr::Borrowed(link.reference), link.span);
let span = span_for_link(&link.reference, link.span);
links.borrow_mut().push(MarkdownLink {
kind: LinkType::ShortcutUnknown,
link: link.reference.to_owned(),
link: link.reference.to_string(),
range: span,
});
None
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cargo_metadata = "0.14"
clippy_utils = { path = "../clippy_utils" }
if_chain = "1.0"
itertools = "0.10"
pulldown-cmark = { version = "0.8", default-features = false }
pulldown-cmark = { version = "0.9", default-features = false }
quine-mc_cluskey = "0.2"
regex-syntax = "0.6"
serde = { version = "1.0", features = ["derive"] }
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,16 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
},
Start(Link(_, url, _)) => in_link = Some(url),
End(Link(..)) => in_link = None,
Start(Heading(_) | Paragraph | Item) => {
if let Start(Heading(_)) = event {
Start(Heading(_, _, _) | Paragraph | Item) => {
if let Start(Heading(_, _, _)) = event {
in_heading = true;
}
ticks_unbalanced = false;
let (_, span) = get_current_span(spans, range.start);
paragraph_span = first_line_of_span(cx, span);
},
End(Heading(_) | Paragraph | Item) => {
if let End(Heading(_)) = event {
End(Heading(_, _, _) | Paragraph | Item) => {
if let End(Heading(_, _, _)) = event {
in_heading = false;
}
if ticks_unbalanced {
Expand Down

0 comments on commit 8ed935e

Please sign in to comment.