Skip to content
sanchitram1Public

About

sanchit's markdown formatter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

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

About

sanchit's markdown formatter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages