about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-12-10 21:01:48 +0100
committerPietro Albini <pietro@pietroalbini.org>2022-12-12 15:35:25 +0100
commit76184b1ba7487b59a350a610ced89898b30eda7e (patch)
treea00f079d9badac290a4fa3bad14dcabc6b4d7595 /src
parent47141d6e7a4b7f8d575779517ff940dbd490e035 (diff)
downloadrust-76184b1ba7487b59a350a610ced89898b30eda7e.tar.gz
rust-76184b1ba7487b59a350a610ced89898b30eda7e.zip
Don't take into account hashtag prepended lines if not in rust code block
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/markdown.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 5ce62224d35..1e1c657b0bf 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -246,8 +246,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
                 _ => {}
             }
         }
-        let lines = origtext.lines().filter_map(|l| map_line(l).for_html());
-        let text = lines.intersperse("\n".into()).collect::<String>();
 
         let parse_result = match kind {
             CodeBlockKind::Fenced(ref lang) => {
@@ -260,7 +258,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
                                  <pre class=\"language-{}\"><code>{}</code></pre>\
                              </div>",
                             lang,
-                            Escape(&text),
+                            Escape(&origtext),
                         )
                         .into(),
                     ));
@@ -270,6 +268,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
             CodeBlockKind::Indented => Default::default(),
         };
 
+        let lines = origtext.lines().filter_map(|l| map_line(l).for_html());
+        let text = lines.intersperse("\n".into()).collect::<String>();
+
         compile_fail = parse_result.compile_fail;
         should_panic = parse_result.should_panic;
         ignore = parse_result.ignore;