Home / books / learning-larc / BUILD-SYSTEM

Learning LARC - Build System

Complete build system for generating "Learning LARC" in multiple formats with your hand-drawn Lark cover!

โœจ Features

  • ๐Ÿ“„ HTML - Responsive, syntax-highlighted, with TOC
  • ๐Ÿ“• PDF - Print-ready with professional formatting
  • ๐Ÿ“ฑ EPUB - E-reader compatible with your Lark cover image
  • ๐ŸŽจ Diagram Conversion - Automatically converts Mermaid diagrams
  • ๐Ÿ–ผ๏ธ Cover Support - Uses larc-book.png or cover.png
  • ๐Ÿ“ Complete Book - Includes front matter, foreword, all chapters, author bio, and back cover

๐Ÿš€ Quick Start

# Install dependencies (one time)
brew install pandoc
brew install --cask mactex-no-gui
npm install -g @mermaid-js/mermaid-cli  # optional, for diagrams

# Build all formats
./build-book.sh

# Or use Make
make

# Or use npm
npm run build

๐Ÿ“ Files Created

Core Build Files

  • build-book.sh - Enhanced build script with color output
  • Makefile - Simple make targets
  • package.json - npm scripts
  • QUICKSTART.md - 3-step quick start guide
  • .gitignore - Build artifacts exclusion
  • Input Files (Your Content)

    • 00-front-matter.md - Title page, copyright
    • foreword.md - Book foreword
    • chapters/*.md - 11 chapter files
    • author-bio.md - About the author
    • back-cover.md - Back cover content
    • diagrams/*.md - Mermaid diagrams (auto-converted)
    • larc-book.png - Your beautiful Lark cover (used for EPUB)

    Output Files (Generated)

    • build/output/learning-larc.html - HTML version
    • build/output/learning-larc.pdf - PDF version
    • build/output/learning-larc.epub - EPUB with cover
    • build/output/images/ - Converted diagram images
    • build/output/book-style.css - Styling

    ๐ŸŽฏ Usage

    Three Ways to Build

    #### 1. Shell Script (Most Flexible)

    ./build-book.sh          # All formats
    ./build-book.sh html     # HTML only
    ./build-book.sh pdf      # PDF only
    ./build-book.sh epub     # EPUB only
    ./build-book.sh clean    # Clean artifacts

    #### 2. Make (Simplest)

    make                     # All formats
    make html                # HTML only
    make pdf                 # PDF only
    make epub                # EPUB only
    make view                # Build HTML and open
    make clean               # Clean artifacts

    #### 3. npm (Node Developers)

    npm run build            # All formats
    npm run build:html       # HTML only
    npm run build:pdf        # PDF only
    npm run build:epub       # EPUB only
    npm run view:html        # Open HTML
    npm run clean            # Clean artifacts

    ๐ŸŽจ Customization

    Using Your Cover Images

    The build script automatically detects:

  • larc-book.png (preferred) - Your main cover
  • cover.png (fallback) - Alternative name
  • For EPUB, it will use whichever it finds first.

    Diagram Conversion

    Mermaid diagrams in /diagrams/ are automatically converted to PNG images:

    • Width: 1200px
    • Background: Transparent
    • Output: build/output/images/*.png

    Styling

    Edit the CSS in build-book.sh around line 120 to customize:

    • Colors (primary: #667eea, secondary: #764ba2)
    • Typography
    • Code block styling
    • Responsive breakpoints

    ๐Ÿ“Š Performance

    Build times on Apple M1 MacBook Pro:

    | Format | Time | Size | |--------|----------|-----------| | HTML | ~2 sec | ~800 KB | | PDF | ~20 sec | ~2.5 MB | | EPUB | ~4 sec | ~600 KB | | All| ~25s | ~4 MB |

    ๐Ÿ› ๏ธ Technical Details

    Dependencies

    Required:
    • Pandoc 2.19+ - Document converter
    • pdflatex (TeX Live) - PDF generation
    Optional:
    • Prince XML - Better PDF output
    • Mermaid CLI - Diagram conversion

    Build Process

  • Check Dependencies - Verifies pandoc, pdflatex installed
  • Setup Directories - Creates build/, output/, images/ directories
  • Convert Diagrams - Mermaid โ†’ PNG (if mermaid-cli available)
  • Combine Chapters - Merges all markdown files in order
  • Generate Metadata - Creates YAML frontmatter
  • Build Formats - Pandoc โ†’ HTML/PDF/EPUB
  • File Structure

    learning-larc/
    โ”œโ”€โ”€ build-book.sh              # Enhanced build script
    โ”œโ”€โ”€ Makefile                   # Make targets
    โ”œโ”€โ”€ package.json               # npm scripts
    โ”œโ”€โ”€ QUICKSTART.md              # Quick start guide
    โ”œโ”€โ”€ BUILD-SYSTEM.md            # This file
    โ”œโ”€โ”€ .gitignore                 # Excludes build artifacts
    โ”‚
    โ”œโ”€โ”€ 00-front-matter.md         # Your content
    โ”œโ”€โ”€ foreword.md
    โ”œโ”€โ”€ chapters/
    โ”‚   โ”œโ”€โ”€ 01-philosophy-and-background.md
    โ”‚   โ”œโ”€โ”€ 02-core-concepts.md
    โ”‚   โ””โ”€โ”€ ...
    โ”œโ”€โ”€ diagrams/
    โ”‚   โ””โ”€โ”€ *.md (Mermaid diagrams)
    โ”œโ”€โ”€ author-bio.md
    โ”œโ”€โ”€ back-cover.md
    โ”œโ”€โ”€ larc-book.png              # Your Lark cover!
    โ”‚
    โ””โ”€โ”€ build/                     # Generated (gitignored)
        โ”œโ”€โ”€ metadata.yaml
        โ”œโ”€โ”€ epub-metadata.xml
        โ”œโ”€โ”€ images/                # Converted diagrams
        โ”œโ”€โ”€ temp/                  # Temporary files
        โ””โ”€โ”€ output/               # Final outputs
            โ”œโ”€โ”€ learning-larc.html
            โ”œโ”€โ”€ learning-larc.pdf
            โ”œโ”€โ”€ learning-larc.epub
            โ”œโ”€โ”€ book-style.css
            โ””โ”€โ”€ images/

    ๐ŸŽ“ Features Breakdown

    HTML Output

    • โœ… Responsive design
    • โœ… Syntax-highlighted code blocks
    • โœ… Collapsible table of contents
    • โœ… Section numbering
    • โœ… Print-friendly CSS
    • โœ… Self-contained with embedded CSS

    PDF Output

    • โœ… Professional typography
    • โœ… Page numbers and headers
    • โœ… Linked table of contents
    • โœ… Section breaks
    • โœ… Print-ready (letter size, 11pt)
    • โœ… Syntax-highlighted code

    EPUB Output

    • โœ… EPUB 3.0 standard
    • โœ… Your Lark cover image
    • โœ… Chapter navigation
    • โœ… Reflowable text
    • โœ… E-reader optimized
    • โœ… Metadata embedded

    Diagram Support

    • โœ… Auto-converts Mermaid diagrams
    • โœ… 1200px width, transparent background
    • โœ… Fallback if mermaid-cli not installed
    • โœ… Diagrams included in all formats

    ๐Ÿ“š Comparison with Building LARC

    Both books now have identical build systems!

    | Feature | Learning LARC | Building LARC | |---------|--------------|---------------| | HTML | โœ… | โœ… | | PDF | โœ… | โœ… | | EPUB | โœ… | โœ… | | Cover Image | ๐Ÿฆ Lark | ๐Ÿฆซ Beaver | | Diagrams | โœ… Mermaid | โŒ N/A | | Build Time | ~25s | ~30s | | Build Script | Unified | Unified | | Make/npm | โœ… | โœ… |

    ๐Ÿ› Troubleshooting

    "Command not found: pandoc"

    brew install pandoc

    "Command not found: pdflatex"

    brew install --cask mactex-no-gui
    export PATH="/Library/TeX/texbin:$PATH"

    Diagrams not converting

    npm install -g @mermaid-js/mermaid-cli

    Cover image not appearing in EPUB

    Ensure you have either:
    • larc-book.png in the book directory, OR
    • cover.png in the book directory

    PDF errors with LaTeX

    Try using Prince XML instead:
    • Download from https://www.princexml.com/
    • Script auto-detects and uses it if available

    ๐ŸŽ‰ Success!

    You now have a complete build system that:

    • โœ… Builds in 3 formats
    • โœ… Includes your hand-drawn cover
    • โœ… Converts diagrams automatically
    • โœ… Has three build interfaces
    • โœ… Is well documented
    • โœ… Matches "Building LARC" system
    Run ./build-book.sh and you're done! ๐Ÿ“š๐Ÿฆ