Skip to main content

Markdown formatter with configurable line length

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 (default: 80)
  • Single line breaks: Joined within paragraphs (markdown treats them as spaces)
  • Double line breaks: Preserved as paragraph separators
  • Links: [text](url) patterns are 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

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.5.0.tar.gz (7.2 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.5.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formdt-0.5.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.5.0.tar.gz
Algorithm Hash digest
SHA256 e00c34856b5f1dc746188800bbc430a217f42a894fb152c536f872ddfba8ce67
MD5 e9442b038e1a659fb4686b599cf875c2
BLAKE2b-256 5044f70eb3a876cc486bce569c34153a6ed289c7b119d3dd9d78f328f3f658e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formdt-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16466d0a0471c22ff0f13247781b1a9741f18a6820de37c0c5169a89106057cb
MD5 e64bec448db406886a404d8c702f75f3
BLAKE2b-256 c19b447866f8f42d88a7ce2b0592dae671a60a395650cea04c723748f1b3daa2

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