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.3.tar.gz (4.9 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.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_snakeoil-0.1.3.tar.gz
  • Upload date:
  • Size: 4.9 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.3.tar.gz
Algorithm Hash digest
SHA256 ae4d34b00535cbae29dbc8f88001141813b36cf08ffcf9ca4b3597b1c0250b2c
MD5 a9cf8b492248acd1083861a443d3e1b6
BLAKE2b-256 34b5ad6d8f0aa37b29d31170b8194f5f9e4020ff940e6ad468acf415bf5d07d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md_snakeoil-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8364240cd588f64c4e9feed4e0f09efc3a5f6319744e9a3c6a3a072d6b6ab618
MD5 bff5fbe44f1f661f0f53264c0bb29cf7
BLAKE2b-256 50941efa9ec6ff9fa402da4a28e8fa01aae887c17eb4929f7a4e19a52dfc3449

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