Add ICJ108 table style and RTL Typst helpers.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -29,3 +29,6 @@ format:
|
|||||||
- templates/typst/typst-template.typ
|
- templates/typst/typst-template.typ
|
||||||
- templates/typst/typst-show.typ
|
- templates/typst/typst-show.typ
|
||||||
- templates/typst/page.typ
|
- templates/typst/page.typ
|
||||||
|
filters:
|
||||||
|
- filters/ltr-spans.lua
|
||||||
|
- filters/typst-linebreaks.lua
|
||||||
|
|||||||
15
filters/ltr-spans.lua
Normal file
15
filters/ltr-spans.lua
Normal 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
|
||||||
20
filters/typst-linebreaks.lua
Normal file
20
filters/typst-linebreaks.lua
Normal 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
|
||||||
@@ -12,6 +12,14 @@
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--text: #1f2328;
|
||||||
|
--text2: #57606a;
|
||||||
|
--stroke: #d0d7de;
|
||||||
|
--bg: #ffffff;
|
||||||
|
--fill: #f6f8fa;
|
||||||
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
lang: fa;
|
lang: fa;
|
||||||
@@ -24,8 +32,8 @@ body {
|
|||||||
max-width: 48rem;
|
max-width: 48rem;
|
||||||
margin: 2rem auto;
|
margin: 2rem auto;
|
||||||
padding: 0 1.25rem;
|
padding: 0 1.25rem;
|
||||||
color: #1a1a1a;
|
color: var(--text);
|
||||||
background: #fff;
|
background: var(--bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3 {
|
h1, h2, h3 {
|
||||||
@@ -67,21 +75,43 @@ p.author,
|
|||||||
margin: 0.15rem 0 0.5rem 0;
|
margin: 0.15rem 0 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Match Inco Mixed ICJ108 HTML table chrome */
|
||||||
table {
|
table {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
font-size: 0.95rem;
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
border: 1px solid #ccc;
|
padding: 0.55rem 0.75rem;
|
||||||
padding: 0.4rem 0.6rem;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
thead th {
|
||||||
background: #eee;
|
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 {
|
code {
|
||||||
|
|||||||
Reference in New Issue
Block a user