Skip to content

Commit 7289731

Browse files
authored
Rollup merge of rust-lang#44368 - ollie27:rustdoc_pulldown_ids, r=QuietMisdreavus
rustdoc: Don't counts ids twice when using --enable-commonmark cc @GuillaumeGomez r? @QuietMisdreavus
2 parents 0952276 + 55f9087 commit 7289731

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/html/render.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1762,9 +1762,13 @@ fn render_markdown(w: &mut fmt::Formatter,
17621762
prefix: &str,
17631763
scx: &SharedContext)
17641764
-> fmt::Result {
1765-
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
17661765
// We only emit warnings if the user has opted-in to Pulldown rendering.
17671766
let output = if render_type == RenderType::Pulldown {
1767+
// Save the state of USED_ID_MAP so it only gets updated once even
1768+
// though we're rendering twice.
1769+
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone());
1770+
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
1771+
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map);
17681772
let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown));
17691773
let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output);
17701774
differences.retain(|s| {
@@ -1785,7 +1789,7 @@ fn render_markdown(w: &mut fmt::Formatter,
17851789

17861790
pulldown_output
17871791
} else {
1788-
hoedown_output
1792+
format!("{}", Markdown(md_text, RenderType::Hoedown))
17891793
};
17901794

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

0 commit comments

Comments
 (0)