astral-sh / astral-sh/ruff

☂️ Formatter: Support formatting of embedded code

Open
#8,237 16 comments 47 reactions 0 assignees View on GitHub
formatter wish
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

Support formatting Python code embedded in other languages like:

* Markdown
* reStructuredText
* HTML
* ...

The goal of this issue is not that we implement support for all these languages but to build up the infrastructure to run ruff (at least the formatter) on files that contain embedded python code and format it. Ideally, the infrastructure would, in the future, allow us to support arbitrary nesting:

* Format SQL in Python
* Format Markdown in Python
* ...

Prettier and JetBrains code formatter do an excellent job at this.

Related:
* https://github.com/astral-sh/ruff/issues/7146
* https://github.com/astral-sh/ruff/issues/3792

Contributor guide

Open the contributing guide

Research direction

No source file, test, or entry point is named. Start by reading the formatter architecture and related issues #7146 and #3792, then define the scope for formatting embedded Python in Markdown, reStructuredText, or HTML; done means Ruff's formatter can process embedded Python with infrastructure that can support future nesting.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.