Skip to content

Commit 55f9087

Browse files
committed
rustdoc: Don't counts ids twice when using --enable-commonmark
1 parent 2f1ef9e commit 55f9087

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
@@ -1752,9 +1752,13 @@ fn render_markdown(w: &mut fmt::Formatter,
17521752
prefix: &str,
17531753
scx: &SharedContext)
17541754
-> fmt::Result {
1755-
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
17561755
// We only emit warnings if the user has opted-in to Pulldown rendering.
17571756
let output = if render_type == RenderType::Pulldown {
1757+
// Save the state of USED_ID_MAP so it only gets updated once even
1758+
// though we're rendering twice.
1759+
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone());
1760+
let hoedown_output = format!("{}", Markdown(md_text, RenderType::Hoedown));
1761+
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map);
17581762
let pulldown_output = format!("{}", Markdown(md_text, RenderType::Pulldown));
17591763
let differences = html_diff::get_differences(&pulldown_output, &hoedown_output);
17601764
let differences = differences.into_iter()
@@ -1775,7 +1779,7 @@ fn render_markdown(w: &mut fmt::Formatter,
17751779

17761780
pulldown_output
17771781
} else {
1778-
hoedown_output
1782+
format!("{}", Markdown(md_text, RenderType::Hoedown))
17791783
};
17801784

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

0 commit comments

Comments
 (0)