diff --git a/.eleventy.js b/.eleventy.js index 824956d..44c2385 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -4,12 +4,29 @@ import markdownItGithubAlerts from "markdown-it-github-alerts"; export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy("_assets"); + eleventyConfig.addPassthroughCopy({ + "node_modules/mermaid/dist/mermaid.min.js": "_assets/mermaid.min.js", + }); const markdownLibrary = markdownIt({ html: true, typographer: true }) .use(markdownItGithubAlerts) .use(markdownItAnchor, { level: [2, 3, 4] }); eleventyConfig.setLibrary("md", markdownLibrary); + // Mermaid fenced code blocks render as
instead of
+ // highlighted code, which is the markup mermaid.js looks for in the
+ // browser to replace with an inline SVG diagram.
+ const defaultFenceRenderer = markdownLibrary.renderer.rules.fence.bind(
+ markdownLibrary.renderer.rules,
+ );
+ markdownLibrary.renderer.rules.fence = (tokens, idx, options, env, self) => {
+ const token = tokens[idx];
+ if (token.info.trim() === "mermaid") {
+ return `${markdownLibrary.utils.escapeHtml(token.content)}\n`;
+ }
+ return defaultFenceRenderer(tokens, idx, options, env, self);
+ };
+
// Builds a collapsed, non-printing table of contents from the h2-h4
// headings (and their anchor ids, added by markdown-it-anchor above)
// found in a page's rendered content.
diff --git a/_assets/style.css b/_assets/style.css
index d8ccfe9..3bb01ed 100644
--- a/_assets/style.css
+++ b/_assets/style.css
@@ -209,6 +209,12 @@ pre {
margin-bottom: 0;
}
+pre.mermaid[data-processed] {
+ background-color: transparent;
+ padding: 0;
+ text-align: center;
+}
+
@media print {
nav,
.noprint {
diff --git a/_includes/layout.html b/_includes/layout.html
index bd6f19c..0776283 100644
--- a/_includes/layout.html
+++ b/_includes/layout.html
@@ -51,5 +51,9 @@
+
+