Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff_python_formatter: support reformatting Markdown code blocks #9030

Merged
merged 2 commits into from
Dec 7, 2023

Commits on Dec 6, 2023

  1. ruff_python_formatter: fix typo in code

    When I renamed `line` to `trimmed`, I forgot one.
    
    (Previously, I had rebound `line`, and I think that made
    these sorts of bugs impossible.)
    
    This regression is covered by new tests for Markdown supported
    in a subsequent commit.
    BurntSushi committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    13a45b7 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2023

  1. ruff_python_formatter: support reformatting Markdown code blocks

    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
    BurntSushi committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    d838fa1 View commit details
    Browse the repository at this point in the history