Skip to content

Commit b6cc030

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 86402ad + 55f9087 commit b6cc030

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
@@ -1764,9 +1764,13 @@ fn render_markdown(w: &mut fmt::Formatter,
17641764
prefix: &str,
17651765
scx: &SharedContext)
17661766
-> fmt::Result {
1767-
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
17681767
// We only emit warnings if the user has opted-in to Pulldown rendering.
17691768
let output = if render_type == RenderType::Pulldown {
1769+
// Save the state of USED_ID_MAP so it only gets updated once even
1770+
// though we're rendering twice.
1771+
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone());
1772+
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
1773+
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map);
17701774
let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown));
17711775
let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output);
17721776
differences.retain(|s| {
@@ -1787,7 +1791,7 @@ fn render_markdown(w: &mut fmt::Formatter,
17871791

17881792
pulldown_output
17891793
} else {
1790-
hoedown_output
1794+
format!("{}", Markdown(md_text, RenderType::Hoedown))
17911795
};
17921796

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

0 commit comments

Comments
 (0)