From 06fba2464554434a3aed730672b1fef8ef912e78 Mon Sep 17 00:00:00 2001 From: Twest2 Date: Sat, 13 Jun 2026 23:11:02 -0500 Subject: [PATCH] Use GitHub-Flavored Markdown alert syntax for Note/Tip/Warning/Important blocks Markdown export now emits > [!NOTE]/[!TIP]/[!WARNING]/[!IMPORTANT] for text-block callouts, giving them the same colored/icon-labeled treatment as the PDF/HTML/DOCX exports on renderers that support GFM alerts (GitHub, Azure DevOps wikis, etc.), while degrading gracefully to a plain blockquote elsewhere. --- exporters/markdown.js | 6 +++++- tests/unit/exporters-text.test.js | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/exporters/markdown.js b/exporters/markdown.js index 3100f97..5f46027 100644 --- a/exporters/markdown.js +++ b/exporters/markdown.js @@ -84,7 +84,11 @@ function exportMarkdown(ast, outDir, template = {}) { function emitBlocks(lines, step, position) { for (const tb of stepBlocks(step).filter((b) => b.kind === 'text' && b.position === position)) { const label = LEVEL_LABEL[tb.level] || 'Note'; - lines.push(`> **${label}${tb.title ? `: ${tb.title}` : ''}**`); + // GitHub-Flavored Markdown alert syntax — renders with a colored, + // icon-labeled box on GitHub/Azure DevOps wikis and several other + // viewers; degrades to a plain blockquote elsewhere. + lines.push(`> [!${label.toUpperCase()}]`); + if (tb.title) lines.push(`> **${tb.title}**`); const body = htmlToMarkdown(tb.descriptionHtml); if (body) lines.push(`> ${body.replace(/\n/g, '\n> ')}`); lines.push(''); diff --git a/tests/unit/exporters-text.test.js b/tests/unit/exporters-text.test.js index 45c2dc4..119749a 100644 --- a/tests/unit/exporters-text.test.js +++ b/tests/unit/exporters-text.test.js @@ -109,10 +109,11 @@ test('Markdown export: TOC anchors resolve, images exist, blocks rendered', (t) assert.equal(lines[fenceStart + 1], '0 2 * * * /usr/local/bin/acmesync --backup'); assert.equal(lines[fenceStart + 2], '```'); assert.ok(lines.some((l) => /^\| Day \| Window \|$/.test(l)), 'table header row'); - // Warning text block became a blockquote with its content. - const warnIdx = lines.findIndex((l) => l.startsWith('> **Warning: Access**')); + // Warning text block became a GFM alert blockquote with its content. + const warnIdx = lines.findIndex((l) => l.startsWith('> [!WARNING]')); assert.ok(warnIdx > 0); - assert.equal(lines[warnIdx + 1], '> Admins only.'); + assert.equal(lines[warnIdx + 1], '> **Access**'); + assert.equal(lines[warnIdx + 2], '> Admins only.'); }); test('Confluence export writes storage-format XML and image attachments', (t) => {