Skip to content

Commit f60aeec

Browse files
committed
Include shortcut links in markdown_links
1 parent 6818551 commit f60aeec

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/librustdoc/html/markdown.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -731,18 +731,30 @@ pub fn markdown_links(md: &str) -> Vec<String> {
731731
opts.insert(OPTION_ENABLE_TABLES);
732732
opts.insert(OPTION_ENABLE_FOOTNOTES);
733733

734-
let p = Parser::new_ext(md, opts);
735-
736-
let iter = Footnotes::new(HeadingLinks::new(p, None));
737734
let mut links = vec![];
735+
let shortcut_links = RefCell::new(vec![]);
736+
737+
{
738+
let push = |_: &str, s: &str| {
739+
shortcut_links.borrow_mut().push(s.to_owned());
740+
None
741+
};
742+
let p = Parser::new_with_broken_link_callback(md, opts,
743+
Some(&push));
738744

739-
for ev in iter {
740-
if let Event::Start(Tag::Link(dest, _)) = ev {
741-
debug!("found link: {}", dest);
742-
links.push(dest.into_owned());
745+
let iter = Footnotes::new(HeadingLinks::new(p, None));
746+
747+
for ev in iter {
748+
if let Event::Start(Tag::Link(dest, _)) = ev {
749+
debug!("found link: {}", dest);
750+
links.push(dest.into_owned());
751+
}
743752
}
744753
}
745754

755+
let mut shortcut_links = shortcut_links.into_inner();
756+
links.extend(shortcut_links.drain(..));
757+
746758
links
747759
}
748760

0 commit comments

Comments
 (0)