Skip to content

Commit 4a6e940

Browse files
committed
Support quarto markdown language markers
- Regex to allow curly braces around language name - Test cases
1 parent ce5f7b6 commit 4a6e940

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

  • crates/ruff_markdown/src

crates/ruff_markdown/src/lib.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static MARKDOWN_CODE_FENCE: LazyLock<Regex> = LazyLock::new(|| {
2121
^
2222
(?<indent>\s*)
2323
(?<fence>(?:```+|~~~+))\s*
24-
(?<language>(?:\w+)?)\s*
24+
\{?(?<language>(?:\w+)?)\}?\s*
2525
(?<info>(?:.*))\s*
2626
$
2727
",
@@ -384,4 +384,30 @@ print( 'hello' )
384384
&FormatterSettings::default()
385385
), @"Unchanged");
386386
}
387+
388+
#[test]
389+
fn format_code_blocks_quarto() {
390+
let code = r#"
391+
```{py}
392+
print( 'hello' )
393+
```
394+
395+
~~~{pyi}
396+
def foo(): ...
397+
398+
399+
def bar(): ...
400+
~~~
401+
"#;
402+
assert_snapshot!(format_code_blocks(code, None, &FormatterSettings::default()), @r#"
403+
```{py}
404+
print("hello")
405+
```
406+
407+
~~~{pyi}
408+
def foo(): ...
409+
def bar(): ...
410+
~~~
411+
"#);
412+
}
387413
}

0 commit comments

Comments
 (0)