mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Include shortcut links in markdown_links
This commit is contained in:
parent
6818551c6f
commit
f60aeec5d5
@ -731,18 +731,30 @@ pub fn markdown_links(md: &str) -> Vec<String> {
|
||||
opts.insert(OPTION_ENABLE_TABLES);
|
||||
opts.insert(OPTION_ENABLE_FOOTNOTES);
|
||||
|
||||
let p = Parser::new_ext(md, opts);
|
||||
|
||||
let iter = Footnotes::new(HeadingLinks::new(p, None));
|
||||
let mut links = vec![];
|
||||
let shortcut_links = RefCell::new(vec![]);
|
||||
|
||||
for ev in iter {
|
||||
if let Event::Start(Tag::Link(dest, _)) = ev {
|
||||
debug!("found link: {}", dest);
|
||||
links.push(dest.into_owned());
|
||||
{
|
||||
let push = |_: &str, s: &str| {
|
||||
shortcut_links.borrow_mut().push(s.to_owned());
|
||||
None
|
||||
};
|
||||
let p = Parser::new_with_broken_link_callback(md, opts,
|
||||
Some(&push));
|
||||
|
||||
let iter = Footnotes::new(HeadingLinks::new(p, None));
|
||||
|
||||
for ev in iter {
|
||||
if let Event::Start(Tag::Link(dest, _)) = ev {
|
||||
debug!("found link: {}", dest);
|
||||
links.push(dest.into_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut shortcut_links = shortcut_links.into_inner();
|
||||
links.extend(shortcut_links.drain(..));
|
||||
|
||||
links
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user