https://github.com/pythoncharmers/ruff-formatter
A Quarto extension for formatting Python code with Ruff when rendering Quarto documents
https://github.com/pythoncharmers/ruff-formatter
Last synced: 10 months ago
JSON representation
A Quarto extension for formatting Python code with Ruff when rendering Quarto documents
- Host: GitHub
- URL: https://github.com/pythoncharmers/ruff-formatter
- Owner: PythonCharmers
- License: mit
- Created: 2025-08-01T05:03:43.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T05:06:06.000Z (11 months ago)
- Last Synced: 2025-08-01T07:43:02.541Z (11 months ago)
- Language: Lua
- Size: 312 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ruff-formatter Extension For Quarto
A [Quarto](https://quarto.org/) filter to format the Python code using [ruff](https://docs.astral.sh/ruff/formatter/)
## Installing
```bash
quarto add PythonCharmers/ruff-formatter
```
This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.
Make sure `ruff` is installed. See [here](https://docs.astral.sh/ruff/installation/) for installation instructions.
## Using
Add the filter in your Quarto document like this:
```
---
filters:
- ruff-formatter
---
```
It is possible to configure `ruff` via a `pyproject.toml` or `ruff.toml` file: see [here](https://docs.astral.sh/ruff/configuration/).
For example, suppose you want to use 80 characters per line i.e. `--line-length=80`. (Ruff defaults to 88 character per line.) You can specify the following in the `pyproject.toml` file under `[tool.ruff]`,
```
[tool.ruff]
line-length = 80
```
And then place this toml file in the same directory as the qmd file of the Python code chunks you want to format.
## Credits
Thanks to Shafayet Shafee for his [Black formatter for Quarto](https://github.com/shafayetShafee/black-formatter) for inspiration!