Skip to main content

Format and lint Python code blocks within markdown files.

Project description

md-snakeoil

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.

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.0.tar.gz (4.4 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.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_snakeoil-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 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.0.tar.gz
Algorithm Hash digest
SHA256 8ca02ea342c76c1358528800b4425a9d06ec29399830aba84342b12d7afe40e5
MD5 50d503967b1b0a3ebf5ae3720eacbae0
BLAKE2b-256 c7285c627dab6a430d53a1c6b977fbe750e6e95197dd4663f19e56260efb192c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md_snakeoil-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c1c1fcff61216b8498902b401d93a44339471a9bd8e8a9d232e4931d8d3056e
MD5 de21ee99b46b069d1fca29129d0c50e4
BLAKE2b-256 40f234e1fd0f18128cd447b94e00fbe8fca833258450c7a296a608f17333298e

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