Metadata-Version: 2.4
Name: md2pydantic
Version: 0.1.0
Summary: Extract structured data from messy Markdown strings into Pydantic v2 models
Project-URL: Homepage, https://github.com/felipemorandini/md2pydantic
Project-URL: Repository, https://github.com/felipemorandini/md2pydantic
Project-URL: Issues, https://github.com/felipemorandini/md2pydantic/issues
Author: Felipe Pires Morandini
License: MIT License
        
        Copyright (c) 2026 Felipe Pires Morandini
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: extraction,llm,markdown,parsing,pydantic
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: markdown
Requires-Dist: marko>=2.0.0; extra == 'markdown'
Provides-Extra: pandas
Requires-Dist: pandas>=2.0.0; extra == 'pandas'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# md2pydantic

Extract structured data from messy Markdown strings into [Pydantic v2](https://docs.pydantic.dev/) models.

Built for resilience against common LLM output quirks: triple-backtick wrappers, trailing prose, incomplete tables, malformed JSON, and more.

> **Status:** Early development (pre-alpha). Core functionality works. See [Issues](https://github.com/felipemorandini/md2pydantic/issues) for the roadmap.

## Installation

```bash
# With uv
uv add md2pydantic

# With pip
pip install md2pydantic
```

Requires Python 3.10+.

## Usage

### Tables

```python
from pydantic import BaseModel
from md2pydantic import MDConverter

class Product(BaseModel):
    name: str
    price: float
    in_stock: bool

markdown = """
| name       | price | in_stock |
|------------|-------|----------|
| Widget     | 9.99  | Yes      |
| Gadget     | 24.50 | No       |
"""

products = MDConverter(Product).parse_tables(markdown)
# [Product(name='Widget', price=9.99, in_stock=True),
#  Product(name='Gadget', price=24.5, in_stock=False)]
```

### JSON

```python
from pydantic import BaseModel
from md2pydantic import MDConverter

class Config(BaseModel):
    host: str
    port: int
    debug: bool

markdown = '''Here is the config:
```json
{"host": "localhost", "port": 8080, "debug": true}
```
'''

config = MDConverter(Config).parse_json(markdown)
```

### Auto-detect

```python
result = MDConverter(MyModel).parse(markdown)  # tries JSON/YAML, then tables
```

## Development

```bash
# Install with dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Lint & format
uv run ruff check .
uv run ruff format .

# Type check
uv run mypy src/md2pydantic
```

## License

MIT
