Skip to main content

Format and lint Python code blocks within markdown files.

Project description

Python License: MIT

A Python package/CLI to format and lint Python code blocks within Markdown files. Specifically designed for Markdown files used with mkdocs-material.

md-snakeoil is built on the awesome ruff formatter and linter and helps you to keep your Markdown files looking sharp.


Installation

pip install md-snakeoil

Command Line Interface

The package provides a command-line interface (CLI) using typer. The CLI has two main commands:

  1. file: Formats and lints Python code blocks in a single Markdown file.
  2. directory: Recursively formats and lints Python code blocks in all Markdown files within a directory.

Usage

Help

snakeoil --help
 Usage: snakeoil [OPTIONS] COMMAND [ARGS]...                                                                                                       
                                                                                                                                                   
 Format and lint Python code blocks in Markdown files.

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --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.                                                                                       │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ file        Process a single Markdown.                                                                                                          │
│ directory   Format all Markdown files within a directory (recursively!).                                                                        │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

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.

You can pull up the help page for individual commands:

snakeoil file --help
snakeoil directory --help

Single Markdown

snakeoil file path/to/file.md

Formatting all files in a directory

snakeoil directory path/to/directory

This will recursively format and lint the Python code blocks in all Markdown files within path/to/directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md_snakeoil-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md_snakeoil-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file md_snakeoil-0.1.1.tar.gz.

File metadata

  • Download URL: md_snakeoil-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for md_snakeoil-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d23babd456a2d2cbbda33e5b4772a7e7304614fa1baf01805211c9f703671410
MD5 33624be67e2d6f92be4306a171828f28
BLAKE2b-256 3e33533b19af8819693ca65ef1c436bcabf25318503813bddbb2820e0c6110a1

See more details on using hashes here.

File details

Details for the file md_snakeoil-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: md_snakeoil-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for md_snakeoil-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fce18379702732bce09aaf7db89f194ef46484a6a070eee9d6a38ada9f95a14f
MD5 0cc19ef8de3a34abb17564707b0168f1
BLAKE2b-256 d6a804ae10e7c282e937d0b35bc4152b1935be982ec985d7fb16b6044f74c1e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page