docs: diagram + multi-format documentation across README, make-pdf skill, and how-to guide

README gains /make-pdf (Publisher) and /diagram (Diagram Maker) rows in the
sprint table. make-pdf's skill doc — the agent-facing contract — gains Core
patterns for mermaid/excalidraw fences (title/render=false/page= options),
the image policy ({width=}/{page=} directives, zero-truncation, conservative
auto-landscape), --to html|docx, and --strict, plus the --to vs --format
disambiguation in Common flags. New docs/howto-diagrams-and-formats.md is
the user-facing walkthrough: fences, directives, formats, /diagram triplet,
the mermaid racetrack trick, troubleshooting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-06-12 06:57:42 -07:00
parent 4c11fe4e61
commit 8759442089
4 changed files with 265 additions and 0 deletions
+66
View File
@@ -598,6 +598,69 @@ as you edit the markdown. Skip the PDF round trip until you're ready.
$P generate --no-confidential memo.md memo.pdf
```
### Diagrams — mermaid and excalidraw fences render as pictures
Any ` ```mermaid ` or ` ```excalidraw ` fence in the markdown renders as a
crisp vector diagram, fully offline (vendored bundle, no CDN). A broken fence
produces a visible red diagnostic block with the parse error — never silent
raw code.
Fence info-string options:
```
```mermaid title="Auth flow" ← caption + aria-label
```mermaid render=false ← keep it as a code block (today's behavior)
```mermaid page=landscape ← force this diagram onto a landscape page
```
A ` ```excalidraw ` fence contains a full .excalidraw scene file (what
excalidraw.com saves). Authoring NEW diagrams from English is `/diagram`'s
job — it emits an editable triplet (source, .excalidraw, SVG/PNG) and pairs
with this skill: embed the `.mmd` source in your markdown, not the PNG.
### Images — scaled right, never truncated
Local images inline automatically (relative paths resolve against the
markdown file). Every image caps at the content box — zero truncation, ever.
Oversized photos downscale to print resolution (300dpi) so payloads stay
small with no visible quality loss.
Per-image directives, written immediately after the image:
```
![chart](data.png){width=full} ← stretch to content-box width
![chart](data.png){width=50%} ← percentage or 3in/8cm/200px
![wide](arch.png){page=landscape} ← give it its own landscape page
![wide](shot.png){page=portrait} ← veto auto-landscape
```
Wide, small-text diagram images auto-promote to their own landscape page
(conservative: aspect ≥ 1.8, width over ~2.5x the content box, AND a
diagram-ish alt word — diagram/architecture/flowchart/chart/graph). The
promoted page is vertically centered. When the heuristic guesses wrong,
`{page=portrait}` vetoes it; false negatives just need `{page=landscape}`.
### Other formats — single-file HTML and Word
```bash
$P generate readme.md out.html --to html # ONE self-contained file: inline
# SVG diagrams, data-URI images,
# zero network refs, screen-readable
$P generate readme.md out.docx --to docx # Word: content fidelity (headings,
# tables, code, diagrams as PNG) —
# layout is Word's, not ours
```
`--to` is the output format. `--format` is something else entirely (a
`--page-size` alias) — don't confuse them.
### CI mode — fail loud on missing assets
```bash
$P generate docs.md --strict # missing/remote images exit non-zero
# instead of warn + placeholder
```
## Common flags
```
@@ -617,6 +680,9 @@ Branding:
--no-confidential Suppress the CONFIDENTIAL right-footer
Output:
--to pdf|html|docx Output format (default: pdf). html = single
self-contained file; docx = content fidelity.
--strict Missing/remote images fail the run (CI mode).
--page-numbers "N of M" footer (default on)
--tagged Accessible PDF (default on)
--outline PDF bookmarks from headings (default on)
+66
View File
@@ -94,6 +94,69 @@ as you edit the markdown. Skip the PDF round trip until you're ready.
$P generate --no-confidential memo.md memo.pdf
```
### Diagrams — mermaid and excalidraw fences render as pictures
Any ` ```mermaid ` or ` ```excalidraw ` fence in the markdown renders as a
crisp vector diagram, fully offline (vendored bundle, no CDN). A broken fence
produces a visible red diagnostic block with the parse error — never silent
raw code.
Fence info-string options:
```
```mermaid title="Auth flow" ← caption + aria-label
```mermaid render=false ← keep it as a code block (today's behavior)
```mermaid page=landscape ← force this diagram onto a landscape page
```
A ` ```excalidraw ` fence contains a full .excalidraw scene file (what
excalidraw.com saves). Authoring NEW diagrams from English is `/diagram`'s
job — it emits an editable triplet (source, .excalidraw, SVG/PNG) and pairs
with this skill: embed the `.mmd` source in your markdown, not the PNG.
### Images — scaled right, never truncated
Local images inline automatically (relative paths resolve against the
markdown file). Every image caps at the content box — zero truncation, ever.
Oversized photos downscale to print resolution (300dpi) so payloads stay
small with no visible quality loss.
Per-image directives, written immediately after the image:
```
![chart](data.png){width=full} ← stretch to content-box width
![chart](data.png){width=50%} ← percentage or 3in/8cm/200px
![wide](arch.png){page=landscape} ← give it its own landscape page
![wide](shot.png){page=portrait} ← veto auto-landscape
```
Wide, small-text diagram images auto-promote to their own landscape page
(conservative: aspect ≥ 1.8, width over ~2.5x the content box, AND a
diagram-ish alt word — diagram/architecture/flowchart/chart/graph). The
promoted page is vertically centered. When the heuristic guesses wrong,
`{page=portrait}` vetoes it; false negatives just need `{page=landscape}`.
### Other formats — single-file HTML and Word
```bash
$P generate readme.md out.html --to html # ONE self-contained file: inline
# SVG diagrams, data-URI images,
# zero network refs, screen-readable
$P generate readme.md out.docx --to docx # Word: content fidelity (headings,
# tables, code, diagrams as PNG) —
# layout is Word's, not ours
```
`--to` is the output format. `--format` is something else entirely (a
`--page-size` alias) — don't confuse them.
### CI mode — fail loud on missing assets
```bash
$P generate docs.md --strict # missing/remote images exit non-zero
# instead of warn + placeholder
```
## Common flags
```
@@ -113,6 +176,9 @@ Branding:
--no-confidential Suppress the CONFIDENTIAL right-footer
Output:
--to pdf|html|docx Output format (default: pdf). html = single
self-contained file; docx = content fidelity.
--strict Missing/remote images fail the run (CI mode).
--page-numbers "N of M" footer (default on)
--tagged Accessible PDF (default on)
--outline PDF bookmarks from headings (default on)