mirror of
https://github.com/rust-lang/mdBook.git
synced 2025-12-27 09:05:40 -05:00
Migrate summary_with_markdown_formatting to BookTest
This commit is contained in:
@@ -106,39 +106,3 @@ fn example_book_can_build() {
|
||||
|
||||
md.build().unwrap();
|
||||
}
|
||||
|
||||
/// Checks formatting of summary names with inline elements.
|
||||
#[test]
|
||||
fn summary_with_markdown_formatting() {
|
||||
let temp = DummyBook::new().build().unwrap();
|
||||
let mut cfg = Config::default();
|
||||
cfg.set("book.src", "summary-formatting").unwrap();
|
||||
let md = MDBook::load_with_config(temp.path(), cfg).unwrap();
|
||||
md.build().unwrap();
|
||||
|
||||
let rendered_path = temp.path().join("book/toc.js");
|
||||
assert_contains_strings(
|
||||
rendered_path,
|
||||
&[
|
||||
r#"<a href="formatted-summary.html"><strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>"#,
|
||||
r#"<a href="soft.html"><strong aria-hidden="true">2.</strong> Soft line break</a>"#,
|
||||
r#"<a href="escaped-tag.html"><strong aria-hidden="true">3.</strong> <escaped tag></a>"#,
|
||||
],
|
||||
);
|
||||
|
||||
let generated_md = temp.path().join("summary-formatting/formatted-summary.md");
|
||||
assert_eq!(
|
||||
fs::read_to_string(generated_md).unwrap(),
|
||||
"# Italic code *escape* `escape2`\n"
|
||||
);
|
||||
let generated_md = temp.path().join("summary-formatting/soft.md");
|
||||
assert_eq!(
|
||||
fs::read_to_string(generated_md).unwrap(),
|
||||
"# Soft line break\n"
|
||||
);
|
||||
let generated_md = temp.path().join("summary-formatting/escaped-tag.md");
|
||||
assert_eq!(
|
||||
fs::read_to_string(generated_md).unwrap(),
|
||||
"# <escaped tag>\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,3 +142,46 @@ fn check_link_target_fallback() {
|
||||
TOC_TOP_LEVEL.len() + TOC_SECOND_LEVEL.len()
|
||||
);
|
||||
}
|
||||
|
||||
// Checks formatting of summary names with inline elements.
|
||||
#[test]
|
||||
fn summary_with_markdown_formatting() {
|
||||
BookTest::from_dir("toc/summary_with_markdown_formatting")
|
||||
.check_toc_js(str![[r#"
|
||||
<ol class="chapter">
|
||||
<li class="chapter-item expanded ">
|
||||
<a href="formatted-summary.html">
|
||||
<strong aria-hidden="true">1.</strong> Italic code *escape* `escape2`</a>
|
||||
</li>
|
||||
<li class="chapter-item expanded ">
|
||||
<a href="soft.html">
|
||||
<strong aria-hidden="true">2.</strong> Soft line break</a>
|
||||
</li>
|
||||
<li class="chapter-item expanded ">
|
||||
<a href="escaped-tag.html">
|
||||
<strong aria-hidden="true">3.</strong> <escaped tag></a>
|
||||
</li>
|
||||
</ol>
|
||||
"#]])
|
||||
.check_file(
|
||||
"src/formatted-summary.md",
|
||||
str![[r#"
|
||||
# Italic code *escape* `escape2`
|
||||
|
||||
"#]],
|
||||
)
|
||||
.check_file(
|
||||
"src/soft.md",
|
||||
str![[r#"
|
||||
# Soft line break
|
||||
|
||||
"#]],
|
||||
)
|
||||
.check_file(
|
||||
"src/escaped-tag.md",
|
||||
str![[r#"
|
||||
# <escaped tag>
|
||||
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Summary formatting tests
|
||||
|
||||
- [*Italic* `code` \*escape\* \`escape2\`](formatted-summary.md)
|
||||
- [Soft
|
||||
line break](soft.md)
|
||||
- [\<escaped tag\>](escaped-tag.md)
|
||||
Reference in New Issue
Block a user