Skip to content

Commit a32eefb

Browse files
committed
Allow mardown files in system tests
This will make it easeir to write tests for markdown codeblock reformatting.
1 parent 33bed1d commit a32eefb

File tree

3 files changed

+127
-1
lines changed

3 files changed

+127
-1
lines changed

β€Žsrc/test/mod.rsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
109109
let path = entry.path();
110110
if path.is_dir() && recursive {
111111
files.append(&mut get_test_files(&path, recursive));
112-
} else if path.extension().map_or(false, |f| f == "rs") && !is_file_skip(&path) {
112+
} else if path.extension().map_or(false, |f| f == "rs" || f == "md")
113+
&& !is_file_skip(&path)
114+
{
113115
files.push(path);
114116
}
115117
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Testing rustfmts support for formatting code blocks in markdown files
2+
3+
The goal here is to format rust code blocks in markdown files.\
4+
Formatting will _mostly_ impact unformatted code blocks, however there will be minor changes to markdown constructs outside of code blocks. For example, aligning GitHub Flavored Markdown (GFM) tables.
5+
6+
7+
```rust
8+
fn main() {
9+
println!( "Hello world!"
10+
)
11+
}
12+
```
13+
14+
Here's an indented code block that won't be formatted
15+
16+
fn main() {
17+
println!( "Hello world!"
18+
)
19+
}
20+
21+
> > Here's a code block in a blockquote
22+
> > ``` rust
23+
> > fn main() {
24+
> > println!( "Hello world!"
25+
> > )
26+
> > }
27+
> > ```
28+
29+
* Here's a code block in a list!
30+
```rust
31+
fn main() {
32+
println!( "Hello world!"
33+
)
34+
}
35+
```
36+
37+
>> * Here's a code block in a deeply nested markdown context
38+
>> * ```rust
39+
>> fn main() {
40+
>> println!( "Hello world!"
41+
>> )
42+
>> }
43+
>> ```
44+
45+
<p>Markdown also support inline HTML</p>
46+
47+
Oh and we've got some cool support for aligning tables:
48+
49+
| column 1 | column 2 | column 3|
50+
| :---: | :--- | ---: |
51+
| values for column 1 | values for column 2 | values for column 3 |
52+
| 😁😁 | πŸŽ‰πŸŽ‰πŸŽ‰ | 😁 :^) :^)|
53+
54+
Check out the [commonmark spec]!
55+
56+
[commonmark spec]: https://spec.commonmark.org/0.30/
57+
58+
Look we can also link to rust traits or types like [`Debug`] and [`Vec`].
59+
Some additional text with [brackets]. what if I manually \[esacpe the bracket\]? looks like they stay escaped!
60+
61+
62+
[a dead link]: https://this/link/isnt/used
63+
64+
[`Debug`]: core::fmt::Debug
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Testing rustfmts support for formatting code blocks in markdown files
2+
3+
The goal here is to format rust code blocks in markdown files.\
4+
Formatting will _mostly_ impact unformatted code blocks, however there will be minor changes to markdown constructs outside of code blocks. For example, aligning GitHub Flavored Markdown (GFM) tables.
5+
6+
7+
```rust
8+
fn main() {
9+
println!("Hello world!")
10+
}
11+
```
12+
13+
Here's an indented code block that won't be formatted
14+
15+
fn main() {
16+
println!( "Hello world!"
17+
)
18+
}
19+
20+
> > Here's a code block in a blockquote
21+
> > ``` rust
22+
> > fn main() {
23+
> > println!("Hello world!")
24+
> > }
25+
> > ```
26+
27+
* Here's a code block in a list!
28+
```rust
29+
fn main() {
30+
println!("Hello world!")
31+
}
32+
```
33+
34+
> > * Here's a code block in a deeply nested markdown context
35+
> > * ```rust
36+
> > fn main() {
37+
> > println!("Hello world!")
38+
> > }
39+
> > ```
40+
41+
<p>Markdown also support inline HTML</p>
42+
43+
Oh and we've got some cool support for aligning tables:
44+
45+
| column 1 | column 2 | column 3 |
46+
| :-----------------: | :------------------ | ------------------: |
47+
| values for column 1 | values for column 2 | values for column 3 |
48+
| 😁😁 | πŸŽ‰πŸŽ‰πŸŽ‰ | 😁 :^) :^) |
49+
50+
Check out the [commonmark spec]!
51+
52+
[commonmark spec]: https://spec.commonmark.org/0.30/
53+
54+
Look we can also link to rust traits or types like [`Debug`] and [`Vec`].
55+
Some additional text with [brackets]. what if I manually \[esacpe the bracket\]? looks like they stay escaped!
56+
57+
58+
[a dead link]: https://this/link/isnt/used
59+
60+
[`Debug`]: core::fmt::Debug

0 commit comments

Comments
Β (0)