Skip to main content

An opinionated markdown formatter

Project description

formdt

CI Coverage Status

Markdown formatter with configurable line length.

Installation

uv add formdt

Usage

CLI

# Print formatted output to stdout
formdt README.md

# Write changes back to file
formdt README.md --write

# Override line length
formdt README.md --line-length 120

Jupyter Notebooks

[!note] You must specify either -m (all markdown cells) or -c (specific cells) when formatting notebooks.

# Format all markdown cells
formdt notebook.ipynb -m -w

# Format specific cells (0-indexed)
formdt notebook.ipynb -c "0,2,5" -w

# Format a range of cells
formdt notebook.ipynb -c "1-3,7" -w

# Preview without writing
formdt notebook.ipynb -m -l 65

Library

from formdt import format_markdown, Config

text = "This is a very long line that needs to be wrapped."
config = Config(line_length=40)

formatted = format_markdown(text, config)

Configuration

Create a .formdt file in your project root:

{
    "line_length": 80
}

Rules

  • Line wrapping: Lines are wrapped at the configured length
  • Single line breaks: Joined within paragraphs
  • Double line breaks: Preserved as paragraph separators
  • Links: [text](url) patterns are kept intact and never broken across lines
    • Previews: Previews are also kept intact and never broken across lines
  • Preserved blocks: Headings, lists, code fences, and math blocks ($$) are not modified

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

Tasks

test

pytest

sync

uv sync --all-extras
uv pip install -e .

cov

uv run coveralls

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

formdt-0.6.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

formdt-0.6.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file formdt-0.6.0.tar.gz.

File metadata

  • Download URL: formdt-0.6.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for formdt-0.6.0.tar.gz
Algorithm Hash digest
SHA256 a8dfb0cca7ba6cfcfa9cbe5ee78e1d3bed332c759d33c6c462f039161526f5c7
MD5 63b78183757e3ecbef10d456c2349ebf
BLAKE2b-256 48c4c3734ef57dda777dc6567daa25eeb494406cd4ac8d02edf84705d67e0a3b

See more details on using hashes here.

File details

Details for the file formdt-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: formdt-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for formdt-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3725bc8f114d7a3cf26aa58252849c80c596c4bb03d6e033f698c8601e6d607b
MD5 898a32fac6d8ecbea429b24be030c5b8
BLAKE2b-256 46cf841d19e1491383f110b26e29734f12aa910b44e6c3ff1bd4561689015972

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