xinetzone/SpecWeave / .agents/skills/doc-page
Doc Page
VerifiedCreate polished printable document pages for reports, forms, schedules, resumes, memos, and records, with clean A4 layout and optional PDF or DOCX export when needed.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.4 KB |
| assets/paged-report-template.html | other | 19.2 KB |
| references/content-blocks.md | markdown | 6.3 KB |
| references/design.md | markdown | 4.8 KB |
| references/document-types.md | markdown | 5.9 KB |
| references/images-media.md | markdown | 7.8 KB |
| references/pagination.md | markdown | 5.5 KB |
| references/research-palettes.md | markdown | 6.6 KB |
| references/typography-print.md | markdown | 1.7 KB |
| references/validation.md | markdown | 5.5 KB |
| scripts/export-paper-docx-fallback.py | script | 21.5 KB |
| scripts/export-paper-to-docx.mjs | script | 13.4 KB |
| scripts/export-paper-to-pdf.mjs | script | 7.9 KB |
| scripts/render-mermaid-to-svg.mjs | script | 2.8 KB |
| theme-smoke-test.html | other | 10.1 KB |
references/pagination.md
View on GitHub# Pagination Reference
Use this reference before implementing or changing the pagination framework.
## Core Model
The paginator renders a visible paged preview from a hidden continuous source document. The source remains the authority for print/PDF.
Recommended DOM:
```html
<section id="cover-source" class="has-cover" aria-hidden="true">
<div class="cover-page">...</div>
</section>
<main id="source" class="doc-flow print-only" aria-hidden="true">
<section class="flow-block">...</section>
<section class="flow-block">...</section>
</main>
<div id="pages" aria-label="分页报告"></div>
<nav class="viewer-tools" aria-label="预览缩放">...</nav>
```
Generated DOM:
```html
<div class="page-frame">
<article class="page">
<div class="page-content">...</div>
<div class="folio">1</div>
</article>
</div>
```
Optional generated cover DOM:
```html
<div class="page-frame cover-frame">
<article class="page">
<div class="cover-page">...</div>
</article>
</div>
```
In the default flow-pagination template, `.page-content` contains a `.page-slice` view of the same continuous `.doc-flow` content. The page slice is offset horizontally inside a fixed-height CSS multi-column layout. This gives a real paged screen preview without requiring the model to decide where paragraphs or tables should be split.
## Cover Pages
Use an authored cover when the genre expects one: formal reports, proposals, portfolios, image-led documents, or polished long-form deliverables. The cover is not part of the continuous `#source` flow.
Implementation rules:
- Keep cover markup in `#cover-source`, not inside `#source`.
- Enable it with `class="has-cover"` only when needed.
- Render it as `.cover-frame .page` with `padding: 0`; put any desired title-panel padding inside the cover component itself.
- Do not add `.folio` to the cover.
- Number generated content pages from 1, ignoring the cover.
- For print/PDF, show `#cover-source.has-cover` before `#source`, set `page: cover`, use `@page cover { margin: 0; }`, and force `break-after: page`.
- Keep the cover at exactly A4 dimensions (`var(--page-w)` by `var(--page-h)`) so screen preview and print agree.
Do not solve cover layout by adding a first `.flow-block` with negative margins or oversized images inside `#source`; it will still inherit content margins, page numbers, and column fragmentation behavior.
## Page Geometry
Use fixed A4 geometry for the page:
```css
:root {
--page-w: 210mm;
--page-h: 297mm;
--page-pad-top: 23mm;
--page-pad-x: 24mm;
--page-pad-bottom: 20mm;
--content-w: calc(var(--page-w) - var(--page-pad-x) * 2);
--content-h: calc(var(--page-h) - var(--page-pad-top) - var(--page-pad-bottom));
--column-gap: 36px;
}
```
The screen preview may scale the outer page with `transform: scale(...)`. Do not reduce the report font size for screen fit.
## Screen Preview Zoom
Paged HTML documents should behave like lightweight document viewers on screen:
- fit pages to the available viewport by default;
- allow user zoom with trackpad pinch gestures where browsers expose them as `ctrl/meta + wheel`;
- support `Ctrl/Cmd + +`, `Ctrl/Cmd + -`, and `Ctrl/Cmd + 0`;
- include small zoom buttons for discoverability;
- show zoom controls only while the user is adjusting scale, then fade them out;
- enforce a readable minimum scale and a reasonable maximum scale;
- optionally switch to two-column page preview when zoomed out and the viewport is wide enough.
Scale the `.page` with `transform: scale(var(--page-scale))` and resize `.page-frame` to reserve the scaled dimensions. Do not change the document font size for zoom.
Use print rules to hide `.viewer-tools`, reset `--page-scale` to `1`, reset preview columns to `1`, and remove screen-only frame sizing before print.
## Paginator Behavior
Algorithm:
1. Clear `#pages`.
2. If `#cover-source.has-cover` exists, clone it into an unnumbered `.cover-frame`.
3. Create a hidden measurement `.doc-flow.column-flow` with the same HTML as `#source`.
4. Measure how many fixed-height columns the source occupies.
5. Create one numbered `.page-frame` per measured column.
6. In each `.page-content`, add a `.page-slice` whose transform offsets the continuous column flow to the matching page.
7. Fit the generated page frames to the current preview zoom scale.
This is flow-level pagination. It intentionally lets the browser split paragraphs, lists, and ordinary tables in the same way print layout does. Avoid the old pattern of moving whole `.flow-block`s to the next page by default; that pattern is what creates large half-page gaps before big tables.
## Preventing Large Gaps
Large gaps usually mean the document is still using hard block-level pagination, fixed-height elements, or oversized keep-together blocks.
Fix by:
- using flow-pagination slices rather than moving whole `.flow-block`s;
- letting ordinary tables break naturally with `thead { display: table-header-group; }`;
- removing unnecessary `break-inside: avoid` from large sections;
- keeping figures and captions together only when the figure block fits within a page;
- splitting source lists into item-level blocks only when they are visually cleaner that way.
Do not fix pagination gaps by shrinking body text unless the overall document density is wrong.
## Limits
The screen preview is a close browser preview, not a full paged-media engine. Repeated table headers are reliable in Chrome print/PDF, but may not be identical in the screen column-slice preview. Footnotes, cross-references, and widow/orphan control still require a paged-media engine such as Paged.js or Vivliostyle.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |