// Quarto's default Pandoc Typst template defines this; custom template-partials // replace that file, so we need the helper here. #let content-to-string(content) = { if type(content) == str { content } else if content.has("text") { content.text } else if content.has("children") { content.children.map(content-to-string).join("") } else if content.has("body") { content-to-string(content.body) } else if content == [ ] { " " } else { "" } } #let article( title: none, subtitle: none, authors: none, keywords: (), date: none, abstract-title: none, abstract: none, thanks: none, cols: 1, lang: "fa", region: none, font: none, fontsize: 13pt, title-size: 1.5em, subtitle-size: 1.25em, heading-family: none, heading-weight: "bold", heading-style: "normal", heading-color: black, heading-line-height: 0.65em, mathfont: none, codefont: none, linestretch: 1, sectionnumbering: none, linkcolor: none, citecolor: none, filecolor: none, toc: false, toc_title: none, toc_depth: none, toc_indent: 1.5em, company: none, destinations: none, purpose: none, logo: none, doc, ) = { set document(title: title, keywords: keywords) set document( author: authors.map(author => content-to-string(author.name)).join(", ", last: " و "), ) if authors != none and authors != () set text(lang: lang, dir: rtl, size: fontsize) set text(font: font) if font != none set par(justify: true, leading: linestretch * 0.65em) set align(right) set heading(numbering: sectionnumbering) show math.equation: set text(font: mathfont) if mathfont != none show raw: set text(font: codefont) if codefont != none show link: set text(fill: rgb(content-to-string(linkcolor))) if linkcolor != none show ref: set text(fill: rgb(content-to-string(citecolor))) if citecolor != none let dest-text = if destinations == none { "" } else if type(destinations) == array { destinations.join(" - ") } else { destinations } let author-names = if authors == none or authors == () { "" } else { authors.map(a => content-to-string(a.name)).join(" - ") } // Title block block(width: 100%)[ #grid( columns: (1fr, auto), align: (right, left), [ #set par(leading: 0.9em, spacing: 0em) #if company != none { text(21pt, weight: "bold", company) if subtitle != none { text(14pt)[ | #subtitle] } linebreak() } #if title != none { text(14pt, weight: "bold", title) } ], if logo != none { image(logo, height: 1.8cm) } else { [] }, ) ] // Travel reports pass `purpose`; product-test reports put general info in the body. let show-travel-meta = purpose != none and purpose != "" if show-travel-meta { v(12pt) align(center, line(length: 100%)) text(1.4em, weight: "bold", [اطلاعات کلی]) v(8pt) let meta-row(label, value) = if value != none and value != "" { grid( columns: (8em, 1fr), gutter: 1em, align: (right, right), [#label], [#strong(value)], ) } stack( spacing: 12pt, meta-row([مقصد:], dest-text), meta-row([هدف مأموریت:], purpose), meta-row([تیم اعزامی:], author-names), meta-row([تاریخ:], date), ) v(24pt) align(center, line(length: 100%)) v(12pt) } else { v(16pt) } if toc { let title = if toc_title == none { auto } else { toc_title } block(above: 0em, below: 2em)[ #outline(title: title, depth: toc_depth, indent: toc_indent) ] } doc } #set table( inset: 6pt, stroke: 0.5pt + gray, align: center, )