Metadata-Version: 2.4
Name: mdimg
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Typing :: Typed
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Summary: Map and rewrite images in Markdown text, including inline HTML img tags
Keywords: markdown,image,html,map,parser
License-Expression: MIT OR Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/niller-g/mdimg

# mdimg

This project provides a simple way of surgically substituting image syntax in Markdown. I.e. map image syntax like (`![alt](url)` and `<img src="url" alt="alt">`) to your own lambda function.

```console
pip install mdimg
```

```python
import mdimg

output = mdimg.map_images(
    "Before ![alt](file.png) after", lambda image: f"[image: alt={image.alt} url={image.url}]"
)
assert output == "Before [image: alt=alt url=file.png] after"
```

Return `image.raw` to leave an image unchanged. Markdown parsing is done by
[pulldown-cmark](https://pulldown-cmark.github.io/pulldown-cmark/); its extensions are available
through the `markdown` keyword argument, and HTML `<img>` handling through `html`.

```python
from mdimg import MarkdownOptions, map_images

map_images(text, rewrite, markdown=MarkdownOptions.GFM | MarkdownOptions.WIKILINKS, html=False)
```

## Development

In `crates/mdimg-python`, create a virtual environment and install dependencies:

```bash
python -m venv .venv
pip install . --group dev
```

