Metadata-Version: 2.4
Name: formdt
Version: 0.6.0
Summary: An opinionated markdown formatter
Project-URL: Repository, https://github.com/sanchitram1/formdt.git
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# formdt

[![CI](https://github.com/sanchitram1/formdt/actions/workflows/ci.yml/badge.svg)
](https://github.com/sanchitram1/formdt/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/sanchitram1/formdt/badge.svg?branch=admin)
](https://coveralls.io/github/sanchitram1/formdt?branch=admin)

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
- **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

```bash
# Install dependencies
uv sync

# Run tests
uv run pytest
```

## Tasks

### test

```bash
pytest
```

### sync

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

### cov

```bash
uv run coveralls
```
