Skip to content

PythonCharmers/ruff-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruff-formatter Extension For Quarto

A Quarto filter to format the Python code using ruff

Installing

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 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.

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 for inspiration!

About

A Quarto extension for formatting Python code with Ruff when rendering Quarto documents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published