Skip to content

Instantly share code, notes, and snippets.

@rasjonell
Last active February 13, 2023 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasjonell/a8bd377eea90bf27c05481e922a51ad0 to your computer and use it in GitHub Desktop.
Save rasjonell/a8bd377eea90bf27c05481e922a51ad0 to your computer and use it in GitHub Desktop.
Get an embeddable link to PlantUML Diagram Image for MarkDown

PlantUML For Markdown

Installation

  • Download the shell script bellow
  • Make it executable: chmod +x puml-to-md-image.sh

Usage Example

./puml-to-md-image.sh <path-to-puml-file> <path-to-the-project>

The script takes 2 arguments:

  1. Path the the puml file
  2. Path to the project

Example:

$ ./puml-to-md-image.sh ~/Projects/client/application/web/lazy-modules/search/uml/LoadData.puml ~/Projects/client

Getting Diagram link for ~/Projects/client/application/web/lazy-modules/search/uml/LoadData.puml
Copy this line into your PR Description:

[![Diagram Image](https://tinyurl.com/2pte5cgt)](https://tinyurl.com/2pte5cgt)<!--![Diagram Image](/Users/rasjonell/Projects/client/application/web/lazy-modules/search/uml/LoadData.puml)-->

You can then copy the generated line into you PR Description or any Markdown file. It will render an image like bellow:

Diagram Image

#!/bin/bash
function get-puml() {
echo "Getting Diagram link for $1"
mkdir temp
echo "<!--![Diagram Image]($1)-->" > temp/temp.md
puml-for-markdown -p $2 -x temp > /dev/null
echo ""
echo "Copy this line into your PR Description:"
echo ""
cat temp/temp.md
echo ""
rm -rf temp/
}
which puml-for-markdown > /dev/null 2>&1
rc=$?
if [ $rc != 0 ]; then
echo installing puml-for-markdown
npm i -g puml-for-markdown > /dev/null
fi
get-puml $1 $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment