#![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;
}
}