Explanatory Document Generator
Generate branded, visual RTL Hebrew HTML documents with colored sections, callout boxes, phase cards, checklists, Q&A cards, and tables.
When to use this vs branded-doc:
explanatory-doc = Explaining concepts (trading bot to a friend, study tips, project overview)
branded-doc = Contract feedback, proposals, pricing sheets, client documents
How It Works
- Build a JSON file with the document content
- Run
bun scripts/explanatory-doc.ts input.json output.html
- Generate PDF:
/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --headless --disable-gpu --print-to-pdf="output.pdf" --no-margins "output.html"
Quick Start
# Generate from JSON file
bun scripts/explanatory-doc.ts /tmp/doc-input.json ~/Documents/output.html
# Pipe from stdin
cat /tmp/doc-input.json | bun scripts/explanatory-doc.ts - ~/Documents/output.html
# Generate PDF from HTML
/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser \
--headless --disable-gpu --no-margins \
--print-to-pdf="$HOME/Documents/output.pdf" \
"$HOME/Documents/output.html"
JSON Schema
{
"title": "Document Title",
"subtitle": "Optional context line (sources, date range, etc.)",
"date": "March 2026",
"recipient": "Name (optional)",
"sections": [
{
"num": 1,
"title": "Section Title",
"color": "blue",
"blocks": [
{ "type": "text", "content": "Paragraph. Use **bold** for emphasis." },
{ "type": "callout", "style": "warn", "title": "Note Title", "content": "Callout content" },
{ "type": "table", "headers": ["Col1", "Col2"], "rows": [["Cell", "Cell"], [{"text": "+22%", "style": "pos"}, {"text": "-30%", "style": "neg"}]] },
{ "type": "phase", "title": "Phase 1", "risk": "zero", "riskLabel": "Risk: None", "items": ["Step 1", "Step 2"], "note": "Optional note" },
{ "type": "list", "items": ["Bullet 1", "Bullet 2"] },
{ "type": "checklist", "items": ["Green checkmark item 1", "Green checkmark item 2"] },
{ "type": "qa", "items": [{ "q": "Question?", "a": "Answer." }] },
{ "type": "divider" }
]
}
],
"closing": "Optional closing text",
"output": "~/Documents/output.html"
}
Block Types
| Type |
Visual |
Use |
text |
Paragraph |
Regular content |
callout |
Colored sidebar box |
Key insights, warnings, tips |
table |
Striped table with dark header |
Data, comparisons |
phase |
Rounded card with risk badge |
Project phases, steps |
list |
Bullet list |
Features, items |
checklist |
Green checkmark list |
Safeguards, done items |
qa |
Card with blue question |
FAQ section |
divider |
Horizontal line |
Section separator |
Callout Styles
| Style |
Color |
Use |
info (default) |
Blue |
General notes, tips |
warn |
Amber |
Warnings, caveats |
danger |
Red |
Critical warnings, risks |
success |
Green |
Positive outcomes, recommendations |
Section Colors
All sections use the same green numbered circle for visual consistency (matching the Avi Huberman style). The color field is available for future customization but currently maps to the same green.
| Color |
Use |
blue |
Default, informational |
red |
Problems, risks, warnings |
green |
Solutions, positives |
amber |
Caution, expectations |
purple |
People, roles, meta |
Table Cell Styling
Regular cells are plain strings. For colored cells (positive/negative):
{ "text": "+22.8%", "style": "pos" }
{ "text": "-62.7%", "style": "neg" }
Phase Risk Levels
| Risk |
Badge Color |
Use |
zero |
Green |
No risk at all |
low |
Yellow |
Controlled, limited risk |
medium |
Orange |
Moderate risk |
high |
Red |
High risk |
Visual Style
The document uses a dark slate banner header with the document title (NOT freelancing branding). Modeled after the "Avi Huberman Tips" visual style:
- Header: Dark charcoal (#0f172a), white title text, centered
- Number badges: Muted teal (#0d9488), rounded rectangles (not circles)
- Table headers: Teal (#0d9488), with light gray alternating rows (#f8fafc)
- Section dividers: Teal top-border line on each section
- Callouts: Info=blue, Warn=amber (insight boxes), Danger=red, Success=green (action boxes)
- Q&A cards: Teal question text (#0d9488)
No personal branding (no name/email/phone). The document is about the topic, not the sender.
Page Break Rules
Each section gets its own page. The script forces page-break-before: always on every section (except the first). This guarantees no component is ever split across pages. The <hr> dividers between sections are hidden — replaced by teal top-border lines on each section.
Because each section gets a full page, make sure sections have enough content to fill the page well. A section with just a 2-row table and one line of text will look sparse. Add explanatory text, callouts with key takeaways, or context paragraphs to fill out short sections.
Writing Rules
When generating content for explanatory docs:
- Write in simple, everyday language — the reader is smart but not technical
- Use bold for key terms when they first appear
- Explain jargon in parentheses: "Stop Loss (automatic exit when price drops)"
- Keep paragraphs short — 2-3 sentences max
- Use callouts for the most important takeaways
- Use phases for step-by-step processes
- Use Q&A for anticipated questions
- Use checklists for safeguards or summary items
- Hebrew RTL — write naturally, the template handles direction
- Each section = one page, so fill each section with enough content: explanatory paragraphs, real data/facts, callouts with key insights. A sparse section with just a table looks empty.
- Be genuinely explanatory — add context, real numbers, analogies. The goal is that the reader walks away understanding the topic deeply, not just seeing bullet points.
Full Workflow
- User asks to explain something to someone
- Gather content (research, notes, conversation)
- Structure into sections with appropriate block types
- Write JSON to temp file
- Run
bun scripts/explanatory-doc.ts to generate HTML
- Generate PDF via Brave headless
- Copy to Obsidian:
~/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal/Personal/
1---2name: explanatory-doc3description: Generate visual, branded HTML documents that explain concepts to non-technical audiences. Use when creating explanatory content for friends, partners, investors, or anyone who needs to understand a technical topic in simple language. NOT for contracts or proposals (use branded-doc). Triggers on: "explain to", "make a document for", "explanatory doc", "visual explanation", "send him/her an explanation", "/explanatory-doc".4---56# Explanatory Document Generator78Generate branded, visual RTL Hebrew HTML documents with colored sections, callout boxes, phase cards, checklists, Q&A cards, and tables.910**When to use this vs branded-doc:**11- `explanatory-doc` = Explaining concepts (trading bot to a friend, study tips, project overview)12- `branded-doc` = Contract feedback, proposals, pricing sheets, client documents1314## How It Works15161. Build a JSON file with the document content172. Run `bun scripts/explanatory-doc.ts input.json output.html`183. Generate PDF: `/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --headless --disable-gpu --print-to-pdf="output.pdf" --no-margins "output.html"`1920## Quick Start2122```bash23# Generate from JSON file24bun scripts/explanatory-doc.ts /tmp/doc-input.json ~/Documents/output.html2526# Pipe from stdin27cat /tmp/doc-input.json | bun scripts/explanatory-doc.ts - ~/Documents/output.html2829# Generate PDF from HTML30/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser \31 --headless --disable-gpu --no-margins \32 --print-to-pdf="$HOME/Documents/output.pdf" \33 "$HOME/Documents/output.html"34```3536## JSON Schema3738```json39{40 "title": "Document Title",41 "subtitle": "Optional context line (sources, date range, etc.)",42 "date": "March 2026",43 "recipient": "Name (optional)",44 "sections": [45 {46 "num": 1,47 "title": "Section Title",48 "color": "blue",49 "blocks": [50 { "type": "text", "content": "Paragraph. Use **bold** for emphasis." },51 { "type": "callout", "style": "warn", "title": "Note Title", "content": "Callout content" },52 { "type": "table", "headers": ["Col1", "Col2"], "rows": [["Cell", "Cell"], [{"text": "+22%", "style": "pos"}, {"text": "-30%", "style": "neg"}]] },53 { "type": "phase", "title": "Phase 1", "risk": "zero", "riskLabel": "Risk: None", "items": ["Step 1", "Step 2"], "note": "Optional note" },54 { "type": "list", "items": ["Bullet 1", "Bullet 2"] },55 { "type": "checklist", "items": ["Green checkmark item 1", "Green checkmark item 2"] },56 { "type": "qa", "items": [{ "q": "Question?", "a": "Answer." }] },57 { "type": "divider" }58 ]59 }60 ],61 "closing": "Optional closing text",62 "output": "~/Documents/output.html"63}64```6566## Block Types6768| Type | Visual | Use |69|------|--------|-----|70| `text` | Paragraph | Regular content |71| `callout` | Colored sidebar box | Key insights, warnings, tips |72| `table` | Striped table with dark header | Data, comparisons |73| `phase` | Rounded card with risk badge | Project phases, steps |74| `list` | Bullet list | Features, items |75| `checklist` | Green checkmark list | Safeguards, done items |76| `qa` | Card with blue question | FAQ section |77| `divider` | Horizontal line | Section separator |7879## Callout Styles8081| Style | Color | Use |82|-------|-------|-----|83| `info` (default) | Blue | General notes, tips |84| `warn` | Amber | Warnings, caveats |85| `danger` | Red | Critical warnings, risks |86| `success` | Green | Positive outcomes, recommendations |8788## Section Colors8990All sections use the same green numbered circle for visual consistency (matching the Avi Huberman style). The `color` field is available for future customization but currently maps to the same green.9192| Color | Use |93|-------|-----|94| `blue` | Default, informational |95| `red` | Problems, risks, warnings |96| `green` | Solutions, positives |97| `amber` | Caution, expectations |98| `purple` | People, roles, meta |99100## Table Cell Styling101102Regular cells are plain strings. For colored cells (positive/negative):103```json104{ "text": "+22.8%", "style": "pos" }105{ "text": "-62.7%", "style": "neg" }106```107108## Phase Risk Levels109110| Risk | Badge Color | Use |111|------|-------------|-----|112| `zero` | Green | No risk at all |113| `low` | Yellow | Controlled, limited risk |114| `medium` | Orange | Moderate risk |115| `high` | Red | High risk |116117## Visual Style118119The document uses a **dark slate banner header** with the document title (NOT freelancing branding). Modeled after the "Avi Huberman Tips" visual style:120- **Header:** Dark charcoal (#0f172a), white title text, centered121- **Number badges:** Muted teal (#0d9488), rounded rectangles (not circles)122- **Table headers:** Teal (#0d9488), with light gray alternating rows (#f8fafc)123- **Section dividers:** Teal top-border line on each section124- **Callouts:** Info=blue, Warn=amber (insight boxes), Danger=red, Success=green (action boxes)125- **Q&A cards:** Teal question text (#0d9488)126127No personal branding (no name/email/phone). The document is about the topic, not the sender.128129## Page Break Rules130131**Each section gets its own page.** The script forces `page-break-before: always` on every section (except the first). This guarantees no component is ever split across pages. The `<hr>` dividers between sections are hidden — replaced by teal top-border lines on each section.132133Because each section gets a full page, make sure sections have enough content to fill the page well. A section with just a 2-row table and one line of text will look sparse. Add explanatory text, callouts with key takeaways, or context paragraphs to fill out short sections.134135## Writing Rules136137When generating content for explanatory docs:138- Write in simple, everyday language — the reader is smart but not technical139- Use **bold** for key terms when they first appear140- Explain jargon in parentheses: "Stop Loss (automatic exit when price drops)"141- Keep paragraphs short — 2-3 sentences max142- Use callouts for the most important takeaways143- Use phases for step-by-step processes144- Use Q&A for anticipated questions145- Use checklists for safeguards or summary items146- Hebrew RTL — write naturally, the template handles direction147- **Each section = one page**, so fill each section with enough content: explanatory paragraphs, real data/facts, callouts with key insights. A sparse section with just a table looks empty.148- Be genuinely explanatory — add context, real numbers, analogies. The goal is that the reader walks away understanding the topic deeply, not just seeing bullet points.149150## Full Workflow1511521. User asks to explain something to someone1532. Gather content (research, notes, conversation)1543. Structure into sections with appropriate block types1554. Write JSON to temp file1565. Run `bun scripts/explanatory-doc.ts` to generate HTML1576. Generate PDF via Brave headless1587. Copy to Obsidian: `~/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal/Personal/`