Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ assets/

# Local reference material — not for distribution
.reference/

# PDF build artifacts
book-combined.md
claude-code-from-source.pdf
32 changes: 32 additions & 0 deletions .md-to-pdf.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require('path');

const CHROME_PATHS = {
darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
win32: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
linux: '/usr/bin/google-chrome',
};

const executablePath = process.env.CHROME_PATH || CHROME_PATHS[process.platform];

module.exports = {
stylesheet: [path.resolve(__dirname, 'book-style.css')],
body_class: 'book',
highlight_style: 'atom-one-dark',
launch_options: {
executablePath,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
},
pdf_options: {
format: 'Letter',
margin: {
top: '0.85in',
right: '0.85in',
bottom: '0.9in',
left: '0.9in',
},
printBackground: true,
displayHeaderFooter: true,
headerTemplate: `<div style="font-size:7pt; font-family:'Inter',sans-serif; color:#bbb; width:100%; text-align:center; padding-top:0.35in; letter-spacing:1px;">CLAUDE CODE FROM SOURCE</div>`,
footerTemplate: `<div style="font-size:7pt; font-family:'Inter',sans-serif; color:#aaa; width:100%; text-align:center; padding-bottom:0.35in;"><span class="pageNumber"></span></div>`,
},
};
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: pdf clean-pdf help

## Generate the book as a PDF (output: claude-code-from-source.pdf)
pdf:
@command -v md-to-pdf >/dev/null 2>&1 || { echo "Installing md-to-pdf..."; npm install -g md-to-pdf; }
@echo "Building book-combined.md..."
@node scripts/build-pdf.js
@echo "Rendering PDF..."
@md-to-pdf --config-file .md-to-pdf.config.js book-combined.md
@mv book-combined.pdf claude-code-from-source.pdf
@echo "✔ claude-code-from-source.pdf"

## Remove generated PDF artifacts
clean-pdf:
@rm -f book-combined.md claude-code-from-source.pdf
@echo "✔ cleaned"

## Show available targets
help:
@grep -E '^##' Makefile | sed 's/## / /'
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ Every chapter has layered depth: a narrative flow for technical leaders, deep-di

---

## Generate the PDF

You can render the entire book as a styled PDF locally:

```bash
# Requires Node.js and Google Chrome installed
make pdf
```

This runs `scripts/build-pdf.js` to assemble all chapters into a single document (with cover page, table of contents, and part dividers), then uses [`md-to-pdf`](https://github.com/simonhaenisch/md-to-pdf) to render it via headless Chrome.

The output is `claude-code-from-source.pdf` in the repo root. If Chrome is not at the default path for your OS, set `CHROME_PATH`:

```bash
CHROME_PATH="/path/to/chrome" make pdf
```

---

## The 10 Patterns That Make It Work

If you read nothing else:
Expand Down
Loading