Metadata-Version: 2.4
Name: mdimg
Version: 0.1.1
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: Surgical substitution of image syntax in Markdown
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.

The markdown parser is [pulldown-cmark](https://pulldown-cmark.github.io/pulldown-cmark/) and
simply re-exports its functionality and configuration options.

## Example

```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. Configure markdown parsing with the `markdown` argument, e.g. to enable GitHub Flavored Markdown:

```python
from mdimg import MarkdownOptions, map_images

map_images(text, lambda image: f"your mapping logic here", markdown=MarkdownOptions.GFM)
```

