Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shafayetShafee/black-formatter
A Quarto filter to format the python code using black code formatter
https://github.com/shafayetShafee/black-formatter
black black-formatter python quarto quarto-extension quarto-filter
Last synced: 2 months ago
JSON representation
A Quarto filter to format the python code using black code formatter
- Host: GitHub
- URL: https://github.com/shafayetShafee/black-formatter
- Owner: shafayetShafee
- License: mit
- Created: 2023-03-16T14:31:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-22T05:14:18.000Z (about 1 year ago)
- Last Synced: 2024-02-04T06:11:08.844Z (5 months ago)
- Topics: black, black-formatter, python, quarto, quarto-extension, quarto-filter
- Language: Lua
- Homepage:
- Size: 645 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-quarto - black-formatter - A Quarto filter to format Python code using [black](https://black.readthedocs.io/en/stable/index.html) formatter. (Extensions)
README
# Black-formatter Extension For Quarto
A [Quarto](https://quarto.org/) filter to format the python code using [black](https://black.readthedocs.io/en/stable/index.html)
## Installing
```bash
quarto add shafayetShafee/black-formatter
```This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.## Using
Before using this filter, make sure black is installed already. See [here](https://github.com/psf/black#installation) for installation command.
Then add the filter in your quarto document
```
---
filters:
- black-formatter
---
```And it is possible to specify the black command line options [via a `pyproject.toml` file](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file).
Suppose you want to use 80 characters per line i.e. `--line-length=80` (Black defaults to 88 character per line), you can specify the follwoing in `pyproject.toml` file under `[tool.black]`,
```
[tool.black]
line-length = 80
```And then place this toml file in the same directory along with the qmd file of which python code-chunks you want to format.
## Example
Here is the source code for a minimal example: [example.qmd](example.qmd) and view the rendered output with black-formatted code [here](https://shafayetshafee.github.io/black-formatter/example.html)