Skip to content

factor out non-pandoc part of the template into its own file #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,10 @@ do_typst() {
local extra_pandoc_options=$4
mkdir -p "$(dirname ${output})"

# Hack: Just copy the Typst template(s) to the current directory so that
# Typst can find them during compilation.
cp /resources/templates/*.typ .

# TODO: https://github.com/TrustedComputingGroup/pandoc/issues/164
# highlighting breaks diffing due to the \xxxxTok commands generated during highlighting being fragile.
# Citations: https://pandoc.org/MANUAL.html#other-relevant-metadata-fields
Expand Down Expand Up @@ -934,7 +938,7 @@ do_pdf_from_typst() {
local temp_pdf_file="$(basename ${input%.*}).pdf"
rm -f ${temp_pdf_file}
local start=$(date +%s)
typst compile ${input} ${temp_pdf_file}
typst compile --package-path="/resources/templates" ${input} ${temp_pdf_file}
if [ $? -ne 0 ]; then
FAILED=true
echo "PDF output failed"
Expand Down
27 changes: 0 additions & 27 deletions guide_typst.tcg
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,6 @@ type: GUIDANCE

---

# Disclaimers, Notices, and License Terms

THIS SPECIFICATION IS PROVIDED “AS IS” WITH NO WARRANTIES WHATSOEVER, INCLUDING
ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR
PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR
SAMPLE.

Without limitation, TCG disclaims all liability, including liability for
infringement of any proprietary rights, relating to use of information in this
specification and to the implementation of this specification, and TCG disclaims
all liability for cost of procurement of substitute goods or services, lost
profits, loss of use, loss of data or any incidental, consequential, direct,
indirect, or special damages, whether under contract, tort, warranty or
otherwise, arising in any way out of use or reliance upon this specification or
any information herein. This document is copyrighted by Trusted Computing Group
(TCG), and no license, express or implied, is granted herein other than as
follows: You may not copy or reproduce the document or distribute it to others
without written permission from TCG, except that you may freely do so for the
purposes of (a) examining or implementing TCG specifications or (b) developing,
testing, or promoting information technology standards and best practices, so
long as you distribute the document with these disclaimers, notices, and license
terms. Contact the Trusted Computing Group at www.trustedcomputinggroup.org for
information on specification licensing through membership agreements. Any marks
and brands contained herein are the property of their respective owners.

---

# Change History

| Revision | Date | Description |
Expand Down
74 changes: 5 additions & 69 deletions template/tcg.typ
Original file line number Diff line number Diff line change
@@ -1,74 +1,10 @@
//
// TCG Template for Typst
// Initial version generated by Pandoc v3.6.4 using:
// pandoc -D typst
//
#import "tcgcore.typ": conf

//
// TODO: Title page
//

//
// Font settings
//
// Normal text
#set text(
font: "Noto Sans",
size: 9pt,
)
// Math
#show math.equation: set text(
font: "Noto Sans Math",
size: 9pt,
)
// Code
#show raw: set text(
font: "Noto Sans Mono",
size: 9pt,
#show: conf.with(
title: [
$title$
],
)
// Headings
#set heading(numbering: "1.1")
#show heading: it => block()[
#let size = 16pt - it.depth*2pt
#if size < 10pt { size = 10pt }
#set align(center)
#set text(
font: "Noto Sans",
size: size,
weight: "semibold")
#it
]

#let horizontalrule = line(start: (25%,0%), end: (75%,0%))

#show terms: it => {
it.children
.map(child => [
#strong[#child.term]
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
])
.join()
}

#set table(
inset: 6pt,
stroke: 1pt
)

#show figure.where(
kind: table
): set figure.caption(position: bottom)

#show figure.where(
kind: image
): set figure.caption(position: bottom)

$if(toc)$
#outline(
title: auto,
depth: $toc-depth$
);
$endif$

$body$

Expand Down
204 changes: 204 additions & 0 deletions template/tcgcore.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
// Informative box
#let informative(
content,
kind: none,
) = context {
let pre = if kind != none { kind } else { "Informative Text" }
let post = none

let meas = measure(content)
if meas.height > 2in {
post = "End of " + pre
pre = "Start of " + pre
}

box(
strong(pre) + v(-2pt) + content + if post != none { v(-2pt) + strong(post) },
width: 100%,
inset: 10pt,
stroke: (
top: .5pt,
bottom: .5pt,
),
)
}

#let conf(
title: none,
authors: (),
abstract: [],
doc,
) = {
//
// Font settings
//
// Normal text
set text(
font: "Manuale",
size: 9pt,
)
// Math
show math.equation: set text(
font: "Inter",
size: 9pt,
)
// Code
show raw: set text(
font: "Fira Code",
size: 9pt,
)
// Headings
set heading(numbering: "1.1")
show heading: it => block()[
#let size = 16pt - it.depth * 2pt
#if size < 10pt { size = 10pt }
#set align(center)
#set text(
font: "Inter",
size: size,
weight: "bold",
)
#it
]

let horizontalrule = line(start: (25%, 0%), end: (75%, 0%))

show terms: it => {
it
.children
.map(child => [
#strong[#child.term]
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
])
.join()
}

set table(
inset: 6pt,
stroke: 1pt,
)

show figure.where(kind: table): set figure.caption(position: bottom)

show figure.where(kind: image): set figure.caption(position: bottom)

set align(center)
text(17pt, title)

let count = authors.len()
let ncols = calc.min(count, 3)
grid(
columns: (1fr,) * ncols,
row-gutter: 24pt,
..authors.map(author => [
#author.name \
#author.affiliation \
#link("mailto:" + author.email)
]),
)

par(justify: false)[
*Abstract* \
#abstract
]

set align(left)

pagebreak()

heading("Disclaimers, Notices, and License Terms", level: 1)

heading("Copyright Licenses", level: 2)

[
Trusted Computing Group (TCG) grants to the user of the source code in this
specification (the \"Source Code\") a worldwide, irrevocable, nonexclusive,
royalty free, copyright license to reproduce, create derivative works,
distribute, display and perform the Source Code and derivative works
thereof, and to grant others the rights granted herein.

The TCG grants to the user of the other parts of the specification (other
than the Source Code) the rights to reproduce, distribute, display, and
perform the specification solely for the purpose of developing products
based on such documents.
]

heading("Source Code Distribution Conditions", level: 2)

[
Redistributions of Source Code must retain the above copyright licenses,
this list of conditions and the following disclaimers.

Redistributions in binary form must reproduce the above copyright licenses,
this list of conditions and the following disclaimers in the documentation
and/or other materials provided with the distribution.
]

heading("Disclaimers", level: 2)

[
THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF LICENSE
OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH RESPECT TO
PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) THAT MAY BE
NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. Contact TCG
Administration #link("mailto:[email protected]") for information on
specification licensing rights available through TCG membership agreements.

THIS SPECIFICATION IS PROVIDED “AS IS” WITH NO EXPRESS OR IMPLIED WARRANTIES
WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR NONINFRINGEMENT OF
INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY
PROPOSAL, SPECIFICATION OR SAMPLE.

Without limitation, TCG and its members and licensors disclaim all
liability, including liability for infringement of any proprietary rights,
relating to use of information in this specification and to the
implementation of this specification, and TCG disclaims all liability for
cost of procurement of substitute goods or services, lost profits, loss of
use, loss of data or any incidental, consequential, direct, indirect, or
special damages, whether under contract, tort, warranty or otherwise,
arising in any way out of use or reliance upon this specification or any
information herein.

Any marks and brands contained herein are the property of their respective
owners.
]

pagebreak()


heading("Document Style", level: 1)

heading("Key Words", level: 2)

[
The key words "MUST," "MUST NOT," "REQUIRED," "SHALL," "SHALL NOT," "SHOULD,"
"SHOULD NOT," "RECOMMENDED," "MAY," and "OPTIONAL" in this document's normative
statements are to be interpreted as described in
[RFC 2119: Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt).
]

heading("Statement Type", level: 2)

[
Please note an important distinction between different sections of text
throughout this document. There are two distinctive kinds of text: *informative
comments* and *normative statements*. Because most of the text in this
specification will be of the kind *normative statements*, the authors have
informally defined it as the default and, as such, have specifically called out
text of the kind *informative comment*. They have done this by flagging the
beginning and end of each informative comment and highlighting its text in gray.
This means that unless text is specifically marked as of the kind *informative
comment*, it can be considered a *normative statement*.
]

informative(
[Reach out to #link("mailto:[email protected]") with any questions about this document.
],
kind: "Example",
)

pagebreak()

doc
}