about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-12-10 21:02:08 +0100
committerPietro Albini <pietro@pietroalbini.org>2022-12-12 15:35:29 +0100
commit94b305dc371f002dee75a31b1afa22cb168023ab (patch)
tree3ad418fb9aa6edbbaf921e4094bbae71d7690127
parent76184b1ba7487b59a350a610ced89898b30eda7e (diff)
downloadrust-94b305dc371f002dee75a31b1afa22cb168023ab.tar.gz
rust-94b305dc371f002dee75a31b1afa22cb168023ab.zip
Add test for non-rust code block hashtag prepended lines
-rw-r--r--src/librustdoc/html/markdown/tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index e4f72a05789..68b31a6ee08 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -309,3 +309,40 @@ fn test_find_testable_code_line() {
     t("```rust\n```\n```rust\n```", &[1, 3]);
     t("```rust\n```\n ```rust\n```", &[1, 3]);
 }
+
+#[test]
+fn test_ascii_with_prepending_hashtag() {
+    fn t(input: &str, expect: &str) {
+        let mut map = IdMap::new();
+        let output = Markdown {
+            content: input,
+            links: &[],
+            ids: &mut map,
+            error_codes: ErrorCodes::Yes,
+            edition: DEFAULT_EDITION,
+            playground: &None,
+            heading_offset: HeadingOffset::H2,
+        }
+        .into_string();
+        assert_eq!(output, expect, "original: {}", input);
+    }
+
+    t(
+        r#"```ascii
+#..#.####.#....#.....##..
+#..#.#....#....#....#..#.
+####.###..#....#....#..#.
+#..#.#....#....#....#..#.
+#..#.#....#....#....#..#.
+#..#.####.####.####..##..
+```"#,
+        "<div class=\"example-wrap\"><pre class=\"language-ascii\"><code>\
+#..#.####.#....#.....##..
+#..#.#....#....#....#..#.
+####.###..#....#....#..#.
+#..#.#....#....#....#..#.
+#..#.#....#....#....#..#.
+#..#.####.####.####..##..
+</code></pre></div>",
+    );
+}