Generate shortcut links
This commit is contained in:
parent
f60aeec5d5
commit
1d0ae9f174
1 changed files with 19 additions and 2 deletions
|
|
@ -591,7 +591,15 @@ impl<'a> fmt::Display for Markdown<'a> {
|
|||
opts.insert(OPTION_ENABLE_TABLES);
|
||||
opts.insert(OPTION_ENABLE_FOOTNOTES);
|
||||
|
||||
let p = Parser::new_ext(md, opts);
|
||||
let replacer = |_: &str, s: &str| {
|
||||
if let Some(&(_, ref replace)) = links.into_iter().find(|link| &*link.0 == s) {
|
||||
Some((replace.clone(), s.to_owned()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let p = Parser::new_with_broken_link_callback(md, opts, Some(&replacer));
|
||||
|
||||
let mut s = String::with_capacity(md.len() * 3 / 2);
|
||||
|
||||
|
|
@ -662,7 +670,16 @@ impl<'a> fmt::Display for MarkdownSummaryLine<'a> {
|
|||
// This is actually common enough to special-case
|
||||
if md.is_empty() { return Ok(()) }
|
||||
|
||||
let p = Parser::new(md);
|
||||
let replacer = |_: &str, s: &str| {
|
||||
if let Some(&(_, ref replace)) = links.into_iter().find(|link| &*link.0 == s) {
|
||||
Some((replace.clone(), s.to_owned()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let p = Parser::new_with_broken_link_callback(md, Options::empty(),
|
||||
Some(&replacer));
|
||||
|
||||
let mut s = String::new();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue