Skip to content

[WIP] Migrate from @sntke/antora-mermaid-extension to Beautiful Mermaid#10066

Draft
rosieyohannan wants to merge 2 commits intomainfrom
DOC-119-beautiful-mermaid
Draft

[WIP] Migrate from @sntke/antora-mermaid-extension to Beautiful Mermaid#10066
rosieyohannan wants to merge 2 commits intomainfrom
DOC-119-beautiful-mermaid

Conversation

@rosieyohannan
Copy link
Contributor

Replace client-side Mermaid rendering with build-time rendering using Beautiful Mermaid. This provides faster page loads and instant theme switching between light and dark modes.

Changes:

  • Install beautiful-mermaid package (replaces @sntke/antora-mermaid-extension)
  • Create beautiful-mermaid-extension.js: Custom Asciidoctor extension that renders diagrams at build time with dual SVG variants
  • Create mermaid-renderer.mjs: ES module helper for Beautiful Mermaid
  • Update antora-playbook.yml: Register extension in asciidoc.extensions
  • Update ui/src/css/doc.css: Add theme-aware CSS for instant diagram switching with !important rules for proper specificity
  • Update markdown-export-extension.js: Handle new diagram container structure when exporting to markdown
  • Update using-images.adoc: Document Beautiful Mermaid approach
  • Update workflows.adoc: Use composite states for better ELK layout

Theme configuration:

  • Light theme: CircleCI green (document rerun failed tests with knapsack pro #8542) with light backgrounds
  • Dark theme: Lighter green (#94E5AB) with dark backgrounds
  • Configurable: Can switch between 15 built-in themes or custom colors by editing extensions/beautiful-mermaid-extension.js lines 67-94

Technical details:

  • Uses ELK (Eclipse Layout Kernel) for diagram layout
  • Renders two SVG variants per diagram (light + dark) at build time
  • CSS controls visibility based on html[data-theme] attribute
  • Full backward compatibility with existing [mermaid] AsciiDoc blocks

Replace client-side Mermaid rendering with build-time rendering using
Beautiful Mermaid. This provides faster page loads and instant theme
switching between light and dark modes.

Changes:
- Install beautiful-mermaid package (replaces @sntke/antora-mermaid-extension)
- Create beautiful-mermaid-extension.js: Custom Asciidoctor extension
  that renders diagrams at build time with dual SVG variants
- Create mermaid-renderer.mjs: ES module helper for Beautiful Mermaid
- Update antora-playbook.yml: Register extension in asciidoc.extensions
- Update ui/src/css/doc.css: Add theme-aware CSS for instant diagram
  switching with !important rules for proper specificity
- Update markdown-export-extension.js: Handle new diagram container
  structure when exporting to markdown
- Update using-images.adoc: Document Beautiful Mermaid approach
- Update workflows.adoc: Use composite states for better ELK layout

Theme configuration:
- Light theme: CircleCI green (#8542) with light backgrounds
- Dark theme: Lighter green (#94E5AB) with dark backgrounds
- Configurable: Can switch between 15 built-in themes or custom colors
  by editing extensions/beautiful-mermaid-extension.js lines 67-94

Technical details:
- Uses ELK (Eclipse Layout Kernel) for diagram layout
- Renders two SVG variants per diagram (light + dark) at build time
- CSS controls visibility based on html[data-theme] attribute
- Full backward compatibility with existing [mermaid] AsciiDoc blocks

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@linear
Copy link

linear bot commented Mar 12, 2026

Add support for diagram captions that appear below mermaid diagrams,
matching AsciiDoc's standard image caption behavior. Both diagrams and
titles are now centered for better visual presentation.

Changes:
- extensions/beautiful-mermaid-extension.js:
  - Render title div after mermaid-diagram-container
  - Update light theme: white background (#ffffff), added muted and border colors
  - Update dark theme: added muted color (#565f89)
- ui/src/css/doc.css:
  - Add .mermaid-diagram-container + .title to styled title selectors
  - Center diagrams using flexbox (justify-content: center)
  - Center titles with text-align: center
  - Add margin: 0 auto to SVG elements
- docs/contributors/modules/docs-style/pages/using-images.adoc:
  - Fix example sequence diagram syntax (was missing participant names)

Diagram titles now display consistently with image captions, positioned
below the diagram and centered.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

1 participant