mirror of https://github.com/garrytan/gstack.git
`make-pdf` emitted a spurious blank/near-blank first page whenever any content preceded the first <h1>. Two triggers: 1. YAML frontmatter — marked has no frontmatter awareness, so a leading `---\n...\n---` block rendered as a literal paragraph of body text. 2. A leading top-of-file <style> block — invisible, but still produced an empty first page. Root cause: `wrapChaptersByH1()` wraps everything before the first <h1> in a preamble `.chapter`. That section becomes `:first-of-type`, claiming the `break-before: auto` exception, so the first *real* chapter inherits `break-before: page` and starts on page 2. `preamble.trim().length > 0` was true even when the preamble was only non-rendering markup. Fix: - Strip a leading YAML frontmatter block before `marked.parse` (anchored to the document start, so a `---` thematic break elsewhere is untouched). - Don't give a non-rendering preamble (style/script/comment-only) its own chapter. Fold the markup into the first real chapter so its styling still applies but it no longer forces a page break. Adds render-unit regression tests for both triggers, the "real text preamble still gets its own chapter" invariant, and a non-frontmatter `---` thematic break. All fail on main (2 chapters / leaked frontmatter), pass with the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| src | ||
| test | ||
| SKILL.md | ||
| SKILL.md.tmpl | ||