Add LinkReplacer pass for pulldown
This commit is contained in:
@@ -1861,12 +1861,13 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
|
||||
/// rendering between Pulldown and Hoedown.
|
||||
fn render_markdown(w: &mut fmt::Formatter,
|
||||
md_text: &str,
|
||||
links: Vec<(String, String)>,
|
||||
span: Span,
|
||||
render_type: RenderType,
|
||||
prefix: &str,
|
||||
scx: &SharedContext)
|
||||
-> fmt::Result {
|
||||
let (hoedown_output, pulldown_output) = render_text(|ty| format!("{}", Markdown(md_text, ty)));
|
||||
let (hoedown_output, pulldown_output) = render_text(|ty| format!("{}", Markdown(md_text, &links, ty)));
|
||||
let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output);
|
||||
differences.retain(|s| {
|
||||
match *s {
|
||||
@@ -1898,7 +1899,7 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin
|
||||
} else {
|
||||
format!("{}", &plain_summary_line(Some(s)))
|
||||
};
|
||||
render_markdown(w, &markdown, item.source.clone(), cx.render_type, prefix, &cx.shared)?;
|
||||
render_markdown(w, &markdown, item.links(), item.source.clone(), cx.render_type, prefix, &cx.shared)?;
|
||||
} else if !prefix.is_empty() {
|
||||
write!(w, "<div class='docblock'>{}</div>", prefix)?;
|
||||
}
|
||||
@@ -1924,7 +1925,7 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
|
||||
cx: &Context, prefix: &str) -> fmt::Result {
|
||||
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
|
||||
debug!("Doc block: =====\n{}\n=====", s);
|
||||
render_markdown(w, &*s, item.source.clone(), cx.render_type, prefix, &cx.shared)?;
|
||||
render_markdown(w, &*s, item.links(), item.source.clone(), cx.render_type, prefix, &cx.shared)?;
|
||||
} else if !prefix.is_empty() {
|
||||
write!(w, "<div class='docblock'>{}</div>", prefix)?;
|
||||
}
|
||||
@@ -2146,10 +2147,10 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||
stab_docs = stab_docs,
|
||||
docs = if cx.render_type == RenderType::Hoedown {
|
||||
format!("{}",
|
||||
shorter(Some(&Markdown(doc_value,
|
||||
shorter(Some(&Markdown(doc_value, &item.links(),
|
||||
RenderType::Hoedown).to_string())))
|
||||
} else {
|
||||
format!("{}", MarkdownSummaryLine(doc_value))
|
||||
format!("{}", MarkdownSummaryLine(doc_value, &item.links()))
|
||||
},
|
||||
class = myitem.type_(),
|
||||
stab = myitem.stability_class().unwrap_or("".to_string()),
|
||||
@@ -3338,7 +3339,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
write!(w, "</span>")?;
|
||||
write!(w, "</h3>\n")?;
|
||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
||||
write!(w, "<div class='docblock'>{}</div>", Markdown(&*dox, cx.render_type))?;
|
||||
write!(w, "<div class='docblock'>{}</div>", Markdown(&*dox, &i.impl_item.links(), cx.render_type))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user