13 Commits

Author SHA1 Message Date
907fcb3884 Refactor compileWithStrategy to use ExceptT for linear error handling
Replace deeply nested Either case expressions with clean ExceptT monad
transformer pipeline. This eliminates manual error propagation and
creates a more readable "straight line" flow while preserving identical
error handling semantics.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 23:31:40 +02:00
bf6f82abe5 Replace makePDF with direct XeLaTeX processing to eliminate API mismatch
- Remove Text.Pandoc.PDF dependency and dummy Pandoc document
- Add direct xelatex invocation with temporary file handling
- Improve error reporting with LaTeX log file parsing
- Add temporary package dependency for proper temp file cleanup
- Maintain same external API while cleaning internal architecture
- Eliminate architectural mismatch between our pipeline and Pandoc's expectations

The previous code used makePDF in a way that fought against its intended usage,
requiring a dummy Pandoc document. Now we directly call xelatex after our
custom LaTeX template processing, creating a cleaner separation of concerns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 23:22:40 +02:00
303f347243 Refactor Compiler.hs with higher-order functions to eliminate duplication
- Extract PDF and HTML compilation differences using strategy pattern
- Implement CompilationStrategy record with format-specific operations
- Create higher-order compileWithStrategy function for common pipeline
- Eliminate ~40 lines of duplicated code between PDF/HTML compilation
- Add LambdaCase extension for cleaner monadic error handling
- Maintain same external API while improving internal architecture
- Enable easy addition of new output formats through new strategies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 23:12:13 +02:00
1c8cfdb075 Split Main.hs into logical modules for better maintainability
- Extract types into Docster.Types module (50 lines)
- Move Mermaid processing to Docster.Mermaid module (93 lines)
- Create Docster.Transform for document walking (21 lines)
- Isolate LaTeX templates in Docster.LaTeX module (65 lines)
- Extract compilation logic to Docster.Compiler module (90 lines)
- Reduce Main.hs to minimal CLI entry point (23 lines from 233)
- Add library stanza to cabal file with proper module organization
- Follow Haskell conventions with Docster.ModuleName hierarchy

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 22:31:55 +02:00
e6048e34d1 Refactor Haskell code with enhanced type safety and error handling
- Add OutputFormat ADT for explicit format handling vs file extension checking
- Replace crash-prone runIOorExplode with proper Either error handling
- Extract processMermaidBlock into focused functions for better maintainability
- Convert String constants to Text for type consistency
- Add DiagramConfig type for better configuration management
- Enhance haskell-refactoring-expert agent to handle module organization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 22:16:34 +02:00
f7a6482447 Fix PDF diagram truncation with LaTeX auto-scaling
Replace manual size constraints with LaTeX's built-in image scaling mechanism.
- Remove artificial width/height constraints that caused diagram truncation
- Add adjustbox package and auto-scaling macros to LaTeX template
- Images now scale intelligently: natural size if they fit, auto-scaled if oversized
- Maintains aspect ratio and prevents page rotation issues

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 20:15:24 +02:00
7f1f1aeeb0 Fix PDF diagram text rendering with format-optimized generation
Problem: SVG diagrams had missing text in PDFs due to Inkscape conversion
issues with foreignObject elements used by Mermaid for HTML text rendering.

Solution: Implement format-specific optimal generation:
- HTML: SVG files for perfect vector scaling and text rendering
- PDF: High-resolution PNG files (3x scale) for sharp images with readable text

Changes:
- Generate SVG for HTML output using standard mmdc command
- Generate PNG for PDF output using mmdc with --scale 3 for high resolution
- Remove SVG LaTeX package dependency and Inkscape requirement
- Update documentation to reflect the dual-format approach

Results:
- HTML: Crisp, scalable vector diagrams with perfect text
- PDF: Sharp, high-resolution raster diagrams with clear text
- No external dependencies beyond mermaid-cli

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 19:20:13 +02:00
4aab281f4b Fix broken diagram links by implementing format-aware image paths
Problem: HTML output contained broken image links because all formats
used the same full path (e.g., living-documentation/diagram-536389.png).
This worked for PDFs but failed for HTML since both files are in the
same directory and need relative paths.

Solution:
- Add output format detection with isHTMLOutput function
- Update processMermaidBlock to take OutputPath parameter
- Generate context-appropriate paths:
  * HTML: relative path (diagram-536389.png)
  * PDF: full path (living-documentation/diagram-536389.png)
- Update transformDocument and compilation functions to pass output path

Both HTML and PDF generation now work correctly with proper image embedding.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 19:06:14 +02:00
1a92427b90 Refactor Haskell code for better maintainability and safety
Major improvements:
- Add custom DocsterError type with proper exception handling
- Introduce type-safe newtypes (SourceDir, OutputPath, DiagramId)
- Consistent Text usage throughout, eliminating String/Text mixing
- Extract LaTeX template generation into separate functions
- Add resource cleanup with bracket pattern for temporary files
- Improve function naming and comprehensive documentation
- Extract constants for better maintainability
- Remove all unused imports and fix compiler warnings

The refactored code maintains identical functionality while being
much more maintainable, type-safe, and following Haskell best practices.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 18:54:21 +02:00
90891d3797 Fix LaTeX PDF generation by adding comprehensive package support
- Add fancyvrb package and Shaded environment for syntax highlighting
- Include amsmath and amssymb packages for mathematical symbols
- Switch from pdflatex to xelatex with fontspec for Unicode support
- Add complete set of syntax highlighting commands for code blocks
- Fix directory-relative Mermaid file generation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 18:26:15 +02:00
0bbff27b44 Set maximum width, no warnings in chromium 2025-07-29 17:47:50 +02:00
e248395557 Fix Haskell project setup and implement Mermaid processing
- Update docster.cabal to modern format with GHC 9.12.2 compatibility
- Fix Mermaid code block detection using getDefaultExtensions
- Switch from SVG to PNG output for PDF compatibility
- Add CLAUDE.md with development instructions
- Update tooling from mise to ghcup for Haskell management

Known issues:
- Generated diagram files are created in root directory instead of alongside source files
- PDF generation fails with LaTeX errors for complex documents (missing \tightlist support)
- HTML output lacks proper DOCTYPE (quirks mode)
- Debug output still present in code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 17:23:04 +02:00
68507e85d1 initial version generated by chatgpt, but cabal file does not work 2025-07-29 12:48:18 +02:00