Skip to content

Commit 1e6ea0a

Browse files
committed
Remove support for tilde fenced code blocks
CommonMark allows code fences using the tilde character in addition to the backtick character. Commit 0a10f82 (Implement limited supported for fenced code blocks, 2023-11-02) indicates that this is rarely used in the wild, and in Linux 6.6 and Git 2.42.0 it is used almost exclusively either to emphasize compilation error output or underline headers. The variability in style does not serve commitmsgfmt, nor does the enormous risk of false positives serve users, so remove tilde support entirely. References: https://gitlab.com/mkjeldsen/commitmsgfmt/-/issues/7 References: https://spec.commonmark.org/0.30/#fenced-code-blocks
1 parent 06c3206 commit 1e6ea0a

File tree

2 files changed

+45
-441
lines changed

2 files changed

+45
-441
lines changed

src/commitmsgfmt.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,6 @@ fenced
226226
code
227227
block
228228
```
229-
230-
~~~
231-
tilde
232-
fenced
233-
code
234-
block
235-
~~~
236229
";
237230

238231
let expected = "
@@ -244,13 +237,6 @@ fenced
244237
code
245238
block
246239
```
247-
248-
~~~
249-
tilde
250-
fenced
251-
code
252-
block
253-
~~~
254240
";
255241

256242
assert_eq!(filter(72, &input), expected);
@@ -266,12 +252,6 @@ a
266252
backtick
267253
```
268254
b
269-
270-
c
271-
~~~
272-
tilde
273-
~~~
274-
d
275255
";
276256

277257
let expected = "
@@ -282,12 +262,30 @@ a
282262
backtick
283263
```
284264
b
265+
";
266+
267+
assert_eq!(filter(72, &input), expected);
268+
}
269+
270+
#[test]
271+
fn ignores_fenced_code_block_with_tilde() {
272+
let input = "
273+
foo
285274
286-
c
287275
~~~
288276
tilde
277+
fenced
278+
code
279+
block
280+
not
281+
supported
289282
~~~
290-
d
283+
";
284+
285+
let expected = "
286+
foo
287+
288+
~~~ tilde fenced code block not supported ~~~
291289
";
292290

293291
assert_eq!(filter(72, &input), expected);

0 commit comments

Comments
 (0)