diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 7a726f87..5da167c0 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -374,70 +374,6 @@ fn no_index_for_print_html() { assert_doesnt_contain_strings(index_html, &[r##"noindex"##]); } -#[test] -fn markdown_options() { - let temp = DummyBook::new().build().unwrap(); - let md = MDBook::load(temp.path()).unwrap(); - md.build().unwrap(); - - let path = temp.path().join("book/first/markdown.html"); - assert_contains_strings( - &path, - &[ - "foo", - "bar", - "baz", - "bim", - ], - ); - assert_contains_strings( - &path, - &[ - r##"1"##, - r##"2"##, - r##"2"##, - r##"
-
  1. -

    This is a footnote. ↩2

    -
  2. -
  3. -

    A longer footnote. -With multiple lines. Link to unicode. -With a reference inside.1 ↩2

    -
  4. -
  5. -
      -
    1. Item one -
        -
      1. Sub-item
      2. -
      -
    2. -
    3. Item two
    4. -
    -
  6. -
  7. One

    Two

    Three

    -
  8. -
  9. -

    Testing footnote id with special characters.

    -
  10. -
  11. -

    This is defined before it is referred to.

    -
  12. -
-"##, - ], - ); - assert_contains_strings(&path, &["strikethrough example"]); - assert_contains_strings( - &path, - &[ - "
  • \nApples", - "
  • \nBroccoli", - "
  • \nCarrots", - ], - ); -} - #[test] fn redirects_are_emitted_correctly() { let temp = DummyBook::new().build().unwrap(); diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 59d9e28a..e2a3ebd9 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -8,6 +8,7 @@ mod cli; mod includes; mod index; mod init; +mod markdown; mod prelude { pub use crate::book_test::BookTest; diff --git a/tests/testsuite/markdown.rs b/tests/testsuite/markdown.rs new file mode 100644 index 00000000..18c9daf7 --- /dev/null +++ b/tests/testsuite/markdown.rs @@ -0,0 +1,99 @@ +//! Tests for special markdown rendering. + +use crate::prelude::*; + +// Test for a variety of footnote renderings. +#[test] +fn footnotes() { + BookTest::from_dir("markdown/footnotes") + .check_main_file("book/footnotes.html", str![[r##" +

    Footnote tests

    +

    Footnote example1, or with a word2.

    +

    There are multiple references to word2.

    +

    Footnote without a paragraph3

    +

    Footnote with multiple paragraphs4

    +

    Footnote name with wacky characters5

    +

    Testing when referring to something earlier.6

    +
    +
    1. +

      This is a footnote. ↩2

      +
    2. +
    3. +

      A longer footnote. +With multiple lines. Link to other. +With a reference inside.1 ↩2

      +
    4. +
    5. +
        +
      1. Item one +
          +
        1. Sub-item
        2. +
        +
      2. +
      3. Item two
      4. +
      +
    6. +
    7. +

      One

      +

      Two

      +

      Three

      +
    8. +
    9. +

      Testing footnote id with special characters.

      +
    10. +
    11. +

      This is defined before it is referred to.

      +
    12. +
    +"##]]); +} + +// Basic table test. +#[test] +fn tables() { + BookTest::from_dir("markdown/tables").check_main_file( + "book/tables.html", + str![[r##" +

    Tables

    +
    + + + + + +
    foobar
    bazbim
    Backslash in code/
    Double back in code//
    Pipe in code|
    Pipe in code2test | inside
    +
    +"##]], + ); +} + +// Strikethrough test. +#[test] +fn strikethrough() { + BookTest::from_dir("markdown/strikethrough").check_main_file( + "book/strikethrough.html", + str![[r##" +

    Strikethrough

    +

    strikethrough example

    +"##]], + ); +} + +// Tasklist test. +#[test] +fn tasklists() { + BookTest::from_dir("markdown/tasklists").check_main_file( + "book/tasklists.html", + str![[r##" +

    Tasklisks

    + +"##]], + ); +} diff --git a/tests/testsuite/markdown/footnotes/src/SUMMARY.md b/tests/testsuite/markdown/footnotes/src/SUMMARY.md new file mode 100644 index 00000000..a36ad791 --- /dev/null +++ b/tests/testsuite/markdown/footnotes/src/SUMMARY.md @@ -0,0 +1 @@ +- [Footnotes](footnotes.md) diff --git a/tests/testsuite/markdown/footnotes/src/footnotes.md b/tests/testsuite/markdown/footnotes/src/footnotes.md new file mode 100644 index 00000000..f1fbacca --- /dev/null +++ b/tests/testsuite/markdown/footnotes/src/footnotes.md @@ -0,0 +1,37 @@ +# Footnote tests + +Footnote example[^1], or with a word[^word]. + +[^1]: This is a footnote. + +[^word]: A longer footnote. + With multiple lines. [Link to other](other.md). + With a reference inside.[^1] + +There are multiple references to word[^word]. + +Footnote without a paragraph[^para] + +[^para]: + 1. Item one + 1. Sub-item + 2. Item two + +Footnote with multiple paragraphs[^multiple] + +[^define-before-use]: This is defined before it is referred to. + +[^multiple]: + One + + Two + + Three + +[^unused]: This footnote is defined by not used. + +Footnote name with wacky characters[^"wacky"] + +[^"wacky"]: Testing footnote id with special characters. + +Testing when referring to something earlier.[^define-before-use] diff --git a/tests/testsuite/markdown/strikethrough/src/SUMMARY.md b/tests/testsuite/markdown/strikethrough/src/SUMMARY.md new file mode 100644 index 00000000..c9a3a836 --- /dev/null +++ b/tests/testsuite/markdown/strikethrough/src/SUMMARY.md @@ -0,0 +1 @@ +- [Strikethrough](strikethrough.md) diff --git a/tests/testsuite/markdown/strikethrough/src/strikethrough.md b/tests/testsuite/markdown/strikethrough/src/strikethrough.md new file mode 100644 index 00000000..4cb45fef --- /dev/null +++ b/tests/testsuite/markdown/strikethrough/src/strikethrough.md @@ -0,0 +1,4 @@ +# Strikethrough + +~~strikethrough example~~ + diff --git a/tests/testsuite/markdown/tables/src/SUMMARY.md b/tests/testsuite/markdown/tables/src/SUMMARY.md new file mode 100644 index 00000000..3c2061aa --- /dev/null +++ b/tests/testsuite/markdown/tables/src/SUMMARY.md @@ -0,0 +1 @@ +- [Tables](tables.md) diff --git a/tests/testsuite/markdown/tables/src/tables.md b/tests/testsuite/markdown/tables/src/tables.md new file mode 100644 index 00000000..d3721ef3 --- /dev/null +++ b/tests/testsuite/markdown/tables/src/tables.md @@ -0,0 +1,9 @@ +# Tables + +| foo | bar | +| --- | --- | +| baz | bim | +| Backslash in code | `\` | +| Double back in code | `\\` | +| Pipe in code | `\|` | +| Pipe in code2 | `test \| inside` | diff --git a/tests/testsuite/markdown/tasklists/src/SUMMARY.md b/tests/testsuite/markdown/tasklists/src/SUMMARY.md new file mode 100644 index 00000000..a1fc91c5 --- /dev/null +++ b/tests/testsuite/markdown/tasklists/src/SUMMARY.md @@ -0,0 +1 @@ +- [Tasklists](tasklists.md) diff --git a/tests/testsuite/markdown/tasklists/src/tasklists.md b/tests/testsuite/markdown/tasklists/src/tasklists.md new file mode 100644 index 00000000..2a90ff56 --- /dev/null +++ b/tests/testsuite/markdown/tasklists/src/tasklists.md @@ -0,0 +1,5 @@ +## Tasklisks + +- [X] Apples +- [X] Broccoli +- [ ] Carrots