add DOCX support to Mermaid diagram rendering

- Transform.hs: DOCX case returns blocks unchanged (no unicode substitution needed)
- Mermaid.hs: DOCX uses PNG images at normal scale (like HTML, not 3x like PDF)
This commit is contained in:
Willem van den Ende 2026-04-30 18:25:09 +01:00
parent f4dab3e354
commit f016950ac7
3 changed files with 6 additions and 1 deletions

1
.gitignore vendored
View File

@ -18,4 +18,5 @@ stack-setup-2.yaml
analytics-charts.md analytics-charts.md
architecture-deep-dive.md architecture-deep-dive.md
devcontainer.org devcontainer.org
.devcontainer/
root.json root.json

View File

@ -79,6 +79,8 @@ generateDiagramPaths (DiagramConfig _ (OutputDir outDir) format) (DiagramId diag
in (svgFile, T.pack $ takeFileName svgFile) in (svgFile, T.pack $ takeFileName svgFile)
PDF -> let pngFile = outDir </> diagIdStr <> ".png" PDF -> let pngFile = outDir </> diagIdStr <> ".png"
in (pngFile, T.pack pngFile) in (pngFile, T.pack pngFile)
DOCX -> let pngFile = outDir </> diagIdStr <> ".png"
in (pngFile, T.pack pngFile)
-- | Puppeteer configuration content for disabling sandbox -- | Puppeteer configuration content for disabling sandbox
puppeteerConfigContent :: Text puppeteerConfigContent :: Text
@ -90,6 +92,7 @@ callMermaidProcess format mmdFile outputFile = do
let baseArgs = case format of let baseArgs = case format of
HTML -> ["-i", mmdFile, "-o", outputFile] HTML -> ["-i", mmdFile, "-o", outputFile]
PDF -> ["-i", mmdFile, "-o", outputFile, "--scale", "3"] PDF -> ["-i", mmdFile, "-o", outputFile, "--scale", "3"]
DOCX -> ["-i", mmdFile, "-o", outputFile]
-- Create temporary puppeteer config file -- Create temporary puppeteer config file
result <- bracket result <- bracket

View File

@ -36,8 +36,9 @@ transformDocument config docName (Pandoc meta blocks) = do
Left err -> return $ Left err Left err -> return $ Left err
Right (newBlocks, _finalState) -> Right (newBlocks, _finalState) ->
case dcOutputFormat config of case dcOutputFormat config of
PDF -> return $ Right $ substituteUnicodeSymbols (Pandoc meta newBlocks) PDF -> return $ Right $ substituteUnicodeSymbols (Pandoc meta newBlocks)
HTML -> return $ Right $ Pandoc meta newBlocks HTML -> return $ Right $ Pandoc meta newBlocks
DOCX -> return $ Right $ Pandoc meta newBlocks
-- | Process a single block with heading tracking state -- | Process a single block with heading tracking state
processBlockStateful :: DiagramConfig -> Block -> TransformM Block processBlockStateful :: DiagramConfig -> Block -> TransformM Block