trying to get mermaid diagrams to work

This commit is contained in:
Lars Rossen 2026-05-10 12:18:02 +02:00
parent 0a5d0a4677
commit 2459b4c680
4 changed files with 47 additions and 3 deletions

View file

@ -19,7 +19,11 @@ fi
echo "Found ${#SLIDES[@]} presentation(s):"
printf ' %s\n' "${SLIDES[@]}"
if command -v marp &>/dev/null; then
CONFIG="$REPO_ROOT/marp.config.mjs"
if command -v npx &>/dev/null && [ -f "$CONFIG" ]; then
npx @marp-team/marp-cli --config "$CONFIG" --html --output "$OUTPUT_DIR/" "${SLIDES[@]}"
elif command -v marp &>/dev/null; then
marp --html --output "$OUTPUT_DIR/" "${SLIDES[@]}"
else
echo "marp not found locally — using Docker (marpteam/marp-cli)..."

View file

@ -1,8 +1,15 @@
---
marp: true
pagination: true
theme: gaia
class: invert
paginate: true
---
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true, theme: 'dark' });
</script>
# Introduction
This is assorted notes on what could go into the MakerFLOSS lab
@ -127,7 +134,7 @@ graph TB
Firewall --> BackupSrv
```
ß---
---
## Long term

21
marp.config.mjs Normal file
View file

@ -0,0 +1,21 @@
import { Marp } from '@marp-team/marp-core'
// Custom Marp engine with Mermaid support via HTML injection
export default {
html: true,
engine: (constructorOptions) => {
const marp = new Marp(constructorOptions)
// Transform mermaid code blocks to divs that mermaid.js can render
const { code } = marp.markdown.renderer.rules
marp.markdown.renderer.rules.code = (tokens, idx, options, env, self) => {
const token = tokens[idx]
if (token.info.trim() === 'mermaid') {
return `<div class="mermaid">${token.content}</div>`
}
return code(tokens, idx, options, env, self)
}
return marp
}
}

12
package.json Normal file
View file

@ -0,0 +1,12 @@
{
"name": "makerfloss-slides",
"private": true,
"type": "module",
"scripts": {
"build": "./build-slides.sh"
},
"devDependencies": {
"@marp-team/marp-cli": "^4.1.0",
"@marp-team/marp-core": "^4.1.0"
}
}