Show shared title block on HTML and align PDF table chrome.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,7 +4,7 @@ Quarto templates for Kimia Razi Persian (RTL) business reports.
|
||||
|
||||
One `.qmd` source renders to:
|
||||
|
||||
- **HTML** — simple RTL reading layout (no print chrome on screen)
|
||||
- **HTML** — RTL reading layout with the same title block as PDF (company, logo, report title)
|
||||
- **PDF** — via WeasyPrint from the HTML, matching `typst-templates` page chrome (sidebar, header, title block, tables)
|
||||
|
||||
## Requirements
|
||||
@@ -53,5 +53,5 @@ examples/product-test.qmd
|
||||
## Notes
|
||||
|
||||
- PDF layout targets `typst-templates` (`product_test_template.typ` / `travel-report-template.typ`): A4, RTL, rotated left sidebar with page `n / N`, running header on page 2+, content-sized tables with grey header row.
|
||||
- HTML on screen stays a simple reading view; print chrome is `display: none` until print/PDF.
|
||||
- HTML on screen shows the shared title block (logo + company | subtitle + report title); running header and sidebar stay `display: none` until print/PDF.
|
||||
- Typst is not used for PDF generation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Inject typst-templates-style title block + sidebar into HTML for WeasyPrint PDF.
|
||||
-- Screen CSS hides .print-only; print.css shows them.
|
||||
-- Title block is shared with screen HTML; .print-only (running header, sidebar) is screen-hidden.
|
||||
|
||||
local function stringify(v)
|
||||
if v == nil then
|
||||
@@ -162,8 +162,9 @@ function Meta(meta)
|
||||
end
|
||||
|
||||
-- Logo first (left), title text second (right) — matches product_test_template.typ
|
||||
-- Visible on screen and in PDF (no print-only); Quarto default title is hidden in CSS.
|
||||
local title_block = string.format([[
|
||||
<div class="print-title-block print-only">
|
||||
<div class="print-title-block">
|
||||
%s
|
||||
<div class="title-text">
|
||||
<p class="company-line">%s%s</p>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Print / PDF styles matching typst-templates product_test_template.typ */
|
||||
/* Print / PDF styles (WeasyPrint); table chrome matches HTML report.css */
|
||||
|
||||
@font-face {
|
||||
font-family: "IRNazanin";
|
||||
@@ -30,8 +30,9 @@
|
||||
|
||||
:root {
|
||||
--text: #000000;
|
||||
--header-fill: #ebebeb; /* ~luma(235) */
|
||||
--text2: #57606a;
|
||||
--stroke: #000000;
|
||||
--fill: #f6f8fa;
|
||||
}
|
||||
|
||||
@page {
|
||||
@@ -301,19 +302,22 @@ li {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
/* ===== Tables (typst: 0.5pt stroke, header luma fill, content-sized) ===== */
|
||||
/* ===== Tables (rounded chrome like HTML; black stroke) ===== */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
margin: 10pt auto;
|
||||
border: 0.5pt solid var(--stroke);
|
||||
border: 1pt solid var(--stroke);
|
||||
border-radius: 8pt;
|
||||
overflow: hidden;
|
||||
font-size: 12.5pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 0.5pt solid var(--stroke);
|
||||
border: none;
|
||||
padding: 7pt 8pt;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
@@ -321,9 +325,15 @@ th, td {
|
||||
|
||||
thead th,
|
||||
tr:first-child th {
|
||||
background: var(--header-fill);
|
||||
background: var(--fill);
|
||||
font-weight: bold;
|
||||
color: var(--text);
|
||||
color: var(--text2);
|
||||
border-bottom: 1pt solid var(--stroke);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
tbody tr + tr td {
|
||||
border-top: 1pt solid var(--stroke);
|
||||
}
|
||||
|
||||
table [dir="ltr"],
|
||||
@@ -333,11 +343,11 @@ table .ltr {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Summary box */
|
||||
/* Summary box — same chrome as HTML (soft stroke) */
|
||||
.summary-box {
|
||||
border: 0.5pt solid #d0d7de;
|
||||
border: 1pt solid #d0d7de;
|
||||
border-radius: 8pt;
|
||||
background: #f6f8fa;
|
||||
background: var(--fill);
|
||||
padding: 10pt 12pt;
|
||||
margin: 10pt 0;
|
||||
page-break-inside: avoid;
|
||||
|
||||
@@ -41,24 +41,65 @@ h1, h2, h3 {
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.1rem;
|
||||
color: #444;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Quarto default title — replaced by .print-title-block (same as PDF) */
|
||||
#title-block-header,
|
||||
header#title-block-header,
|
||||
.quarto-title-block,
|
||||
.quarto-title,
|
||||
.quarto-title-meta,
|
||||
.quarto-title-meta-contents,
|
||||
header.quarto-title-block,
|
||||
h1.title,
|
||||
p.subtitle,
|
||||
p.author,
|
||||
.quarto-title-meta-author {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Screen header — same markup/layout as PDF .print-title-block */
|
||||
.print-title-block {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
margin: 0 0 1.5rem 0;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
.print-title-block .title-text {
|
||||
direction: rtl;
|
||||
text-align: right;
|
||||
line-height: 1.15;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.print-title-block .company-line {
|
||||
font-size: 1.75rem;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.print-title-block .company-line .subtitle {
|
||||
display: inline;
|
||||
font-size: 1.15rem;
|
||||
font-weight: normal;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.print-title-block .report-title {
|
||||
font-size: 1.15rem;
|
||||
font-weight: bold;
|
||||
margin: 0.2rem 0 0 0;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.print-title-block .logo {
|
||||
height: 3.4rem;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.report-meta {
|
||||
margin: 1.5rem 0;
|
||||
padding: 1rem 1.25rem;
|
||||
@@ -144,8 +185,10 @@ code {
|
||||
unicode-bidi: embed;
|
||||
}
|
||||
|
||||
/* Print chrome is injected for WeasyPrint PDF; hide on screen */
|
||||
/* Running header / sidebar are PDF-only; title block stays visible on screen */
|
||||
@media screen {
|
||||
.print-running-header,
|
||||
.print-sidebar,
|
||||
.print-only {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user