Add ICJ108 table style and RTL Typst helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-18 13:55:25 +03:30
parent f98054498d
commit 727e038ca7
4 changed files with 76 additions and 8 deletions

View File

@@ -29,3 +29,6 @@ format:
- templates/typst/typst-template.typ
- templates/typst/typst-show.typ
- templates/typst/page.typ
filters:
- filters/ltr-spans.lua
- filters/typst-linebreaks.lua

15
filters/ltr-spans.lua Normal file
View File

@@ -0,0 +1,15 @@
-- Preserve [text]{dir="ltr"} in Typst PDF (Pandoc HTML keeps the attribute;
-- Typst needs an explicit text(dir: ltr) wrapper).
function Span(el)
if not el.attributes or el.attributes.dir ~= "ltr" then
return nil
end
if not quarto.doc.is_format("typst") then
return nil
end
local text = pandoc.utils.stringify(el.content)
:gsub("\\", "\\\\")
:gsub("%]", "\\]")
:gsub("@", "\\@")
return pandoc.RawInline("typst", "#text(dir: ltr)[" .. text .. "]")
end

View File

@@ -0,0 +1,20 @@
-- Turn HTML <br> / LineBreak into Typst #linebreak() so two-line table
-- headers work in PDF as well as HTML.
local function typst_break()
return pandoc.RawInline("typst", "#linebreak()")
end
function RawInline(el)
if not quarto.doc.is_format("typst") then
return nil
end
if el.format == "html" and el.text:match("^<br%s*/?>$") then
return typst_break()
end
end
function LineBreak()
if quarto.doc.is_format("typst") then
return typst_break()
end
end

View File

@@ -12,6 +12,14 @@
font-style: normal;
}
:root {
--text: #1f2328;
--text2: #57606a;
--stroke: #d0d7de;
--bg: #ffffff;
--fill: #f6f8fa;
}
html {
direction: rtl;
lang: fa;
@@ -24,8 +32,8 @@ body {
max-width: 48rem;
margin: 2rem auto;
padding: 0 1.25rem;
color: #1a1a1a;
background: #fff;
color: var(--text);
background: var(--bg);
}
h1, h2, h3 {
@@ -67,21 +75,43 @@ p.author,
margin: 0.15rem 0 0.5rem 0;
}
/* Match Inco Mixed ICJ108 HTML table chrome */
table {
border-collapse: separate;
border-spacing: 0;
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
font-size: 0.95rem;
border: 1px solid var(--stroke);
border-radius: 8px;
overflow: hidden;
}
th, td {
border: 1px solid #ccc;
padding: 0.4rem 0.6rem;
padding: 0.55rem 0.75rem;
text-align: center;
font-size: 1.05rem;
font-variant-numeric: tabular-nums;
border: none;
}
th {
background: #eee;
thead th {
background: var(--fill);
font-size: 1rem;
color: var(--text2);
border-bottom: 1px solid var(--stroke);
line-height: 1.35;
}
tbody tr + tr td {
border-top: 1px solid var(--stroke);
}
/* Keep compound LTR numerics (e.g. 0.850 ± 0.05) in visual LTR order inside RTL tables */
table [dir="ltr"],
table .ltr {
direction: ltr;
unicode-bidi: isolate;
display: inline-block;
}
code {