Rendering mermaid code in a Write-Once Publishing Pipeline

In the previous post, Building a Content Publishing Pipeline with Jenkins and WordPress, I introduced a fully automated workflow for publishing Markdown content — including pre-rendered diagrams — directly to WordPress.

This post adds a small but powerful improvement: Mermaid diagrams can now be written inline in Markdown and rendered automatically during the pipeline run.


Why this matters

Keeping diagrams close to the text they describe has several benefits:

  • Better readability while writing
  • Fewer external files to manage
  • Easier reviews and diffs
  • Fully automated rendering — no manual steps
  • Wordpress, unlike other platforms, does not automatically recognize Mermaid code

Authors can now focus on content, while the pipeline handles everything else.


Inline Mermaid example

Here is a Mermaid diagram written directly in Markdown:

{{ diagram: mermaid-ef2c8c198811.png }}

During the Jenkins run, this block is:

  1. Extracted from the Markdown
  2. Rendered into a PNG image
  3. Uploaded to the WordPress media library
  4. Replaced inline with a standard Markdown image reference

The published post contains no Mermaid code at all, only a static image — which means:

  • No JavaScript dependencies
  • Better performance
  • Better SEO
  • No surprises for feed readers or crawlers

How it works (high level)

The workflow is intentionally simple:

  1. Markdown files are scanned for “`mermaid blocks
  2. Each diagram is rendered deterministically based on its content
  3. Images are stored alongside other media assets
  4. The publishing step only deals with already-rendered files

This keeps responsibilities clearly separated:

  • Jenkins renders
  • Publishing uploads
  • WordPress (and later other platforms) displays

What’s next

This marks the v1.1.0 milestone of the publishing pipeline.

Future improvements may include:

  • Diagram captions
  • Reusable diagrams across posts
  • Cross-posting to additional platforms

But for now, inline Mermaid support removes friction where it matters most: writing and being creative.


If you haven’t seen the original pipeline yet, start here: Building a Content Publishing Pipeline with Jenkins and WordPress.

Did you find this post helpful? You can support me.

Author Profile

12ww1160DevOps engineer & architect

Leave a Reply

Your email address will not be published. Required fields are marked *

five × five =