Compare commits
5
Commits
6b49db5801
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54c7502f0f | ||
|
|
eb374d20f5 | ||
|
|
57f4f9f165 | ||
|
|
f016950ac7 | ||
|
|
f4dab3e354 |
@@ -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
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ A self-contained CLI tool that converts Markdown with Mermaid diagrams into PDF
|
|||||||
|
|
||||||
docster -pdf path/to/file.md
|
docster -pdf path/to/file.md
|
||||||
docster -html path/to/file.md
|
docster -html path/to/file.md
|
||||||
|
docster -docx path/to/file.md
|
||||||
|
|
||||||
Mermaid code blocks (```mermaid) will be rendered to SVG and embedded.
|
Mermaid code blocks (```mermaid) will be rendered to SVG (HTML) or PNG (PDF/DOCX) and embedded.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: docster
|
name: docster
|
||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
synopsis: A self-contained CLI tool that converts Markdown with Mermaid diagrams to PDF/HTML
|
synopsis: A self-contained CLI tool that converts Markdown with Mermaid diagrams to PDF, HTML, or DOCX
|
||||||
description: Docster converts Markdown documents containing Mermaid diagrams into PDF or HTML files
|
description: Docster converts Markdown documents containing Mermaid diagrams into PDF, HTML, or DOCX files
|
||||||
using Pandoc and Mermaid CLI. It automatically renders Mermaid code blocks to SVG
|
using Pandoc and Mermaid CLI. It automatically renders Mermaid code blocks to SVG (HTML) or PNG (PDF/DOCX)
|
||||||
and embeds them in the output.
|
and embeds them in the output.
|
||||||
homepage: https://github.com/yourusername/docster
|
homepage: https://github.com/yourusername/docster
|
||||||
license: BSD-3-Clause
|
license: BSD-3-Clause
|
||||||
@@ -41,7 +41,7 @@ library
|
|||||||
process >=1.6 && <1.7,
|
process >=1.6 && <1.7,
|
||||||
hashable >=1.4 && <1.6,
|
hashable >=1.4 && <1.6,
|
||||||
containers >=0.6 && <0.8,
|
containers >=0.6 && <0.8,
|
||||||
pandoc >=3.0 && <3.2,
|
pandoc >=3.0 && <3.8,
|
||||||
pandoc-types >=1.23 && <1.25,
|
pandoc-types >=1.23 && <1.25,
|
||||||
bytestring >=0.11 && <0.13,
|
bytestring >=0.11 && <0.13,
|
||||||
temporary >=1.3 && <1.4,
|
temporary >=1.3 && <1.4,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
-- | Document compilation functionality for PDF and HTML output
|
-- | Document compilation functionality for PDF, HTML, and DOCX output
|
||||||
module Docster.Compiler
|
module Docster.Compiler
|
||||||
( -- * Compilation Functions
|
( -- * Compilation Functions
|
||||||
compileToPDF
|
compileToPDF
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ transformDocument config docName (Pandoc meta blocks) = do
|
|||||||
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
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Docster.TransformSpec (spec) where
|
|||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Data.Text (Text)
|
import Data.Text()
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Text.Pandoc.Definition (Inline(..))
|
import Text.Pandoc.Definition (Inline(..))
|
||||||
|
|
||||||
@@ -64,21 +64,21 @@ spec = do
|
|||||||
describe "diagram naming logic" $ do
|
describe "diagram naming logic" $ do
|
||||||
it "first diagram under heading has no suffix" $
|
it "first diagram under heading has no suffix" $
|
||||||
let baseName = "file_flow"
|
let baseName = "file_flow"
|
||||||
counter = Map.findWithDefault 0 baseName Map.empty
|
counter = Map.findWithDefault (0 :: Int) baseName Map.empty
|
||||||
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
||||||
in diagName `shouldBe` "file_flow"
|
in diagName `shouldBe` "file_flow"
|
||||||
|
|
||||||
it "second diagram gets _1 suffix" $
|
it "second diagram gets _1 suffix" $
|
||||||
let baseName = "file_flow"
|
let baseName = "file_flow"
|
||||||
counters = Map.singleton "file_flow" 1
|
counters = Map.singleton "file_flow" (1 :: Int)
|
||||||
counter = Map.findWithDefault 0 baseName counters
|
counter = Map.findWithDefault (0 :: Int) baseName counters
|
||||||
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
||||||
in diagName `shouldBe` "file_flow_1"
|
in diagName `shouldBe` "file_flow_1"
|
||||||
|
|
||||||
it "third diagram gets _2 suffix" $
|
it "third diagram gets _2 suffix" $
|
||||||
let baseName = "file_flow"
|
let baseName = "file_flow"
|
||||||
counters = Map.singleton "file_flow" 2
|
counters = Map.singleton "file_flow" (2 :: Int)
|
||||||
counter = Map.findWithDefault 0 baseName counters
|
counter = Map.findWithDefault (0 :: Int) baseName counters
|
||||||
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
diagName = if counter == 0 then baseName else baseName <> "_" <> T.pack (show counter)
|
||||||
in diagName `shouldBe` "file_flow_2"
|
in diagName `shouldBe` "file_flow_2"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user