Switch README and CLAUDE.md from cabal to stack commands, update GHC version references, add pkg-config to install-deps.sh, and add Stack as the recommended build method. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Docster is a Haskell CLI tool that converts Markdown files with embedded Mermaid diagrams into PDF or HTML. It processes Mermaid code blocks by rendering them to SVG images and embedding them in the output.
Development Commands
Build
stack build
Run
# Convert to PDF
stack exec docster -- -pdf path/to/file.md
# Convert to HTML
stack exec docster -- -html path/to/file.md
Test
stack test
Test a single file
stack exec docster -- -pdf mermaid-to-svg/sample.md
Clean build artifacts
stack clean
Interactive development
stack repl
Architecture
The application consists of:
- Main.hs (app/Main.hs:1-69) - Entry point and core logic
processMermaidBlock(app/Main.hs:54-79) - Transforms Mermaid code blocks into images (SVG for HTML, high-res PNG for PDF)transformDoc(app/Main.hs:36-37) - Walks the Pandoc AST to process all blockscompileToPDF(app/Main.hs:47-58) - Converts Markdown to PDF using LaTeXcompileToHTML(app/Main.hs:60-68) - Converts Markdown to HTML
The tool uses Pandoc's AST transformation capabilities to:
- Parse Markdown input
- Find Mermaid code blocks
- Generate image files using mermaid-cli (mmdc) - SVG for HTML, high-resolution PNG for PDF
- Replace code blocks with image references
- Output final PDF/HTML
Dependencies
External requirements:
- Stack (install via ghcup) — manages GHC 9.10.3 automatically via lts-24.34
- Pandoc library (Haskell dependency, pulled by Stack)
- TeX Live (for PDF generation via XeLaTeX)
- Mermaid CLI (
npm install -g @mermaid-js/mermaid-cli) - pkg-config, libgmp-dev, libffi-dev, zlib1g-dev (see
install-deps.sh)
Common Issues
-
Missing LaTeX packages: PDF generation requires a LaTeX distribution. Install BasicTeX or TinyTeX and use tlmgr to add packages as needed.
-
Mermaid CLI not found: Ensure mmdc is in PATH after installing @mermaid-js/mermaid-cli globally.
-
Type errors with Text vs String: The codebase mixes Data.Text and String. Use T.pack/T.unpack for conversions.