//! Tests for special markdown rendering.
use crate::prelude::*;
use snapbox::file;
// Checks custom header id and classes.
#[test]
fn custom_header_attributes() {
BookTest::from_dir("markdown/custom_header_attributes")
.check_main_file("book/custom_header_attributes.html", str![[r##"
"##]]);
}
// Test for a variety of footnote renderings.
#[test]
fn footnotes() {
BookTest::from_dir("markdown/footnotes")
.run("build", |cmd| {
cmd.expect_stderr(str![[r#"
[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Book building has started
[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Running the html backend
[TIMESTAMP] [WARN] (mdbook_markdown): footnote `multiple-definitions` in defined multiple times - not updating to new definition
[TIMESTAMP] [WARN] (mdbook_markdown): footnote `unused` in `` is defined but not referenced
[TIMESTAMP] [WARN] (mdbook_markdown): footnote `multiple-definitions` in footnotes.md defined multiple times - not updating to new definition
[TIMESTAMP] [WARN] (mdbook_markdown): footnote `unused` in `footnotes.md` is defined but not referenced
[TIMESTAMP] [INFO] (mdbook_html::html_handlebars::hbs_renderer): HTML book written to `[ROOT]/book`
"#]]);
})
.check_main_file(
"book/footnotes.html",
file!["markdown/footnotes/expected/footnotes.html"],
);
}
// Basic table test.
#[test]
fn tables() {
BookTest::from_dir("markdown/tables").check_main_file(
"book/tables.html",
str![[r##"
| foo | bar |
| baz | bim |
| Backslash in code | / |
| Double back in code | // |
| Pipe in code | | |
| Pipe in code2 | test | inside |
"##]],
);
}
// Strikethrough test.
#[test]
fn strikethrough() {
BookTest::from_dir("markdown/strikethrough").check_main_file(
"book/strikethrough.html",
str![[r##"
strikethrough example
"##]],
);
}
// Tasklist test.
#[test]
fn tasklists() {
BookTest::from_dir("markdown/tasklists").check_main_file(
"book/tasklists.html",
str![[r##"
"##]],
);
}
// Smart punctuation test.
#[test]
fn smart_punctuation() {
BookTest::from_dir("markdown/smart_punctuation")
// Default is off.
.check_main_file(
"book/smart_punctuation.html",
str![[r##"
- En dash: --
- Em dash: ---
- Ellipsis: ...
- Double quote: "quote"
- Single quote: 'quote'
"##]],
)
.run("build", |cmd| {
cmd.env("MDBOOK_OUTPUT__HTML__SMART_PUNCTUATION", "true");
})
.check_main_file(
"book/smart_punctuation.html",
str![[r##"
- En dash: –
- Em dash: —
- Ellipsis: …
- Double quote: “quote”
- Single quote: ‘quote’
"##]],
);
}