Skip to main content

Exports mermaid diagrams in Markdown documents as images.

Project description

Pipeline Status Coverage PyPI Project License PyPI Project Version

markdown-mermaid-to-images

A CLI tool for publishing markdown articles to dev.to. The tool will also update articles if they already exist on dev.to. It matches articles based on title in the frontmatter.

Usage

pip install markdown-mermaid-to-images
markdown_mermaid_to_images --help

Usage: markdown_mermaid_to_images [OPTIONS]

Exports mermaid diagrams in Markdown documents as images.

Options:
-m, --file PATH

Path to markdown file, where the mermaid code blocks will be converted to images.

-f, --folder PATH

Path to folder where we will convert all markdown mermaid code blocks to images.

-i, --ignore PATH

Path to folder to ignore, markdown files in this folder will not be converted.

-o, --output PATH

Path to folder where to save the new markdown files. [required]

-l, --log-level

[DEBUG|INFO|ERROR] Path to folder where to save the new markdown files.

--help

Show this message and exit.

$ markdown_mermaid_to_images -f tests/data -o tests/data/output/ -i tests/data/another_folder

Example Markdown File

Where an example markdown file may look something like this. The meramid code blocks must be surrounded by three ` and have the class mermaid.

## Introduction

Example Document

## Heading

```mermaid
graph LR;
  A --> B;
```

> INFO: Info

```mermaid
graph LR;
  A --> B
  B --> C
  subgraph 1;
  subgraph 2;
  C --> D;
  end
  end;
```

This will then get converted into a file that looks like

Introduction
------------

Example Document

Heading
-------

![Image](a18fcc0f6bf14950b5115b22752471cc.png)

> INFO: Info

![Image](7d2490309c1c4bf48069dd7399944ff4.png)

GitLab CI

You can use also use this in your CI/CD with the provided Docker image. Below is an example .gitlab-ci.yml file, you may wish to use or include. The advantage of this is you can publish your aritcles using CI/CD.

stages:
  - pre-publish

convert-mermaid:markdown:
  image: registry.gitlab.com/hmajid2301/markdown-mermaid-to-images
  stage: pre-publish
  script:
    - markdown_mermaid_to_images --folder tests/data --ignore tests/data/another_folder --output tests/data/output

Setup Development Environment

git clone git@gitlab.com:hmajid2301/markdown-mermaid-to-images.git
cd markdown-mermaid-to-images
pip install tox
make install-venv
source .venv/bin/activate
make install-dev

Changelog

You can find the changelog here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown-mermaid-to-images-0.1.0.post1.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file markdown-mermaid-to-images-0.1.0.post1.tar.gz.

File metadata

  • Download URL: markdown-mermaid-to-images-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for markdown-mermaid-to-images-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 f770507656ebc78cbcee29e8e6cae7253c71be980e6abc0a6e20af2cc57b0966
MD5 49c615c5a9d91503d561d47cfdb48356
BLAKE2b-256 5ca9a98ffbfb6baa0da06f94fb97d2ad880d7cdc39cad4ff76a9e3718cd67b5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page