feat: add document conversion templates
Add md-to-pdf and md-to-docx templates for mytoolkit convert command. Migrated from workspace/templates.
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
// 默认空模板 —— 基础排版 + 简洁样式 + 封面页 + 三线表
|
||||
|
||||
#let primary = rgb("#1F4E79")
|
||||
#let accent = rgb("#3467A8")
|
||||
#let light = rgb("#96A0AA")
|
||||
#let rule-blue = accent.lighten(46%)
|
||||
|
||||
#let cover-page(title, subtitle, date) = {
|
||||
page(margin: (top: 3cm, bottom: 3cm, left: 3cm, right: 3cm))[
|
||||
#align(center + horizon)[
|
||||
#v(2cm)
|
||||
#text(size: 28pt, weight: "bold", fill: primary, title)
|
||||
#if subtitle != none {
|
||||
v(0.8cm)
|
||||
text(size: 16pt, fill: accent, subtitle)
|
||||
}
|
||||
#if date != none {
|
||||
v(2cm)
|
||||
text(size: 12pt, fill: light, date)
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
#let three-line-table(..args) = {
|
||||
let kwargs = args.named()
|
||||
let children = args.pos()
|
||||
|
||||
let new_children = ()
|
||||
let header_seen = false
|
||||
|
||||
for child in children {
|
||||
if child.func() == table.header {
|
||||
new_children.push(table.hline(stroke: 1.25pt + rule-blue))
|
||||
new_children.push(child)
|
||||
header_seen = true
|
||||
} else if header_seen and child.func() == table.hline {
|
||||
new_children.push(table.hline(stroke: 0.75pt + rule-blue))
|
||||
header_seen = false
|
||||
} else {
|
||||
new_children.push(child)
|
||||
}
|
||||
}
|
||||
new_children.push(table.hline(stroke: 1.25pt + rule-blue))
|
||||
|
||||
kwargs.stroke = none
|
||||
kwargs.inset = (x: 8pt, y: 5pt)
|
||||
|
||||
table(..new_children, ..kwargs)
|
||||
}
|
||||
|
||||
#let default(
|
||||
title: none,
|
||||
subtitle: none,
|
||||
date: none,
|
||||
body,
|
||||
) = {
|
||||
if title != none {
|
||||
cover-page(title, subtitle, date)
|
||||
pagebreak()
|
||||
}
|
||||
|
||||
set page(
|
||||
paper: "a4",
|
||||
margin: (top: 2.5cm, bottom: 2.5cm, left: 2.5cm, right: 2.5cm),
|
||||
footer: context {
|
||||
align(center)[
|
||||
#text(size: 9pt, fill: light)[
|
||||
#counter(page).display("1")
|
||||
]
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
set text(
|
||||
font: (
|
||||
"Cambria",
|
||||
"PingFang SC",
|
||||
"Helvetica Neue",
|
||||
"Arial",
|
||||
),
|
||||
size: 11pt,
|
||||
lang: "zh",
|
||||
)
|
||||
|
||||
// Body rhythm: spacing > leading; first-line indent = Typst default (none)
|
||||
set par(justify: true, leading: 0.78em, spacing: 1.12em)
|
||||
|
||||
set list(indent: 1.2em, body-indent: 0.45em, spacing: 0.62em)
|
||||
set enum(indent: 1.2em, body-indent: 0.45em, spacing: 0.62em)
|
||||
|
||||
// Headings: slightly tighter than long-form (manual/textbook) because H1 is 16pt here
|
||||
show heading.where(level: 1): it => {
|
||||
v(1.15em)
|
||||
text(size: 16pt, weight: "bold", fill: primary, it)
|
||||
v(0.5em)
|
||||
}
|
||||
|
||||
show heading.where(level: 2): it => {
|
||||
v(0.9em)
|
||||
text(size: 13pt, weight: "bold", fill: accent, it)
|
||||
v(0.34em)
|
||||
}
|
||||
|
||||
show heading.where(level: 3): it => {
|
||||
v(0.62em)
|
||||
text(size: 11pt, weight: "bold", fill: light, it)
|
||||
v(0.24em)
|
||||
}
|
||||
|
||||
set heading(numbering: none)
|
||||
show link: it => text(fill: accent, it)
|
||||
|
||||
body
|
||||
}
|
||||
Reference in New Issue
Block a user