Skip to content

Commit

Permalink
Rollup merge of rust-lang#44368 - ollie27:rustdoc_pulldown_ids, r=Qui…
Browse files Browse the repository at this point in the history
…etMisdreavus

rustdoc: Don't counts ids twice when using --enable-commonmark

cc @GuillaumeGomez
r? @QuietMisdreavus
  • Loading branch information
frewsxcv authored Sep 15, 2017
2 parents 4e646ba + 55f9087 commit 9761a8d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1762,9 +1762,13 @@ fn render_markdown(w: &mut fmt::Formatter,
prefix: &str,
scx: &SharedContext)
-> fmt::Result {
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
// We only emit warnings if the user has opted-in to Pulldown rendering.
let output = if render_type == RenderType::Pulldown {
// Save the state of USED_ID_MAP so it only gets updated once even
// though we're rendering twice.
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone());
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map);
let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown));
let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output);
differences.retain(|s| {
Expand All @@ -1785,7 +1789,7 @@ fn render_markdown(w: &mut fmt::Formatter,

pulldown_output
} else {
hoedown_output
format!("{}", Markdown(md_text, RenderType::Hoedown))
};

write!(w, "<div class='docblock'>{}{}</div>", prefix, output)
Expand Down

0 comments on commit 9761a8d

Please sign in to comment.