Metadata-Version: 2.4
Name: formdt
Version: 0.4.0
Summary: Markdown formatter with configurable line length
Requires-Python: >=3.13
Requires-Dist: ruff>=0.14.8
Description-Content-Type: text/markdown

# formdt

Markdown formatter with configurable line length.

## Installation

```bash
uv add formdt
```

## Usage

### CLI

```bash
# 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.

```bash
# 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

```python
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:

```json
{
    "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

```bash
# Install dependencies
uv sync

# Run tests
uv run pytest
```
