
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
puml-for-markdown
Advanced tools
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
Just run puml-for-markdown
in any directory where you have markdown files and it will render links to PlantUML files
in markdown comments. The best part about this is that it requires no build files, you don't even need to store
puml images in your repo. Also the embedded diagrams can link to other diagrams. PlantUML files
allow you to create diagrams that are defined using a simple and intuitive language. By default the entire directory
is recursively searched, automatically ignoring anything in the gitignore file.
The following examples are of a project I worked on, yellow components will link you to another diagram. Obviously the diagram content has been obfuscated.
You can easily add an embedded diagram to your markdown. Simply add a link to the puml file in a markdown comment like so:
<!---->
Here's the result. Try clicking on the yellow blocks.
To render a link to a puml diagram, do the same thing but exclude the !
<!--[Click to Open Interactive Diagram](./puml/level_1_system_view.puml)-->
which renders into
Click to Open Interactive Diagram
The goal is to make PlantUML diagrams easily accessible from markdown, specifically GitHub flavored.
!include
PlantUML allows you to create diagrams that are defined using a simple and intuitive language. PlantUML diagrams are great for designing new projects but they don't work very well in Github markdown preview. There are some workarounds, but I found these to be unstable and they have a lot of caveats.
Update: Github released support for embeddable Mermaid diagrams, but PlantUML is still unsupported, see here for more info.
Whenever you run the CLI it will add a tinyurl link to the rendered SVG next to the markdown comments referencing a puml diagram. E.g.
<!--[Example With Only Link](./puml/level_1_system_view.puml)-->
will be replaced with
[Example With Only Link](https://tinyurl.com/yfpclfpp)<!--[Example With Only Link](./puml/level_1_system_view.puml)-->
When !
is included in front of the markdown link, it will render the diagram image in the markdown. If the image is
clicked it will open up the diagram. E.g.
<!---->
will be replaced with
[](https://tinyurl.com/yfpclfpp)<!---->
If you want to update the link text or switch it between image and link, just update the comment and rerun the CLI. You don't need to delete the rendered image or link.
npm i -g puml-for-markdown
Here are some other features supported
--output-images
and --image-formats
.
For an example of outputted images, checkout dist_puml/puml. These images were created by the
pre-commit hook.--puml-server-url
Usage: puml-for-markdown [options]
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
Options:
-s, --puml-server-url <url> This is the base URL used to render diagrams. Defaults to the public plantuml server. (default: "https://www.plantuml.com/plantuml")
-x, --root-directory <path> The path to your project (default: CWD)
-r, --hot-reload Rerun markdown generator every `interval` seconds, determined by interval option
-v, --interval-seconds <number> If --hot-reload is set, how often should it reload (default: 2)
-p, --puml-directory <path> Path to directory containing puml files which are referenced in markdown files (default: rootDirectory)
-m, --markdown-directory <path> Path to directory containing markdown files referencing puml files (default: rootDirectory)
-g, --ignore-gitignore Don't use .gitignore to skip PUML and MD
-i, --gitignore-path <path> Use this as path to .gitignore file. (default: rootDirectory/.gitignore)
-d, --output-images If set, will output images of diagrams to the dist directory
-b, --dist-directory <path> If --output-images is set, path to output diagram images (default: rootDirectory/dist_puml)
-f, --image-formats <format> If --output-images is set, sets the output image format (choices: "png", "svg", "both", default: "png")
-t, --turn-off-link-shortening Use the full puml server link instead of the tiny url, if your diagrams are too big this won't work
-h, --help display help for command
inline code
or code blocks
will be excluded from renderingYou can use PlantUML using the online web service to generate images on-the-fly. A online demonstration is available at http://www.plantuml.com/plantuml. You can pass the encoded text of your diagrams to the web service in the url path and it will generate an SVG or PNG for you. Here's a simple HelloWorld example http://www.plantuml.com/plantuml/uml/Aov9B2hXil98pSd9LoZFByf9iUOgBial0000. Large diagrams will have very long encoding strings, they can exceed maximum url length. They also don't look very good in markdown files. By default the CLI will use the tinyurl.com service to shorten the link to the diagram.
The CLI will use the plantuml-encoder
package to encode puml files. To support hyperlinking diagrams we need to parse
all hyperlinks in the puml files. A dependency graph is created for the files and a DFS is performed where we create
links for the leaf nodes first, then replace the links in the parent nodes with the links to the leaf nodes. The puml
files are not actually modified, only the puml files content in memory is modified. By default the tinyurl free service
is used to shorten the links.
In order to support !include
we parse puml files and replace any !include
with the contents of the file referenced.
The markdown files are then parsed for markdown comments. If the comments reference a PlantUML file, a link to the web service url will be added next to the comment. Because these links contain the full PlantUML diagram encoding in it, there are no issues using them in private repositories.
Currently there is no TDD, for now I've just been using the example diagrams to test. The examples are pretty extensive though.
FAQs
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
The npm package puml-for-markdown receives a total of 360 weekly downloads. As such, puml-for-markdown popularity was classified as not popular.
We found that puml-for-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.