Skip to content

Add support for mermaid diagrams#122

Merged
andysteadbbc merged 3 commits into
bbc:mainfrom
paulbrimicombe:mermaid-support
Jul 17, 2026
Merged

Add support for mermaid diagrams#122
andysteadbbc merged 3 commits into
bbc:mainfrom
paulbrimicombe:mermaid-support

Conversation

@paulbrimicombe

@paulbrimicombe paulbrimicombe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🧐 What?

🛠 How

When a Mermaid code block is found:

  • The code block is given the mermaid class so the Mermaid JS can detect the diagrams to be rendered
  • The Mermaid JS bundle is imported from /morty-docs/mermaid.min.js (see https://github.com/bbc/morty/pull/353 )
  • The Mermaid library is used to trigger an auto-render of the diagrams

CSS rules ensure that:

  • A loading message is displayed on initial page load
  • The diagram source code is hidden during render
  • visibility: hidden is used to reserve some space (but not the right amount of space) while the diagram renders to avoid at least some of the layout shift when the diagrams render

👀 See

Here's an example showing the loading state and the rendered diagrams from https://github.com/bbc/iplayer-catalogue/blob/main/programme/docs/long-form-video/episode-ingest-scenarios.md (existing Morty page: https://broxy.tools.bbc.co.uk/morty-docs/iplayer-catalogue/programme/docs/long-form-video/episode-ingest-scenarios.html )

morty-mermaid

🐞 Related issue

https://github.com/bbc/morty/issues/308

@paulbrimicombe
paulbrimicombe marked this pull request as ready for review July 17, 2026 10:34
@paulbrimicombe
paulbrimicombe requested a review from a team as a code owner July 17, 2026 10:34
@andysteadbbc
andysteadbbc merged commit 6c6c580 into bbc:main Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants