Format and lint Python code blocks within markdown files.
Project description
Format and lint Python code blocks within Markdown files. Usable as CLI,
pre-commit hook or Python package.
md-snakeoil is built on the awesome ruff
formatter and linter and helps you to keep your Markdown files looking
sharp. ๐ค๐ฝ
before vs. after
Quickstart
With uv install
it as a tool:
uv tool install md-snakeoil
Format and lint Markdown files within a directory (recursively):
snakeoil path/to/directory
That's it! ๐
[!NOTE] If, your using
pipx, install it withpipx install md-snakeoil
pre-commit hook
To run md-snakeoil with pre-commit add following to your
.pre-commit-config.yaml:
repos:
- repo: https://github.com/JakobKlotz/md-snakeoil
rev: v0.1.9
hooks:
- id: snakeoil
Command Line Interface
The package provides a command-line interface (CLI) using typer.
Help
snakeoil --help
Usage: snakeoil [OPTIONS] [PATH]
Format & lint Markdown files. Either a single file or all files in a directory,
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ path [PATH] File or directory to process โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --line-length INTEGER Maximum line length for the formatted code [default: 79] โ
โ --rules TEXT Ruff rules to apply (comma-separated) [default: I,W] โ
โ --check --no-check Check if files would be reformatted without writing changes [default: no-check] โ
โ --install-completion Install completion for the current shell. โ
โ --show-completion Show completion for the current shell, to copy it or customize the installation. โ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
By default, the line length is set to 79 characters, and the Ruff rules W and
I are enabled. You can change these defaults using the --line-length and
--rules options.
Single Markdown
snakeoil path/to/file.md
Formatting all files in a directory
snakeoil path/to/directory
This will recursively format and lint the Python code blocks in all Markdown
files within path/to/directory.
For example, format the example files within the tests/ directory
(of this repository):
> snakeoil tests/examples
Formatted: tests\examples\indentation.md
Formatted: tests\examples\info_strings.md
Formatted: tests\examples\test.md
3 formatted, 0 already formatted.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file md_snakeoil-0.1.9.tar.gz.
File metadata
- Download URL: md_snakeoil-0.1.9.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d6a84ae77737ca73498efe7a1e5408175e4d3b201c671f7402a89fe128f62fa
|
|
| MD5 |
d8c6703397ffe9e8edc843030412ad93
|
|
| BLAKE2b-256 |
ed4be3fb4460acd3d68fba8f195d27bd968e719de33c336a0186b39e3e5ce9ce
|
Provenance
The following attestation bundles were made for md_snakeoil-0.1.9.tar.gz:
Publisher:
publish.yml on JakobKlotz/md-snakeoil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
md_snakeoil-0.1.9.tar.gz -
Subject digest:
1d6a84ae77737ca73498efe7a1e5408175e4d3b201c671f7402a89fe128f62fa - Sigstore transparency entry: 1602760654
- Sigstore integration time:
-
Permalink:
JakobKlotz/md-snakeoil@ccc6b3f96eff38c5c5f81098106da6b71a4de9b8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JakobKlotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccc6b3f96eff38c5c5f81098106da6b71a4de9b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file md_snakeoil-0.1.9-py3-none-any.whl.
File metadata
- Download URL: md_snakeoil-0.1.9-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83fe9c9ed9700b63baf82d283562984daf9fd34c6816a3a49f8995f53c9c12ff
|
|
| MD5 |
4be6dc9bdcd67708d7a2592cb18fe72c
|
|
| BLAKE2b-256 |
920a502b65d788bee932113c12f6adb569d3bfbe4c6cbcd6eb78c9206f039ae6
|
Provenance
The following attestation bundles were made for md_snakeoil-0.1.9-py3-none-any.whl:
Publisher:
publish.yml on JakobKlotz/md-snakeoil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
md_snakeoil-0.1.9-py3-none-any.whl -
Subject digest:
83fe9c9ed9700b63baf82d283562984daf9fd34c6816a3a49f8995f53c9c12ff - Sigstore transparency entry: 1602760844
- Sigstore integration time:
-
Permalink:
JakobKlotz/md-snakeoil@ccc6b3f96eff38c5c5f81098106da6b71a4de9b8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JakobKlotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccc6b3f96eff38c5c5f81098106da6b71a4de9b8 -
Trigger Event:
push
-
Statement type: