|
|
пре 2 месеци | |
|---|---|---|
| .. | ||
| cases | пре 2 месеци | |
| README.md | пре 2 месеци | |
| skeleton.html | пре 2 месеци | |
The default template for
bash make.sh reformat. Takes any markdown / text / PDF input, renders the prose into a clean A4 portrait report. No charts, no KPI cards — for visual-heavy reports, use a CREATE template (e.g.data-viz-report) instead of REFORMAT.
This template is automatically selected when the user runs
bash make.sh reformat without --template. Other reformat-* templates can be
added in the same templates/ directory and selected via --template <slug>.
scripts/reformat_parse.py does:
source.md markdown-it-py placeholder fill
or .txt or .pdf ─► → HTML fragment ─► skeleton.html → page.html
Then scripts/render_html.cjs renders page.html → report.pdf via
Playwright (Chromium headless).
page-break-inside: avoid.Palette (neutral / general — re-skin per topic via --accent):
#1a1a1a body / #444 secondary / #666 tertiary / #999 muted#e5e5e5 / Hairline #efefef / Mute #f7f7f7<!-- ACCENT --> (defaults to #1d4ed8 indigo from make.sh)#f4f4f6, inline code text #c7254eTypography:
@page { size: A4 portrait; margin: 18mm 16mm; }
* { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
See skeleton.html (~150 lines, single self-contained
file).
Quick start:
# One-shot via make.sh (recommended)
bash scripts/make.sh reformat \
--input mydoc.md --out mydoc.pdf \
--title "My Document" --author "Jane Doe" --accent "#0a7488"
# Or two-step manually
python3 scripts/reformat_parse.py --input mydoc.md --out /tmp/page.html \
--title "My Document" --accent "#0a7488"
node scripts/render_html.cjs --in /tmp/page.html --out mydoc.pdf
For Word/DOCX legal contracts that must become a professional A4 PDF plus Markdown/HTML and reverse DOCX verification, do not rely on the default prose cover. Read ../../docs/docx-contract-roundtrip-professional-case.md and start from cases/pku-contract-roundtrip/source.html.
data-viz-report and write a custom
HTML rather than reformat.reformat_parse.py strips the leading # Title
from the body and uses it as the cover title. If you want the H1 to remain in
body, pass --title "..." explicitly so the lift is skipped.pdftotext -layout works for
text-native PDFs but garbles two-column / scanned PDFs. For those, use
the READ route (../../docs/read-guide.md)
first to get clean text, then reformat.()、:、/ overflow narrow
cells. Edit the source markdown to use half-width punctuation inside table
rows.<img> URLs. render_html.cjs waits for
networkidle, but very slow CDNs may still drop. Inline base64 or use
file:// paths for reliability.Required placeholders (filled by reformat_parse.py):
<!-- TITLE -->, <!-- SUBTITLE -->, <!-- AUTHOR -->, <!-- DATE --><!-- ACCENT --> (CSS hex)<!-- BODY_HTML --> (the rendered markdown)Structural invariants:
@page A4 portrait with 18/16 mm margins (do not change without re-tuning
cover height 261mm).page-break-before: always (except first).Diversify per run. Default accent is a generic blue — change it:
| Topic feel | Suggested accent |
|---|---|
| Engineering / hardware | #0066cc |
| Healthcare / wellness | #0a7488 |
| Sustainability | #3f7d3f |
| Finance | #0c8a5d |
| Creative / portfolio | #7c3aed |
| Industrial / energy | #d4621a |
For richer customization (different cover layout, sidebar, custom hero),
duplicate this directory as reformat-<your-slug>/, edit skeleton.html,
and select with --template <your-slug>.