Skip to main content

Markdown formatter with configurable line length

Project description

formdt

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

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.4.0.tar.gz (11.6 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.4.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formdt-0.4.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.4.0.tar.gz
Algorithm Hash digest
SHA256 cbd571ce95d318559b750a1801428986086491d21fb2ec16578342e249987206
MD5 3f896149e2cda0529b06e8f697a42fdc
BLAKE2b-256 9c060f1e549372144d7d45fde4b3de62a3dd7963eeb0d0fc5981af45f2b5c55b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formdt-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3232cf38c90b98968ffde2f7312c3888363d3a9c37e02428795d6eec57189008
MD5 b598224361b0b7c989ea89a83a903a22
BLAKE2b-256 9c5096d5a251b050a444cde20aa3b744878dda4df72bcac692f31b2baec72576

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