Skip to content

Commit

Permalink
ruff_python_formatter: support reformatting Markdown code blocks
Browse files Browse the repository at this point in the history
This commit slots in support for formatting Markdown fenced code
blocks[1]. With the refactoring done for reStructuredText previously,
this ended up being pretty easy to add. Markdown code blocks are also
quite a bit easier to parse and recognize correctly.

One point of contention in #8860 is whether to assume that unlabeled
Markdown code fences are Python or not by default. In this PR, we make
such an assumption. This follows what `rustdoc` does. The mitigation
here is that if an unlabeled code block isn't Python, then it probably
won't parse as Python. And we'll end up skipping it. So in the vast
majority of cases, the worst thing that can happen is a little bit of
wasted work.

Closes #8860

[1]: https://spec.commonmark.org/0.30/#fenced-code-blocks
  • Loading branch information
BurntSushi committed Dec 7, 2023
1 parent 13a45b7 commit 02fa505
Show file tree
Hide file tree
Showing 4 changed files with 9,362 additions and 4,073 deletions.
Loading

0 comments on commit 02fa505

Please sign in to comment.