Skip to content

Commit 0550766

Browse files
committed
Auto merge of #60140 - euclio:pulldown-cmark, r=GuillaumeGomez
upgrade rustdoc's pulldown-cmark to 0.4.1 Fixes #59194.
2 parents 004c549 + 3030164 commit 0550766

File tree

8 files changed

+113
-124
lines changed

8 files changed

+113
-124
lines changed

Cargo.lock

+31-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "aho-corasick"
1010
version = "0.6.9"
1111
source = "registry+https://github.com/rust-lang/crates.io-index"
1212
dependencies = [
13-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
13+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1414
]
1515

1616
[[package]]
@@ -972,7 +972,7 @@ name = "fwdansi"
972972
version = "1.0.1"
973973
source = "registry+https://github.com/rust-lang/crates.io-index"
974974
dependencies = [
975-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
975+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
976976
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
977977
]
978978

@@ -1027,7 +1027,7 @@ dependencies = [
10271027
"aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
10281028
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
10291029
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1030-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1030+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
10311031
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
10321032
]
10331033

@@ -1143,7 +1143,7 @@ dependencies = [
11431143
"globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
11441144
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
11451145
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1146-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1146+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
11471147
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
11481148
"same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
11491149
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1441,7 +1441,7 @@ dependencies = [
14411441
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
14421442
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
14431443
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1444-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1444+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
14451445
"open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
14461446
"pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
14471447
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1469,7 +1469,7 @@ dependencies = [
14691469
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
14701470
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
14711471
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1472-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1472+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
14731473
"open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
14741474
"pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
14751475
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1494,13 +1494,8 @@ dependencies = [
14941494

14951495
[[package]]
14961496
name = "memchr"
1497-
version = "2.1.1"
1497+
version = "2.2.0"
14981498
source = "registry+https://github.com/rust-lang/crates.io-index"
1499-
dependencies = [
1500-
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
1501-
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
1502-
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1503-
]
15041499

15051500
[[package]]
15061501
name = "memmap"
@@ -2004,6 +1999,16 @@ dependencies = [
20041999
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
20052000
]
20062001

2002+
[[package]]
2003+
name = "pulldown-cmark"
2004+
version = "0.4.1"
2005+
source = "registry+https://github.com/rust-lang/crates.io-index"
2006+
dependencies = [
2007+
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
2008+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2009+
"unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
2010+
]
2011+
20072012
[[package]]
20082013
name = "quick-error"
20092014
version = "1.2.2"
@@ -2169,7 +2174,7 @@ version = "0.2.11"
21692174
source = "registry+https://github.com/rust-lang/crates.io-index"
21702175
dependencies = [
21712176
"aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
2172-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2177+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
21732178
"regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
21742179
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
21752180
"utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2181,7 +2186,7 @@ version = "1.1.0"
21812186
source = "registry+https://github.com/rust-lang/crates.io-index"
21822187
dependencies = [
21832188
"aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
2184-
"memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2189+
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
21852190
"regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
21862191
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
21872192
"utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3015,7 +3020,7 @@ version = "0.0.0"
30153020
dependencies = [
30163021
"minifier 0.0.29 (registry+https://github.com/rust-lang/crates.io-index)",
30173022
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
3018-
"pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
3023+
"pulldown-cmark 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
30193024
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
30203025
]
30213026

@@ -3774,6 +3779,14 @@ name = "ucd-util"
37743779
version = "0.1.3"
37753780
source = "registry+https://github.com/rust-lang/crates.io-index"
37763781

3782+
[[package]]
3783+
name = "unicase"
3784+
version = "2.3.0"
3785+
source = "registry+https://github.com/rust-lang/crates.io-index"
3786+
dependencies = [
3787+
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
3788+
]
3789+
37773790
[[package]]
37783791
name = "unicode-bidi"
37793792
version = "0.3.4"
@@ -4132,7 +4145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41324145
"checksum mdbook 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "90b5a8d7e341ceee5db3882a06078d42661ddcfa2b3687319cc5da76ec4e782f"
41334146
"checksum mdbook 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ba0d44cb4089c741b9a91f3e5218298a40699c2f3a070a85014eed290c60819"
41344147
"checksum measureme 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "36bb2b263a6795d352035024d6b30ce465bb79a5e5280d74c3b5f8464c657bcc"
4135-
"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16"
4148+
"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39"
41364149
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
41374150
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
41384151
"checksum minifier 0.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4950cb2617b1933e2da0446e864dfe0d6a22c22ff72297996c46e6a63b210b"
@@ -4184,6 +4197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41844197
"checksum proptest 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24f5844db2f839e97e3021980975f6ebf8691d9b9b2ca67ed3feb38dc3edb52c"
41854198
"checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32"
41864199
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
4200+
"checksum pulldown-cmark 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d1b74cc784b038a9921fd1a48310cc2e238101aa8ae0b94201e2d85121dd68b5"
41874201
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
41884202
"checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45"
41894203
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
@@ -4293,6 +4307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42934307
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
42944308
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
42954309
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
4310+
"checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd"
42964311
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
42974312
"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25"
42984313
"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1"

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rustdoc"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
pulldown-cmark = { version = "0.1.2", default-features = false }
12+
pulldown-cmark = { version = "0.4.1", default-features = false }
1313
minifier = "0.0.29"
1414
tempfile = "3"
1515
parking_lot = "0.7"

src/librustdoc/html/markdown.rs

+37-80
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ use crate::html::toc::TocBuilder;
3333
use crate::html::highlight;
3434
use crate::test;
3535

36-
use pulldown_cmark::{html, Event, Tag, Parser};
37-
use pulldown_cmark::{Options, OPTION_ENABLE_FOOTNOTES, OPTION_ENABLE_TABLES};
36+
use pulldown_cmark::{html, CowStr, Event, Options, Parser, Tag};
37+
38+
fn opts() -> Options {
39+
Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES
40+
}
3841

3942
/// A unit struct which has the `fmt::Display` trait implemented. When
4043
/// formatted, this struct will emit the HTML corresponding to the rendered
@@ -297,12 +300,11 @@ impl<'a, 'b, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, 'b, I>
297300

298301
fn next(&mut self) -> Option<Self::Item> {
299302
let event = self.inner.next();
300-
if let Some(Event::Start(Tag::Link(dest, text))) = event {
301-
if let Some(&(_, ref replace)) = self.links.into_iter().find(|link| &*link.0 == &*dest)
302-
{
303-
Some(Event::Start(Tag::Link(replace.to_owned().into(), text)))
303+
if let Some(Event::Start(Tag::Link(kind, dest, text))) = event {
304+
if let Some(&(_, ref replace)) = self.links.iter().find(|link| link.0 == *dest) {
305+
Some(Event::Start(Tag::Link(kind, replace.to_owned().into(), text)))
304306
} else {
305-
Some(Event::Start(Tag::Link(dest, text)))
307+
Some(Event::Start(Tag::Link(kind, dest, text)))
306308
}
307309
} else {
308310
event
@@ -393,7 +395,7 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
393395
| Tag::Emphasis
394396
| Tag::Strong
395397
| Tag::Code
396-
| Tag::Link(_, _)
398+
| Tag::Link(..)
397399
| Tag::BlockQuote => true,
398400
_ => false,
399401
}
@@ -520,63 +522,39 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for Footnotes<'a, I> {
520522
}
521523
}
522524

523-
pub struct TestableCodeError(());
524-
525-
impl fmt::Display for TestableCodeError {
526-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
527-
write!(f, "invalid start of a new code block")
528-
}
529-
}
530-
531-
pub fn find_testable_code<T: test::Tester>(
532-
doc: &str,
533-
tests: &mut T,
534-
error_codes: ErrorCodes,
535-
) -> Result<(), TestableCodeError> {
525+
pub fn find_testable_code<T: test::Tester>(doc: &str, tests: &mut T, error_codes: ErrorCodes) {
536526
let mut parser = Parser::new(doc);
537527
let mut prev_offset = 0;
538528
let mut nb_lines = 0;
539529
let mut register_header = None;
540-
'main: while let Some(event) = parser.next() {
530+
while let Some(event) = parser.next() {
541531
match event {
542532
Event::Start(Tag::CodeBlock(s)) => {
533+
let offset = parser.get_offset();
534+
543535
let block_info = if s.is_empty() {
544536
LangString::all_false()
545537
} else {
546538
LangString::parse(&*s, error_codes)
547539
};
548540
if !block_info.rust {
549-
continue
541+
continue;
550542
}
551543
let mut test_s = String::new();
552-
let mut offset = None;
553-
loop {
554-
let event = parser.next();
555-
if let Some(event) = event {
556-
match event {
557-
Event::End(Tag::CodeBlock(_)) => break,
558-
Event::Text(ref s) => {
559-
test_s.push_str(s);
560-
if offset.is_none() {
561-
offset = Some(parser.get_offset());
562-
}
563-
}
564-
_ => {}
565-
}
566-
} else {
567-
break 'main;
568-
}
569-
}
570-
if let Some(offset) = offset {
571-
let lines = test_s.lines().map(|l| map_line(l).for_code());
572-
let text = lines.collect::<Vec<Cow<'_, str>>>().join("\n");
573-
nb_lines += doc[prev_offset..offset].lines().count();
574-
let line = tests.get_line() + (nb_lines - 1);
575-
tests.add_test(text, block_info, line);
576-
prev_offset = offset;
577-
} else {
578-
return Err(TestableCodeError(()));
544+
545+
while let Some(Event::Text(s)) = parser.next() {
546+
test_s.push_str(&s);
579547
}
548+
549+
let text = test_s
550+
.lines()
551+
.map(|l| map_line(l).for_code())
552+
.collect::<Vec<Cow<'_, str>>>()
553+
.join("\n");
554+
nb_lines += doc[prev_offset..offset].lines().count();
555+
let line = tests.get_line() + nb_lines;
556+
tests.add_test(text, block_info, line);
557+
prev_offset = offset;
580558
}
581559
Event::Start(Tag::Header(level)) => {
582560
register_header = Some(level as u32);
@@ -593,7 +571,6 @@ pub fn find_testable_code<T: test::Tester>(
593571
_ => {}
594572
}
595573
}
596-
Ok(())
597574
}
598575

599576
#[derive(Eq, PartialEq, Clone, Debug)]
@@ -687,10 +664,6 @@ impl<'a> fmt::Display for Markdown<'a> {
687664

688665
// This is actually common enough to special-case
689666
if md.is_empty() { return Ok(()) }
690-
let mut opts = Options::empty();
691-
opts.insert(OPTION_ENABLE_TABLES);
692-
opts.insert(OPTION_ENABLE_FOOTNOTES);
693-
694667
let replacer = |_: &str, s: &str| {
695668
if let Some(&(_, ref replace)) = links.into_iter().find(|link| &*link.0 == s) {
696669
Some((replace.clone(), s.to_owned()))
@@ -699,7 +672,7 @@ impl<'a> fmt::Display for Markdown<'a> {
699672
}
700673
};
701674

702-
let p = Parser::new_with_broken_link_callback(md, opts, Some(&replacer));
675+
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&replacer));
703676

704677
let mut s = String::with_capacity(md.len() * 3 / 2);
705678

@@ -718,11 +691,7 @@ impl<'a> fmt::Display for MarkdownWithToc<'a> {
718691
let MarkdownWithToc(md, ref ids, codes) = *self;
719692
let mut ids = ids.borrow_mut();
720693

721-
let mut opts = Options::empty();
722-
opts.insert(OPTION_ENABLE_TABLES);
723-
opts.insert(OPTION_ENABLE_FOOTNOTES);
724-
725-
let p = Parser::new_ext(md, opts);
694+
let p = Parser::new_ext(md, opts());
726695

727696
let mut s = String::with_capacity(md.len() * 3 / 2);
728697

@@ -748,11 +717,7 @@ impl<'a> fmt::Display for MarkdownHtml<'a> {
748717

749718
// This is actually common enough to special-case
750719
if md.is_empty() { return Ok(()) }
751-
let mut opts = Options::empty();
752-
opts.insert(OPTION_ENABLE_TABLES);
753-
opts.insert(OPTION_ENABLE_FOOTNOTES);
754-
755-
let p = Parser::new_ext(md, opts);
720+
let p = Parser::new_ext(md, opts());
756721

757722
// Treat inline HTML as plain text.
758723
let p = p.map(|event| match event {
@@ -868,10 +833,6 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
868833
return vec![];
869834
}
870835

871-
let mut opts = Options::empty();
872-
opts.insert(OPTION_ENABLE_TABLES);
873-
opts.insert(OPTION_ENABLE_FOOTNOTES);
874-
875836
let mut links = vec![];
876837
let shortcut_links = RefCell::new(vec![]);
877838

@@ -894,20 +855,19 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
894855
shortcut_links.borrow_mut().push((s.to_owned(), locate(s)));
895856
None
896857
};
897-
let p = Parser::new_with_broken_link_callback(md, opts,
898-
Some(&push));
858+
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&push));
899859

900860
// There's no need to thread an IdMap through to here because
901861
// the IDs generated aren't going to be emitted anywhere.
902862
let mut ids = IdMap::new();
903863
let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids));
904864

905865
for ev in iter {
906-
if let Event::Start(Tag::Link(dest, _)) = ev {
866+
if let Event::Start(Tag::Link(_, dest, _)) = ev {
907867
debug!("found link: {}", dest);
908868
links.push(match dest {
909-
Cow::Borrowed(s) => (s.to_owned(), locate(s)),
910-
Cow::Owned(s) => (s, None),
869+
CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
870+
s @ CowStr::Boxed(..) | s @ CowStr::Inlined(..) => (s.into_string(), None),
911871
});
912872
}
913873
}
@@ -939,10 +899,7 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
939899
return code_blocks;
940900
}
941901

942-
let mut opts = Options::empty();
943-
opts.insert(OPTION_ENABLE_TABLES);
944-
opts.insert(OPTION_ENABLE_FOOTNOTES);
945-
let mut p = Parser::new_ext(md, opts);
902+
let mut p = Parser::new_ext(md, opts());
946903

947904
let mut code_block_start = 0;
948905
let mut code_start = 0;
@@ -1013,7 +970,7 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
1013970
end: code_end,
1014971
},
1015972
syntax: if !syntax.is_empty() {
1016-
Some(syntax.into_owned())
973+
Some(syntax.into_string())
1017974
} else {
1018975
None
1019976
},

0 commit comments

Comments
 (0)