From 03443f723c415ccf475297a782054f160cf8a7e1 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 16 Sep 2025 14:07:54 -0700 Subject: [PATCH] Add more comprehensive tests for HTML rendering This adds a bunch of tests to better exercise the HTML rendering and to be able to track any changes in its behavior. This includes a new `check_all_main_files` to more conveniently check the HTML content of every chapter in a book. --- tests/testsuite/book_test.rs | 66 ++++++- tests/testsuite/markdown.rs | 17 ++ .../markdown/basic_markdown/book.toml | 2 + .../basic_markdown/expected/blank.html | 0 .../basic_markdown/expected/blockquotes.html | 44 +++++ .../basic_markdown/expected/code-blocks.html | 22 +++ .../basic_markdown/expected/html.html | 67 +++++++ .../basic_markdown/expected/images.html | 3 + .../basic_markdown/expected/inlines.html | 8 + .../basic_markdown/expected/links.html | 16 ++ .../basic_markdown/expected/lists.html | 50 +++++ .../markdown/basic_markdown/expected/svg.html | 12 ++ .../markdown/basic_markdown/src/SUMMARY.md | 11 ++ .../markdown/basic_markdown/src/blank.md | 0 .../basic_markdown/src/blockquotes.md | 31 +++ .../basic_markdown/src/code-blocks.md | 31 +++ .../markdown/basic_markdown/src/html.md | 94 +++++++++ .../markdown/basic_markdown/src/images.md | 12 ++ .../markdown/basic_markdown/src/inlines.md | 13 ++ .../markdown/basic_markdown/src/links.md | 18 ++ .../markdown/basic_markdown/src/lists.md | 40 ++++ .../markdown/basic_markdown/src/svg.md | 14 ++ .../src/custom_header_attributes.md | 2 + .../src/smart_punctuation.md | 5 + tests/testsuite/markdown/tables/src/tables.md | 4 + .../disabled_playground/src/SUMMARY.md | 2 +- .../{index.md => disabled-rust-playground.md} | 0 .../playground_on_rust_code/src/SUMMARY.md | 2 +- .../src/{index.md => rust-playground.md} | 0 tests/testsuite/print.rs | 38 ++-- tests/testsuite/print/chapter_no_h1/book.toml | 2 + .../print/chapter_no_h1/expected/print.html | 5 + .../print/chapter_no_h1/src/SUMMARY.md | 5 + .../print/chapter_no_h1/src/chapter_1.md | 3 + .../print/chapter_no_h1/src/chapter_2.md | 1 + .../print/chapter_no_h1/src/h2-instead.md | 4 + tests/testsuite/print/duplicate_ids/book.toml | 2 + .../print/duplicate_ids/expected/print.html | 11 ++ .../print/duplicate_ids/src/SUMMARY.md | 4 + .../print/duplicate_ids/src/chapter_1.md | 9 + .../print/duplicate_ids/src/chapter_2.md | 11 ++ tests/testsuite/print/noindex/src/index.md | 1 + .../print/relative_links/expected/print.html | 15 ++ .../print/relative_links/src/second/nested.md | 10 +- tests/testsuite/rendering.rs | 184 ++++++++++++++++++ .../rendering/default_rust_edition/book.toml | 5 + .../expected/default-rust-edition.html | 13 ++ .../default_rust_edition/src/SUMMARY.md | 3 + .../src/default-rust-edition.md | 13 ++ .../rendering/editable_rust_block/book.toml | 5 + .../expected/editable-rust.html | 8 + .../editable_rust_block/src/SUMMARY.md | 3 + .../editable_rust_block/src/editable-rust.md | 11 ++ .../testsuite/rendering/fontawesome/book.toml | 2 + .../rendering/fontawesome/expected/fa.html | 5 + .../rendering/fontawesome/src/SUMMARY.md | 3 + .../testsuite/rendering/fontawesome/src/fa.md | 9 + .../rendering/header_links/book.toml | 2 + .../header_links/expected/header_links.html | 10 + .../rendering/header_links/src/SUMMARY.md | 3 + .../header_links/src/header_links.md | 19 ++ tests/testsuite/rendering/hidelines/book.toml | 5 + .../hidelines/expected/hide-lines.html | 23 +++ .../rendering/hidelines/src/SUMMARY.md | 3 + .../rendering/hidelines/src/hide-lines.md | 27 +++ .../testsuite/rendering/html_blocks/book.toml | 2 + .../html_blocks/expected/comment-in-list.html | 6 + .../rendering/html_blocks/src/SUMMARY.md | 3 + .../html_blocks/src/comment-in-list.md | 3 + 69 files changed, 1054 insertions(+), 23 deletions(-) create mode 100644 tests/testsuite/markdown/basic_markdown/book.toml create mode 100644 tests/testsuite/markdown/basic_markdown/expected/blank.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/blockquotes.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/code-blocks.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/html.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/images.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/inlines.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/links.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/lists.html create mode 100644 tests/testsuite/markdown/basic_markdown/expected/svg.html create mode 100644 tests/testsuite/markdown/basic_markdown/src/SUMMARY.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/blank.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/blockquotes.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/code-blocks.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/html.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/images.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/inlines.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/links.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/lists.md create mode 100644 tests/testsuite/markdown/basic_markdown/src/svg.md rename tests/testsuite/playground/disabled_playground/src/{index.md => disabled-rust-playground.md} (100%) rename tests/testsuite/playground/playground_on_rust_code/src/{index.md => rust-playground.md} (100%) create mode 100644 tests/testsuite/print/chapter_no_h1/book.toml create mode 100644 tests/testsuite/print/chapter_no_h1/expected/print.html create mode 100644 tests/testsuite/print/chapter_no_h1/src/SUMMARY.md create mode 100644 tests/testsuite/print/chapter_no_h1/src/chapter_1.md create mode 100644 tests/testsuite/print/chapter_no_h1/src/chapter_2.md create mode 100644 tests/testsuite/print/chapter_no_h1/src/h2-instead.md create mode 100644 tests/testsuite/print/duplicate_ids/book.toml create mode 100644 tests/testsuite/print/duplicate_ids/expected/print.html create mode 100644 tests/testsuite/print/duplicate_ids/src/SUMMARY.md create mode 100644 tests/testsuite/print/duplicate_ids/src/chapter_1.md create mode 100644 tests/testsuite/print/duplicate_ids/src/chapter_2.md create mode 100644 tests/testsuite/print/noindex/src/index.md create mode 100644 tests/testsuite/print/relative_links/expected/print.html create mode 100644 tests/testsuite/rendering/default_rust_edition/book.toml create mode 100644 tests/testsuite/rendering/default_rust_edition/expected/default-rust-edition.html create mode 100644 tests/testsuite/rendering/default_rust_edition/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/default_rust_edition/src/default-rust-edition.md create mode 100644 tests/testsuite/rendering/editable_rust_block/book.toml create mode 100644 tests/testsuite/rendering/editable_rust_block/expected/editable-rust.html create mode 100644 tests/testsuite/rendering/editable_rust_block/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/editable_rust_block/src/editable-rust.md create mode 100644 tests/testsuite/rendering/fontawesome/book.toml create mode 100644 tests/testsuite/rendering/fontawesome/expected/fa.html create mode 100644 tests/testsuite/rendering/fontawesome/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/fontawesome/src/fa.md create mode 100644 tests/testsuite/rendering/header_links/book.toml create mode 100644 tests/testsuite/rendering/header_links/expected/header_links.html create mode 100644 tests/testsuite/rendering/header_links/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/header_links/src/header_links.md create mode 100644 tests/testsuite/rendering/hidelines/book.toml create mode 100644 tests/testsuite/rendering/hidelines/expected/hide-lines.html create mode 100644 tests/testsuite/rendering/hidelines/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/hidelines/src/hide-lines.md create mode 100644 tests/testsuite/rendering/html_blocks/book.toml create mode 100644 tests/testsuite/rendering/html_blocks/expected/comment-in-list.html create mode 100644 tests/testsuite/rendering/html_blocks/src/SUMMARY.md create mode 100644 tests/testsuite/rendering/html_blocks/src/comment-in-list.md diff --git a/tests/testsuite/book_test.rs b/tests/testsuite/book_test.rs index 5b9db068..0dd7a947 100644 --- a/tests/testsuite/book_test.rs +++ b/tests/testsuite/book_test.rs @@ -23,6 +23,8 @@ enum StatusCode { pub struct BookTest { /// The temp directory where the test should perform its work. pub dir: PathBuf, + /// The original source directory if created from [`BookTest::from_dir`]. + original_source: Option, /// Snapshot assertion support. pub assert: snapbox::Assert, /// This indicates whether or not the book has been built. @@ -45,12 +47,12 @@ impl BookTest { &[], ) .unwrap_or_else(|e| panic!("failed to copy test book {dir:?} to {tmp:?}: {e:?}")); - Self::new(tmp) + Self::new(tmp, Some(dir)) } /// Creates a new test with an empty temp directory. pub fn empty() -> BookTest { - Self::new(Self::new_tmp()) + Self::new(Self::new_tmp(), None) } /// Creates a new test with the given function to initialize a new book. @@ -62,7 +64,7 @@ impl BookTest { f(&mut bb); bb.build() .unwrap_or_else(|e| panic!("failed to initialize book at {tmp:?}: {e:?}")); - Self::new(tmp) + Self::new(tmp, None) } fn new_tmp() -> PathBuf { @@ -78,10 +80,11 @@ impl BookTest { tmp } - fn new(dir: PathBuf) -> BookTest { + fn new(dir: PathBuf, original_source: Option) -> BookTest { let assert = assert(&dir); BookTest { dir, + original_source, assert, built: false, } @@ -101,13 +104,64 @@ impl BookTest { let actual = read_to_string(&full_path); let start = actual .find("
") - .unwrap_or_else(|| panic!("didn't find
in:\n{actual}")); + .unwrap_or_else(|| panic!("didn't find
for `{full_path:?}` in:\n{actual}")); let end = actual.find("
").unwrap(); let contents = actual[start + 6..end - 7].trim(); self.assert.eq(contents, expected); self } + /// Verifies the HTML output of all chapters in a book. + /// + /// This calls [`BookTest::check_main_file`] for every `.html` file + /// generated by building the book. All of expected files are stored in a + /// director called "expected" in the original book source directory. + /// + /// This only works when created with [`BookTest::from_dir`]. + /// + /// `404.html`, `print.html`, and `toc.html` are not validated. The root + /// `index.html` is also not validated (since it is often duplicated with + /// the first chapter). If you need to validate it, call + /// [`BookTest::check_main_file`] directly. + #[track_caller] + pub fn check_all_main_files(&mut self) -> &mut Self { + if !self.built { + self.build(); + } + let book_root = self.dir.join("book"); + let mut files = list_all_files(&book_root); + files.retain(|file| { + file.extension().is_some_and(|ext| ext == "html") + && !matches!( + file.to_str().unwrap(), + "index.html" | "404.html" | "print.html" | "toc.html" + ) + }); + let expected_path = self + .original_source + .as_ref() + .expect("created with BookTest::from_dir") + .join("expected"); + let mut expected_list = list_all_files(&expected_path); + for file in &files { + let expected = expected_path.join(file); + let data = snapbox::Data::read_from(&expected, None); + self.check_main_file(book_root.join(file).to_str().unwrap(), data); + if let Some(i) = expected_list.iter().position(|p| p == file) { + expected_list.remove(i); + } + } + // Verify there aren't any unused expected files. + if !expected_list.is_empty() { + panic!( + "extra expected files found in `{expected_path:?}:\n\ + {expected_list:#?}\n\ + Verify that these files are no longer needed and delete them." + ); + } + self + } + /// Checks the summary contents of `toc.js` against the expected value. #[track_caller] pub fn check_toc_js(&mut self, expected: impl IntoData) -> &mut Self { @@ -527,6 +581,8 @@ pub fn list_all_files(dir: &Path) -> Vec { walkdir::WalkDir::new(dir) .sort_by_file_name() .into_iter() + // Skip the outer directory. + .skip(1) .map(|entry| { let entry = entry.unwrap(); let path = entry.path(); diff --git a/tests/testsuite/markdown.rs b/tests/testsuite/markdown.rs index 8317b2a6..8237215c 100644 --- a/tests/testsuite/markdown.rs +++ b/tests/testsuite/markdown.rs @@ -11,6 +11,7 @@ fn custom_header_attributes() {

Heading Attributes

Heading with classes

Heading with id and classes

+

Heading with attribute

"##]]); } @@ -50,6 +51,9 @@ fn tables() { Pipe in code| Pipe in code2test | inside +
+ +
NeitherLeftCenterRight
onetwothreefour
"##]], ); @@ -101,7 +105,10 @@ fn smart_punctuation() {
  • Ellipsis: …
  • Double quote: “quote”
  • Single quote: ‘quote’
  • +
  • Quote in "code"
  • +
    "quoted"
    +
    "##]], ) .run("build", |cmd| { @@ -117,7 +124,17 @@ fn smart_punctuation() {
  • Ellipsis: ...
  • Double quote: "quote"
  • Single quote: 'quote'
  • +
  • Quote in "code"
  • +
    "quoted"
    +
    "##]], ); } + +// Basic markdown syntax. +// This doesn't try to cover the commonmark test suite, but maybe it could some day? +#[test] +fn basic_markdown() { + BookTest::from_dir("markdown/basic_markdown").check_all_main_files(); +} diff --git a/tests/testsuite/markdown/basic_markdown/book.toml b/tests/testsuite/markdown/basic_markdown/book.toml new file mode 100644 index 00000000..aa391a48 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/book.toml @@ -0,0 +1,2 @@ +[book] +title = "basic_markdown" diff --git a/tests/testsuite/markdown/basic_markdown/expected/blank.html b/tests/testsuite/markdown/basic_markdown/expected/blank.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/testsuite/markdown/basic_markdown/expected/blockquotes.html b/tests/testsuite/markdown/basic_markdown/expected/blockquotes.html new file mode 100644 index 00000000..3be37bed --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/blockquotes.html @@ -0,0 +1,44 @@ +

    Blockquotes

    +

    Empty:

    +
    +
    +

    Normal:

    +
    +

    foo +bar

    +
    +

    Contains code block:

    +
    +
    #![allow(unused)]
    +fn main() {
    +let x = 1;
    +}
    +
    +

    Random stuff:

    +
    +

    And now,

    +

    Let us introduce +All kinds of

    +
      +
    • tags
    • +
    • etc
    • +
    • stuff
    • +
    +
      +
    1. +

      In

      +
    2. +
    3. +

      The

      +
    4. +
    5. +

      blockquote

      +
      +

      cause we can

      +
      +

      Cause we can

      +
      +
      +
    6. +
    +
    \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/code-blocks.html b/tests/testsuite/markdown/basic_markdown/expected/code-blocks.html new file mode 100644 index 00000000..09b7b2ba --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/code-blocks.html @@ -0,0 +1,22 @@ +

    Code blocks

    +
    This is a codeblock
    +
    +
    #![allow(unused)]
    +fn main() {
    +// This links to a playpen
    +}
    +
    # This is an editable codeblock
    +
    +
    Text with different classes.
    +
    +
    Indented
    +code
    +block.
    +
    +
    #![allow(unused)]
    +fn main() {
    +let x = 1;
    +}
    +
    fn main() {
    +    println!("hello");
    +}
    \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/html.html b/tests/testsuite/markdown/basic_markdown/expected/html.html new file mode 100644 index 00000000..ac7aa2c2 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/html.html @@ -0,0 +1,67 @@ +

    Inline HTML

    +

    Comments

    + + +

    Void elements

    + + alt text + +

    Line
    break

    +

    Wordbreak

    + + + + + +
    +

    +

    Rule:

    +
    + + + +

    + +

    Blocks

    +
    +A block HTML element trying to do *markup*. +
    +
    +

    A block HTML with spaces that cause it to be interleaved with markdown.

    +
    +

    Scripts

    + + + +

    Style

    + + \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/images.html b/tests/testsuite/markdown/basic_markdown/expected/images.html new file mode 100644 index 00000000..be7e4152 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/images.html @@ -0,0 +1,3 @@ +

    Images

    +

    Image “alt” & " "text" & <stuff> url <em>html</em> — hard break

    +

    Image with title

    \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/inlines.html b/tests/testsuite/markdown/basic_markdown/expected/inlines.html new file mode 100644 index 00000000..306e1221 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/inlines.html @@ -0,0 +1,8 @@ +

    Inlines

    +

    emphasis bold bold emphasis

    +

    Some inline code.

    +

    Hard
    +break

    +

    Invisible hard
    +break

    +

    [escaped] <html> *here*

    \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/links.html b/tests/testsuite/markdown/basic_markdown/expected/links.html new file mode 100644 index 00000000..a8af500a --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/links.html @@ -0,0 +1,16 @@ +

    Links

    + \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/lists.html b/tests/testsuite/markdown/basic_markdown/expected/lists.html new file mode 100644 index 00000000..94dbe9bc --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/lists.html @@ -0,0 +1,50 @@ +

    Lists

    +
      +
    1. A
    2. +
    3. Normal
    4. +
    5. Ordered
    6. +
    7. List
    8. +
    +
    +
      +
    1. A +
        +
      1. Nested
      2. +
      3. List
      4. +
      +
    2. +
    3. But
    4. +
    5. Still
    6. +
    7. Normal
    8. +
    +
    +
      +
    1. Start list
    2. +
    3. with a different number.
    4. +
    +
    +
      +
    • An
    • +
    • Unordered
    • +
    • Normal
    • +
    • List
    • +
    +
    +
      +
    • Nested +
        +
      • Unordered
      • +
      +
    • +
    • List
    • +
    +
    +
      +
    • This +
        +
      1. Is
      2. +
      3. Normal
      4. +
      +
    • +
    • ?!
    • +
    \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/expected/svg.html b/tests/testsuite/markdown/basic_markdown/expected/svg.html new file mode 100644 index 00000000..e2839139 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/expected/svg.html @@ -0,0 +1,12 @@ +

    SVG

    + + + + +SVG + \ No newline at end of file diff --git a/tests/testsuite/markdown/basic_markdown/src/SUMMARY.md b/tests/testsuite/markdown/basic_markdown/src/SUMMARY.md new file mode 100644 index 00000000..6956644a --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/SUMMARY.md @@ -0,0 +1,11 @@ +# Summary + +- [Blank](./blank.md) +- [Blockquotes](./blockquotes.md) +- [Code blocks](./code-blocks.md) +- [Lists](./lists.md) +- [Inlines](./inlines.md) +- [Links](./links.md) +- [Images](./images.md) +- [HTML](./html.md) +- [SVG](./svg.md) diff --git a/tests/testsuite/markdown/basic_markdown/src/blank.md b/tests/testsuite/markdown/basic_markdown/src/blank.md new file mode 100644 index 00000000..e69de29b diff --git a/tests/testsuite/markdown/basic_markdown/src/blockquotes.md b/tests/testsuite/markdown/basic_markdown/src/blockquotes.md new file mode 100644 index 00000000..d7debcf5 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/blockquotes.md @@ -0,0 +1,31 @@ +# Blockquotes + +Empty: +> + +Normal: +> foo +> bar + +Contains code block: +> ```rust +> let x = 1; +> ``` + +Random stuff: +> ### And now, +> +> **Let us _introduce_** +> All kinds of +> +> - tags +> - etc +> - stuff +> +> 1. In +> 2. The +> 3. blockquote +> +> > cause we can +> > +> > > Cause we can diff --git a/tests/testsuite/markdown/basic_markdown/src/code-blocks.md b/tests/testsuite/markdown/basic_markdown/src/code-blocks.md new file mode 100644 index 00000000..67d46716 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/code-blocks.md @@ -0,0 +1,31 @@ +# Code blocks + +``` +This is a codeblock +``` + +```rust +// This links to a playpen +``` + +```bash,editable +# This is an editable codeblock +``` + +```text cls1,,cls2 cls3 +Text with different classes. +``` + + Indented + code + block. + +```rust,edition2021 +let x = 1; +``` + +```rust +fn main() { + println!("hello"); +} +``` diff --git a/tests/testsuite/markdown/basic_markdown/src/html.md b/tests/testsuite/markdown/basic_markdown/src/html.md new file mode 100644 index 00000000..b2383cb4 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/html.md @@ -0,0 +1,94 @@ +# Inline HTML + +## Comments + + + + + +## Void elements + + + alt text + + +Line
    break + +Wordbreak + + + + + + +
    + + + +Rule: +
    + + + + + + + + + + + +## Blocks + +
    +A block HTML element trying to do *markup*. +
    + +
    + +A block HTML with spaces that **cause** it to be interleaved with markdown. + +
    + +## Scripts + + + + + + + +## Style + + + + diff --git a/tests/testsuite/markdown/basic_markdown/src/images.md b/tests/testsuite/markdown/basic_markdown/src/images.md new file mode 100644 index 00000000..e0d28a22 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/images.md @@ -0,0 +1,12 @@ +# Images + +![Image *"alt"* & \" + `"text" & ` + [url](/foo) + html + --- + hard\ + break +](https://rust-lang.org/logos/rust-logo-256x256.png) + +![Image with title](https://rust-lang.org/logos/rust-logo-256x256.png "Some title") diff --git a/tests/testsuite/markdown/basic_markdown/src/inlines.md b/tests/testsuite/markdown/basic_markdown/src/inlines.md new file mode 100644 index 00000000..b05b3c2d --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/inlines.md @@ -0,0 +1,13 @@ +# Inlines + +*emphasis* **bold** **_bold emphasis_** + +Some `inline code`. + +Hard\ +break + +Invisible hard +break + +\[escaped] \ \*here* diff --git a/tests/testsuite/markdown/basic_markdown/src/links.md b/tests/testsuite/markdown/basic_markdown/src/links.md new file mode 100644 index 00000000..8d12c585 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/links.md @@ -0,0 +1,18 @@ +# Links + +- [Inline](https://example.com/inline) +- [Collapsed] +- [Emtpy reference][] +- [Specific reference][specific] +- +- +- [Titled](https://example.com/title "with title") +- [Broken collapsed] +- [Broken reference][missing] +- [Markdown link](path/foo.md) +- [Markdown link anchor](path/foo.md#anchor) +- [Link anchor](#anchor) +- [With md in anchor](path.html#phantomdata) + +[collapsed]: https://example.com/collapsed +[specific]: https://example.com/specific diff --git a/tests/testsuite/markdown/basic_markdown/src/lists.md b/tests/testsuite/markdown/basic_markdown/src/lists.md new file mode 100644 index 00000000..9aba384d --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/lists.md @@ -0,0 +1,40 @@ +# Lists + +1. A +2. Normal +3. Ordered +4. List + +--- + +1. A + 1. Nested + 2. List +2. But +3. Still +4. Normal + +--- + +7. Start list +7. with a different number. + +--- + +- An +- Unordered +- Normal +- List + +--- + +- Nested + - Unordered +- List + +--- + +- This + 1. Is + 2. Normal +- ?! diff --git a/tests/testsuite/markdown/basic_markdown/src/svg.md b/tests/testsuite/markdown/basic_markdown/src/svg.md new file mode 100644 index 00000000..6e53c5d4 --- /dev/null +++ b/tests/testsuite/markdown/basic_markdown/src/svg.md @@ -0,0 +1,14 @@ +# SVG + + + + + +SVG + + diff --git a/tests/testsuite/markdown/custom_header_attributes/src/custom_header_attributes.md b/tests/testsuite/markdown/custom_header_attributes/src/custom_header_attributes.md index a09a22b6..212dcd59 100644 --- a/tests/testsuite/markdown/custom_header_attributes/src/custom_header_attributes.md +++ b/tests/testsuite/markdown/custom_header_attributes/src/custom_header_attributes.md @@ -3,3 +3,5 @@ ## Heading with classes {.class1 .class2} ## Heading with id and classes {#both .class1 .class2} + +## Heading with attribute {.myclass1 myattr #myh3 otherattr=value .myclass2} diff --git a/tests/testsuite/markdown/smart_punctuation/src/smart_punctuation.md b/tests/testsuite/markdown/smart_punctuation/src/smart_punctuation.md index a27f3c32..bf2d47e2 100644 --- a/tests/testsuite/markdown/smart_punctuation/src/smart_punctuation.md +++ b/tests/testsuite/markdown/smart_punctuation/src/smart_punctuation.md @@ -5,3 +5,8 @@ - Ellipsis: ... - Double quote: "quote" - Single quote: 'quote' +- Quote in `"code"` + +``` +"quoted" +``` diff --git a/tests/testsuite/markdown/tables/src/tables.md b/tests/testsuite/markdown/tables/src/tables.md index d3721ef3..106ab31a 100644 --- a/tests/testsuite/markdown/tables/src/tables.md +++ b/tests/testsuite/markdown/tables/src/tables.md @@ -7,3 +7,7 @@ | Double back in code | `\\` | | Pipe in code | `\|` | | Pipe in code2 | `test \| inside` | + +| Neither | Left | Center | Right | +|---------|:-----|:------:|------:| +| one | two | three | four | diff --git a/tests/testsuite/playground/disabled_playground/src/SUMMARY.md b/tests/testsuite/playground/disabled_playground/src/SUMMARY.md index 6f47d01a..608a891e 100644 --- a/tests/testsuite/playground/disabled_playground/src/SUMMARY.md +++ b/tests/testsuite/playground/disabled_playground/src/SUMMARY.md @@ -1,3 +1,3 @@ # Summary -- [Rust Playground](./index.md) +- [Rust Playground](./disabled-rust-playground.md) diff --git a/tests/testsuite/playground/disabled_playground/src/index.md b/tests/testsuite/playground/disabled_playground/src/disabled-rust-playground.md similarity index 100% rename from tests/testsuite/playground/disabled_playground/src/index.md rename to tests/testsuite/playground/disabled_playground/src/disabled-rust-playground.md diff --git a/tests/testsuite/playground/playground_on_rust_code/src/SUMMARY.md b/tests/testsuite/playground/playground_on_rust_code/src/SUMMARY.md index 6f47d01a..7487f646 100644 --- a/tests/testsuite/playground/playground_on_rust_code/src/SUMMARY.md +++ b/tests/testsuite/playground/playground_on_rust_code/src/SUMMARY.md @@ -1,3 +1,3 @@ # Summary -- [Rust Playground](./index.md) +- [Rust Playground](./rust-playground.md) diff --git a/tests/testsuite/playground/playground_on_rust_code/src/index.md b/tests/testsuite/playground/playground_on_rust_code/src/rust-playground.md similarity index 100% rename from tests/testsuite/playground/playground_on_rust_code/src/index.md rename to tests/testsuite/playground/playground_on_rust_code/src/rust-playground.md diff --git a/tests/testsuite/print.rs b/tests/testsuite/print.rs index 0e0cdfe0..2d64f51f 100644 --- a/tests/testsuite/print.rs +++ b/tests/testsuite/print.rs @@ -1,25 +1,33 @@ //! Tests for print page. use crate::prelude::*; +use snapbox::file; // Tests relative links from the print page. #[test] fn relative_links() { - BookTest::from_dir("print/relative_links") - .check_main_file("book/print.html", - str![[r##" -

    First Chapter

    -

    First Nested

    -

    Testing relative links for the print page

    -

    When we link to the first section, it should work on -both the print page and the non-print page.

    -

    A fragment link should work.

    -

    Link outside.

    -

    Some image

    -

    HTML Link

    -raw html -

    Some section

    -"##]]); + BookTest::from_dir("print/relative_links").check_main_file( + "book/print.html", + file!("print/relative_links/expected/print.html"), + ); +} + +// Test for duplicate IDs, and links to those duplicates. +#[test] +fn duplicate_ids() { + BookTest::from_dir("print/duplicate_ids").check_main_file( + "book/print.html", + file!("print/duplicate_ids/expected/print.html"), + ); +} + +// Test for synthesized link to a chapter that does not have an h1. +#[test] +fn chapter_no_h1() { + BookTest::from_dir("print/chapter_no_h1").check_main_file( + "book/print.html", + file!("print/chapter_no_h1/expected/print.html"), + ); } // Checks that print.html is noindex. diff --git a/tests/testsuite/print/chapter_no_h1/book.toml b/tests/testsuite/print/chapter_no_h1/book.toml new file mode 100644 index 00000000..2bc2b7ab --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/book.toml @@ -0,0 +1,2 @@ +[book] +title = "chapter_no_h1" diff --git a/tests/testsuite/print/chapter_no_h1/expected/print.html b/tests/testsuite/print/chapter_no_h1/expected/print.html new file mode 100644 index 00000000..90b64f0f --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/expected/print.html @@ -0,0 +1,5 @@ +

    Chapter 1

    +

    See chapter 2.

    +

    See this.

    +

    H2 instead

    +

    This has H2 instead of H1.

    \ No newline at end of file diff --git a/tests/testsuite/print/chapter_no_h1/src/SUMMARY.md b/tests/testsuite/print/chapter_no_h1/src/SUMMARY.md new file mode 100644 index 00000000..9ef41515 --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/src/SUMMARY.md @@ -0,0 +1,5 @@ +# Summary + +- [Chapter 1](./chapter_1.md) +- [Chapter 2](./chapter_2.md) +- [H2 instead](./h2-instead.md) diff --git a/tests/testsuite/print/chapter_no_h1/src/chapter_1.md b/tests/testsuite/print/chapter_no_h1/src/chapter_1.md new file mode 100644 index 00000000..f0ea240e --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/src/chapter_1.md @@ -0,0 +1,3 @@ +# Chapter 1 + +See [chapter 2](chapter_2.md). diff --git a/tests/testsuite/print/chapter_no_h1/src/chapter_2.md b/tests/testsuite/print/chapter_no_h1/src/chapter_2.md new file mode 100644 index 00000000..a9a3692a --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/src/chapter_2.md @@ -0,0 +1 @@ +See [this](./chapter_2.md). diff --git a/tests/testsuite/print/chapter_no_h1/src/h2-instead.md b/tests/testsuite/print/chapter_no_h1/src/h2-instead.md new file mode 100644 index 00000000..f742de4d --- /dev/null +++ b/tests/testsuite/print/chapter_no_h1/src/h2-instead.md @@ -0,0 +1,4 @@ +## H2 instead + +This has H2 instead of H1. + diff --git a/tests/testsuite/print/duplicate_ids/book.toml b/tests/testsuite/print/duplicate_ids/book.toml new file mode 100644 index 00000000..afd5a020 --- /dev/null +++ b/tests/testsuite/print/duplicate_ids/book.toml @@ -0,0 +1,2 @@ +[book] +title = "duplicate_ids" diff --git a/tests/testsuite/print/duplicate_ids/expected/print.html b/tests/testsuite/print/duplicate_ids/expected/print.html new file mode 100644 index 00000000..b184261f --- /dev/null +++ b/tests/testsuite/print/duplicate_ids/expected/print.html @@ -0,0 +1,11 @@ +

    Chapter 1

    +

    Some title

    +

    See other

    +

    See this

    +

    See this anchor only

    +

    Chapter 2

    +

    Some title

    +

    See other

    +

    See this

    +

    See this anchor only

    +

    Works with HTML extension too

    \ No newline at end of file diff --git a/tests/testsuite/print/duplicate_ids/src/SUMMARY.md b/tests/testsuite/print/duplicate_ids/src/SUMMARY.md new file mode 100644 index 00000000..fa67cf3e --- /dev/null +++ b/tests/testsuite/print/duplicate_ids/src/SUMMARY.md @@ -0,0 +1,4 @@ +# Summary + +- [Chapter 1](./chapter_1.md) +- [Chapter 2](./chapter_2.md) diff --git a/tests/testsuite/print/duplicate_ids/src/chapter_1.md b/tests/testsuite/print/duplicate_ids/src/chapter_1.md new file mode 100644 index 00000000..9d9abd0d --- /dev/null +++ b/tests/testsuite/print/duplicate_ids/src/chapter_1.md @@ -0,0 +1,9 @@ +# Chapter 1 + +## Some title + +See [other](chapter_2.md#some-title) + +See [this](chapter_1.md#some-title) + +See [this anchor only](#some-title) diff --git a/tests/testsuite/print/duplicate_ids/src/chapter_2.md b/tests/testsuite/print/duplicate_ids/src/chapter_2.md new file mode 100644 index 00000000..2ca4d685 --- /dev/null +++ b/tests/testsuite/print/duplicate_ids/src/chapter_2.md @@ -0,0 +1,11 @@ +# Chapter 2 + +## Some title + +See [other](chapter_1.md#some-title) + +See [this](chapter_2.md#some-title) + +See [this anchor only](#some-title) + +[Works with HTML extension too](chapter_1.html#some-title) diff --git a/tests/testsuite/print/noindex/src/index.md b/tests/testsuite/print/noindex/src/index.md new file mode 100644 index 00000000..1e0981f1 --- /dev/null +++ b/tests/testsuite/print/noindex/src/index.md @@ -0,0 +1 @@ +# Intro diff --git a/tests/testsuite/print/relative_links/expected/print.html b/tests/testsuite/print/relative_links/expected/print.html new file mode 100644 index 00000000..68f6d1ed --- /dev/null +++ b/tests/testsuite/print/relative_links/expected/print.html @@ -0,0 +1,15 @@ +

    First Chapter

    +

    First Nested

    +

    Testing relative links for the print page

    +

    When we link to the first section, it should work on +both the print page and the non-print page.

    +

    The same link should work with an html extension.

    +

    A fragment link should work.

    +

    Link outside.

    +

    Link outside with anchor.

    +

    Some image

    +

    HTML Link

    +raw html +

    Some section

    +

    Links with scheme shouldn’t be touched.

    +

    Non-html link

    \ No newline at end of file diff --git a/tests/testsuite/print/relative_links/src/second/nested.md b/tests/testsuite/print/relative_links/src/second/nested.md index faf1187f..d8886203 100644 --- a/tests/testsuite/print/relative_links/src/second/nested.md +++ b/tests/testsuite/print/relative_links/src/second/nested.md @@ -3,14 +3,22 @@ When we link to [the first section](../first/nested.md), it should work on both the print page and the non-print page. +The same link should work [with an html extension](../first/nested.html). + A [fragment link](#some-section) should work. Link [outside](../../std/foo/bar.html). +Link [outside with anchor](../../std/foo/bar.html#panic). + ![Some image](../images/picture.png) -HTML Link +HTML Link raw html ## Some section + +[Links with scheme shouldn't be touched.](https://example.com/foo.html#bar) + +Non-html link diff --git a/tests/testsuite/rendering.rs b/tests/testsuite/rendering.rs index 5c4c68e4..cdbfbeb1 100644 --- a/tests/testsuite/rendering.rs +++ b/tests/testsuite/rendering.rs @@ -1,4 +1,6 @@ //! Tests for HTML rendering. +//! +//! Note that markdown-specific rendering tests are in the `markdown` module. use crate::prelude::*; @@ -41,3 +43,185 @@ fn first_chapter_is_copied_as_index_even_if_not_first_elem() { ]], ); } + +// Fontawesome `` tag support. +#[test] +fn fontawesome() { + BookTest::from_dir("rendering/fontawesome").check_all_main_files(); +} + +// Tests the rendering when setting the default rust edition. +#[test] +fn default_rust_edition() { + BookTest::from_dir("rendering/default_rust_edition").check_all_main_files(); +} + +// Tests the rendering for editable code blocks. +#[test] +fn editable_rust_block() { + BookTest::from_dir("rendering/editable_rust_block").check_all_main_files(); +} + +// Tests for custom hide lines. +#[test] +fn hidelines() { + BookTest::from_dir("rendering/hidelines").check_all_main_files(); +} + +// Tests for code blocks of basic rust code. +#[test] +fn language_rust_playground() { + fn expect(input: &str, info: &str, expected: impl snapbox::IntoData) { + BookTest::init(|_| {}) + .change_file("book.toml", "output.html.playground.editable = true") + .change_file("src/chapter_1.md", &format!("```rust {info}\n{input}\n```")) + .check_main_file("book/chapter_1.html", expected); + } + // No-main should be wrapped in `fn main` boring lines. + expect( + "x()", + "", + str![[r#" +
    #![allow(unused)]
    +fn main() {
    +x()
    +}
    +"#]], + ); + // `fn main` should not be wrapped, not boring. + expect( + "fn main() {}", + "", + str![[ + r#"
    fn main() {}
    "# + ]], + ); + // Lines starting with `#` are boring. + expect( + "let s = \"foo\n # bar\n\";", + "editable", + str![[r#" +
    let s = "foo
    + bar
    +";
    +"#]], + ); + // `##` is not boring and is used as an escape. + expect( + "let s = \"foo\n ## bar\n\";", + "editable", + str![[r#" +
    let s = "foo
    + # bar
    +";
    +"#]], + ); + // `#` on a line by itself is boring. + expect( + "let s = \"foo\n # bar\n#\n\";", + "editable", + str![[r#" +
    let s = "foo
    + bar
    +
    +";
    +"#]], + ); + // `#` must be followed by a space to be boring. + expect( + "#x;", + "", + str![[r#" +
    #![allow(unused)]
    +fn main() {
    +#x;
    +}
    +"#]], + ); + + // Other classes like "ignore" should not change things, and the class is + // included in the code tag. + expect( + "let s = \"foo\n # bar\n\";", + "ignore", + str![[r#" +
    let s = "foo
    + bar
    +";
    +"#]], + ); + // Inner attributes and normal attributes are not boring. + expect( + "#![no_std]\nlet s = \"foo\";\n #[some_attr]", + "editable", + str![[r#" +
    #![no_std]
    +let s = "foo";
    + #[some_attr]
    +"#]], + ); +} + +// Rust code block in a list. +#[test] +fn code_block_in_list() { + BookTest::init(|_| {}) + .change_file( + "src/chapter_1.md", + r#"- inside list + + ```rust + fn foo() { + let x = 1; + } + ``` +"#, + ) + .check_main_file( + "book/chapter_1.html", + str![[r#" +
      +
    • +

      inside list

      +
      #![allow(unused)]
      +fn main() {
      +fn foo() {
      +  let x = 1;
      +}
      +}
      +
    • +
    +"#]], + ); +} + +// Checks the rendering of links added to headers. +#[test] +fn header_links() { + BookTest::from_dir("rendering/header_links").check_all_main_files(); +} + +// A corrupted HTML end tag. +#[test] +fn busted_end_tag() { + BookTest::init(|_| {}) + .change_file("src/chapter_1.md", "
    xfooy
    ") + .run("build", |cmd| { + cmd.expect_stderr(str![[r#" + INFO Book building has started + INFO Running the html backend + INFO HTML book written to `[ROOT]/book` + +"#]]); + }) + .check_main_file( + "book/chapter_1.html", + str!["
    xfooy
    "], + ); +} + +// Various html blocks. +#[test] +fn html_blocks() { + BookTest::from_dir("rendering/html_blocks").check_all_main_files(); +} diff --git a/tests/testsuite/rendering/default_rust_edition/book.toml b/tests/testsuite/rendering/default_rust_edition/book.toml new file mode 100644 index 00000000..f4564b22 --- /dev/null +++ b/tests/testsuite/rendering/default_rust_edition/book.toml @@ -0,0 +1,5 @@ +[book] +title = "default_rust_edition" + +[rust] +edition = "2021" diff --git a/tests/testsuite/rendering/default_rust_edition/expected/default-rust-edition.html b/tests/testsuite/rendering/default_rust_edition/expected/default-rust-edition.html new file mode 100644 index 00000000..a05ee9c1 --- /dev/null +++ b/tests/testsuite/rendering/default_rust_edition/expected/default-rust-edition.html @@ -0,0 +1,13 @@ +

    Chapter 1

    +
    #![allow(unused)]
    +fn main() {
    +let x = 2021;
    +}
    +
    #![allow(unused)]
    +fn main() {
    +let x = 2021;
    +}
    +
    #![allow(unused)]
    +fn main() {
    +let x = 2024;
    +}
    \ No newline at end of file diff --git a/tests/testsuite/rendering/default_rust_edition/src/SUMMARY.md b/tests/testsuite/rendering/default_rust_edition/src/SUMMARY.md new file mode 100644 index 00000000..07b76081 --- /dev/null +++ b/tests/testsuite/rendering/default_rust_edition/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Default rust edition](./default-rust-edition.md) diff --git a/tests/testsuite/rendering/default_rust_edition/src/default-rust-edition.md b/tests/testsuite/rendering/default_rust_edition/src/default-rust-edition.md new file mode 100644 index 00000000..97661324 --- /dev/null +++ b/tests/testsuite/rendering/default_rust_edition/src/default-rust-edition.md @@ -0,0 +1,13 @@ +# Chapter 1 + +```rust +let x = 2021; +``` + +```rust,edition2021 +let x = 2021; +``` + +```rust,edition2024 +let x = 2024; +``` diff --git a/tests/testsuite/rendering/editable_rust_block/book.toml b/tests/testsuite/rendering/editable_rust_block/book.toml new file mode 100644 index 00000000..5c90f1b5 --- /dev/null +++ b/tests/testsuite/rendering/editable_rust_block/book.toml @@ -0,0 +1,5 @@ +[book] +title = "editable_rust_block" + +[output.html.playground] +editable = true diff --git a/tests/testsuite/rendering/editable_rust_block/expected/editable-rust.html b/tests/testsuite/rendering/editable_rust_block/expected/editable-rust.html new file mode 100644 index 00000000..217477ad --- /dev/null +++ b/tests/testsuite/rendering/editable_rust_block/expected/editable-rust.html @@ -0,0 +1,8 @@ +

    Chapter 1

    +
    fn f() {
    +    println!("hello");
    +}
    +
    #![allow(unused)]
    +fn main() {
    +// Not editable.
    +}
    \ No newline at end of file diff --git a/tests/testsuite/rendering/editable_rust_block/src/SUMMARY.md b/tests/testsuite/rendering/editable_rust_block/src/SUMMARY.md new file mode 100644 index 00000000..139e024a --- /dev/null +++ b/tests/testsuite/rendering/editable_rust_block/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Editable rust blocks](./editable-rust.md) diff --git a/tests/testsuite/rendering/editable_rust_block/src/editable-rust.md b/tests/testsuite/rendering/editable_rust_block/src/editable-rust.md new file mode 100644 index 00000000..2ca724f5 --- /dev/null +++ b/tests/testsuite/rendering/editable_rust_block/src/editable-rust.md @@ -0,0 +1,11 @@ +# Chapter 1 + +```rust,editable +fn f() { + println!("hello"); +} +``` + +```rust +// Not editable. +``` diff --git a/tests/testsuite/rendering/fontawesome/book.toml b/tests/testsuite/rendering/fontawesome/book.toml new file mode 100644 index 00000000..b26c31c0 --- /dev/null +++ b/tests/testsuite/rendering/fontawesome/book.toml @@ -0,0 +1,2 @@ +[book] +title = "fontawesome" diff --git a/tests/testsuite/rendering/fontawesome/expected/fa.html b/tests/testsuite/rendering/fontawesome/expected/fa.html new file mode 100644 index 00000000..61b7db73 --- /dev/null +++ b/tests/testsuite/rendering/fontawesome/expected/fa.html @@ -0,0 +1,5 @@ +

    Chapter 1

    +

    +

    +

    +

    Some text here.

    \ No newline at end of file diff --git a/tests/testsuite/rendering/fontawesome/src/SUMMARY.md b/tests/testsuite/rendering/fontawesome/src/SUMMARY.md new file mode 100644 index 00000000..9624b02d --- /dev/null +++ b/tests/testsuite/rendering/fontawesome/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Font Awesome](./fa.md) diff --git a/tests/testsuite/rendering/fontawesome/src/fa.md b/tests/testsuite/rendering/fontawesome/src/fa.md new file mode 100644 index 00000000..7605f946 --- /dev/null +++ b/tests/testsuite/rendering/fontawesome/src/fa.md @@ -0,0 +1,9 @@ +# Chapter 1 + + + + + + + +Some text here. diff --git a/tests/testsuite/rendering/header_links/book.toml b/tests/testsuite/rendering/header_links/book.toml new file mode 100644 index 00000000..57b20148 --- /dev/null +++ b/tests/testsuite/rendering/header_links/book.toml @@ -0,0 +1,2 @@ +[book] +title = "header_links" diff --git a/tests/testsuite/rendering/header_links/expected/header_links.html b/tests/testsuite/rendering/header_links/expected/header_links.html new file mode 100644 index 00000000..ae823201 --- /dev/null +++ b/tests/testsuite/rendering/header_links/expected/header_links.html @@ -0,0 +1,10 @@ +

    Header Links

    +

    Foo^bar

    +

    +

    +

    +

    Repeat

    +

    Repeat

    +

    Repeat

    +

    Repeat 1

    + \ No newline at end of file diff --git a/tests/testsuite/rendering/header_links/src/SUMMARY.md b/tests/testsuite/rendering/header_links/src/SUMMARY.md new file mode 100644 index 00000000..103f554b --- /dev/null +++ b/tests/testsuite/rendering/header_links/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Header Links](./header_links.md) diff --git a/tests/testsuite/rendering/header_links/src/header_links.md b/tests/testsuite/rendering/header_links/src/header_links.md new file mode 100644 index 00000000..8ad556f7 --- /dev/null +++ b/tests/testsuite/rendering/header_links/src/header_links.md @@ -0,0 +1,19 @@ +# Header Links + +## Foo^bar + +### + +#### + +## Hï + +## Repeat +## Repeat +## Repeat + +## Repeat 1 + +## With *emphasis* **bold** **_bold_emphasis_** `code` \ html [link] + +[link]: https://example.com/link diff --git a/tests/testsuite/rendering/hidelines/book.toml b/tests/testsuite/rendering/hidelines/book.toml new file mode 100644 index 00000000..fc980b82 --- /dev/null +++ b/tests/testsuite/rendering/hidelines/book.toml @@ -0,0 +1,5 @@ +[book] +title = "hidelines" + +[output.html.code.hidelines] +python = "~" diff --git a/tests/testsuite/rendering/hidelines/expected/hide-lines.html b/tests/testsuite/rendering/hidelines/expected/hide-lines.html new file mode 100644 index 00000000..4a37bb0f --- /dev/null +++ b/tests/testsuite/rendering/hidelines/expected/hide-lines.html @@ -0,0 +1,23 @@ +

    Hide Lines

    +
    hidden()
    +nothidden():
    +    hidden()
    +    hidden()
    +    nothidden()
    +
    +
    hidden()
    +nothidden():
    +    hidden()
    +    hidden()
    +    nothidden()
    +
    +
    #![allow(unused)]
    +#![allow(something)]
    +fn main() {
    +
    +#hidden();
    +hidden();
    +# not_hidden();
    +#[not_hidden]
    +not_hidden();
    +}
    \ No newline at end of file diff --git a/tests/testsuite/rendering/hidelines/src/SUMMARY.md b/tests/testsuite/rendering/hidelines/src/SUMMARY.md new file mode 100644 index 00000000..bf5fb26a --- /dev/null +++ b/tests/testsuite/rendering/hidelines/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Hide Lines](./hide-lines.md) diff --git a/tests/testsuite/rendering/hidelines/src/hide-lines.md b/tests/testsuite/rendering/hidelines/src/hide-lines.md new file mode 100644 index 00000000..d2a5a6aa --- /dev/null +++ b/tests/testsuite/rendering/hidelines/src/hide-lines.md @@ -0,0 +1,27 @@ +# Hide Lines + +```python +~hidden() +nothidden(): +~ hidden() + ~hidden() + nothidden() +``` + +```python,hidelines=!!! +!!!hidden() +nothidden(): +!!! hidden() + !!!hidden() + nothidden() +``` + +```rust +#![allow(something)] +# +#hidden(); +# hidden(); +## not_hidden(); +#[not_hidden] +not_hidden(); +``` diff --git a/tests/testsuite/rendering/html_blocks/book.toml b/tests/testsuite/rendering/html_blocks/book.toml new file mode 100644 index 00000000..3bcb7e86 --- /dev/null +++ b/tests/testsuite/rendering/html_blocks/book.toml @@ -0,0 +1,2 @@ +[book] +title = "html_blocks" diff --git a/tests/testsuite/rendering/html_blocks/expected/comment-in-list.html b/tests/testsuite/rendering/html_blocks/expected/comment-in-list.html new file mode 100644 index 00000000..cbff27b4 --- /dev/null +++ b/tests/testsuite/rendering/html_blocks/expected/comment-in-list.html @@ -0,0 +1,6 @@ +
      +
    • +

      List

      + +
    • +
    \ No newline at end of file diff --git a/tests/testsuite/rendering/html_blocks/src/SUMMARY.md b/tests/testsuite/rendering/html_blocks/src/SUMMARY.md new file mode 100644 index 00000000..498dedb3 --- /dev/null +++ b/tests/testsuite/rendering/html_blocks/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Comment in list](./comment-in-list.md) diff --git a/tests/testsuite/rendering/html_blocks/src/comment-in-list.md b/tests/testsuite/rendering/html_blocks/src/comment-in-list.md new file mode 100644 index 00000000..f818205e --- /dev/null +++ b/tests/testsuite/rendering/html_blocks/src/comment-in-list.md @@ -0,0 +1,3 @@ +* List + +