Metadata-Version: 2.4
Name: mermaid-codeblock-generator
Version: 0.1.0
Summary: Tiny dependency-free Mermaid code-block generator
License-Expression: MIT
Keywords: mermaid,markdown,diagram,cli
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Topic :: Documentation
Classifier: Topic :: Multimedia :: Graphics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Mermaid Codeblock Generator

Tiny, dependency-free Python library and CLI that prints fenced Mermaid blocks.
It accepts plain arrow chains, structured JSON, existing Mermaid source, and
image nodes.

## Install

```bash
pip install mermaid-codeblock-generator
```

For local development:

```bash
python -m pip install -e .
```

## CLI

```bash
mermaid-blocks 'Upload -> Process -> Download'
```

Output:

````markdown
```mermaid
flowchart LR
    upload["Upload"]
    process["Process"]
    download["Download"]
    upload --> process
    process --> download
```
````

Input can also come from a file or stdin:

```bash
mermaid-blocks --file steps.txt
printf 'A -> B -> C' | mermaid-blocks
```

Attach image URLs or local files to nodes:

```bash
mermaid-blocks 'Input -> Preview -> Done' --image Preview=./preview.png
```

Local images are embedded as data URLs by default. Use `--no-embed-images` to
leave the path unchanged. Image nodes require Mermaid 11.3 or newer.

```bash
mermaid-blocks 'A -> B' --direction TD --title 'Small flow'
mermaid-blocks $'sequenceDiagram\nAlice->>Bob: Hi' --bare
mermaid-blocks --file diagram.json --json --output diagram.md
```

## JSON format

```json
{
  "type": "flowchart",
  "direction": "LR",
  "title": "Image pipeline",
  "nodes": [
    {"id": "upload", "label": "Upload", "shape": "round"},
    {
      "id": "preview",
      "label": "Preview",
      "image": "https://example.com/preview.png",
      "height": 80
    },
    {"id": "done", "label": "Done", "shape": "stadium"}
  ],
  "edges": [
    {"from": "upload", "to": "preview", "label": "file"},
    {"from": "preview", "to": "done", "style": "==>"}
  ],
  "classDefs": {
    "success": "fill:#d1fae5,stroke:#059669"
  }
}
```

Supported shapes are `rectangle`, `round`, `stadium`, `diamond`, `circle`, and
`database`. Nodes may also contain `class`, `href`, and `tooltip`. Edge styles
are `-->`, `---`, `-.->`, `==>`, and `~~~`.

JSON can directly wrap any Mermaid diagram type:

```json
{"mermaid": "sequenceDiagram\nAlice->>Bob: Hello"}
```

## Python API

```python
from mermaid_blocks import generate

print(generate("Start -> Work -> Finish"))
print(generate({
    "nodes": [
        {"id": "a", "label": "Photo", "image": "photo.png"},
        {"id": "b", "label": "Result"}
    ],
    "edges": [{"from": "a", "to": "b"}]
}))
```

This package generates Mermaid source; it does not render SVG or PNG.

## Test and build

```bash
python -m unittest discover -s tests -v
python -m build
```
