Skip to content

Commit 3992bc1

Browse files
committed
Add a test for a fenced code block with an indent
1 parent f84b1a1 commit 3992bc1

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

crates/mdbook-html/src/html/hide_lines.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,8 @@ fn it_partitions_rust_source() {
179179
),
180180
("\n#![allow(foo)]\n\n#![allow(bar)]\n\n", "let x = 1;")
181181
);
182+
assert_eq!(
183+
partition_rust_source(" // Example"),
184+
(" ", "// Example")
185+
);
182186
}

tests/testsuite/rendering.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,9 @@ Html text was:
223223
fn html_blocks() {
224224
BookTest::from_dir("rendering/html_blocks").check_all_main_files();
225225
}
226+
227+
// Test for a fenced code block that is also indented.
228+
#[test]
229+
fn code_block_fenced_with_indent() {
230+
BookTest::from_dir("rendering/code_blocks_fenced_with_indent").check_all_main_files();
231+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[book]
2+
title = "code_blocks_fenced_with_indent"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1 id="code-blocks-fenced-with-indent"><a class="header" href="#code-blocks-fenced-with-indent">Code blocks fenced with indent</a></h1>
2+
<pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
3+
</span><span class="boring"> fn main() {
4+
</span>// This has a first line that is indented.
5+
println!("hello");
6+
<span class="boring">}</span></code></pre>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summary
2+
3+
- [Code blocks fenced with indent](./code-blocks-fenced-with-indent.md)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Code blocks fenced with indent
2+
3+
```rust
4+
// This has a first line that is indented.
5+
println!("hello");
6+
```

0 commit comments

Comments
 (0)