Skip to content

Commit af7983a

Browse files
authored
factor out non-pandoc part of the template into its own file (#259)
1 parent 73f2be0 commit af7983a

File tree

4 files changed

+214
-97
lines changed

4 files changed

+214
-97
lines changed

build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,10 @@ do_typst() {
838838
local extra_pandoc_options=$4
839839
mkdir -p "$(dirname ${output})"
840840

841+
# Hack: Just copy the Typst template(s) to the current directory so that
842+
# Typst can find them during compilation.
843+
cp /resources/templates/*.typ .
844+
841845
# TODO: https://github.com/TrustedComputingGroup/pandoc/issues/164
842846
# highlighting breaks diffing due to the \xxxxTok commands generated during highlighting being fragile.
843847
# Citations: https://pandoc.org/MANUAL.html#other-relevant-metadata-fields
@@ -934,7 +938,7 @@ do_pdf_from_typst() {
934938
local temp_pdf_file="$(basename ${input%.*}).pdf"
935939
rm -f ${temp_pdf_file}
936940
local start=$(date +%s)
937-
typst compile ${input} ${temp_pdf_file}
941+
typst compile --package-path="/resources/templates" ${input} ${temp_pdf_file}
938942
if [ $? -ne 0 ]; then
939943
FAILED=true
940944
echo "PDF output failed"

guide_typst.tcg

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,6 @@ type: GUIDANCE
55

66
---
77

8-
# Disclaimers, Notices, and License Terms
9-
10-
THIS SPECIFICATION IS PROVIDED “AS IS” WITH NO WARRANTIES WHATSOEVER, INCLUDING
11-
ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR
12-
PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR
13-
SAMPLE.
14-
15-
Without limitation, TCG disclaims all liability, including liability for
16-
infringement of any proprietary rights, relating to use of information in this
17-
specification and to the implementation of this specification, and TCG disclaims
18-
all liability for cost of procurement of substitute goods or services, lost
19-
profits, loss of use, loss of data or any incidental, consequential, direct,
20-
indirect, or special damages, whether under contract, tort, warranty or
21-
otherwise, arising in any way out of use or reliance upon this specification or
22-
any information herein. This document is copyrighted by Trusted Computing Group
23-
(TCG), and no license, express or implied, is granted herein other than as
24-
follows: You may not copy or reproduce the document or distribute it to others
25-
without written permission from TCG, except that you may freely do so for the
26-
purposes of (a) examining or implementing TCG specifications or (b) developing,
27-
testing, or promoting information technology standards and best practices, so
28-
long as you distribute the document with these disclaimers, notices, and license
29-
terms. Contact the Trusted Computing Group at www.trustedcomputinggroup.org for
30-
information on specification licensing through membership agreements. Any marks
31-
and brands contained herein are the property of their respective owners.
32-
33-
---
34-
358
# Change History
369

3710
| Revision | Date | Description |

template/tcg.typ

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,10 @@
1-
//
2-
// TCG Template for Typst
3-
// Initial version generated by Pandoc v3.6.4 using:
4-
// pandoc -D typst
5-
//
1+
#import "tcgcore.typ": conf
62

7-
//
8-
// TODO: Title page
9-
//
10-
11-
//
12-
// Font settings
13-
//
14-
// Normal text
15-
#set text(
16-
font: "Noto Sans",
17-
size: 9pt,
18-
)
19-
// Math
20-
#show math.equation: set text(
21-
font: "Noto Sans Math",
22-
size: 9pt,
23-
)
24-
// Code
25-
#show raw: set text(
26-
font: "Noto Sans Mono",
27-
size: 9pt,
3+
#show: conf.with(
4+
title: [
5+
$title$
6+
],
287
)
29-
// Headings
30-
#set heading(numbering: "1.1")
31-
#show heading: it => block()[
32-
#let size = 16pt - it.depth*2pt
33-
#if size < 10pt { size = 10pt }
34-
#set align(center)
35-
#set text(
36-
font: "Noto Sans",
37-
size: size,
38-
weight: "semibold")
39-
#it
40-
]
41-
42-
#let horizontalrule = line(start: (25%,0%), end: (75%,0%))
43-
44-
#show terms: it => {
45-
it.children
46-
.map(child => [
47-
#strong[#child.term]
48-
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
49-
])
50-
.join()
51-
}
52-
53-
#set table(
54-
inset: 6pt,
55-
stroke: 1pt
56-
)
57-
58-
#show figure.where(
59-
kind: table
60-
): set figure.caption(position: bottom)
61-
62-
#show figure.where(
63-
kind: image
64-
): set figure.caption(position: bottom)
65-
66-
$if(toc)$
67-
#outline(
68-
title: auto,
69-
depth: $toc-depth$
70-
);
71-
$endif$
728

739
$body$
7410

template/tcgcore.typ

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
// Informative box
2+
#let informative(
3+
content,
4+
kind: none,
5+
) = context {
6+
let pre = if kind != none { kind } else { "Informative Text" }
7+
let post = none
8+
9+
let meas = measure(content)
10+
if meas.height > 2in {
11+
post = "End of " + pre
12+
pre = "Start of " + pre
13+
}
14+
15+
box(
16+
strong(pre) + v(-2pt) + content + if post != none { v(-2pt) + strong(post) },
17+
width: 100%,
18+
inset: 10pt,
19+
stroke: (
20+
top: .5pt,
21+
bottom: .5pt,
22+
),
23+
)
24+
}
25+
26+
#let conf(
27+
title: none,
28+
authors: (),
29+
abstract: [],
30+
doc,
31+
) = {
32+
//
33+
// Font settings
34+
//
35+
// Normal text
36+
set text(
37+
font: "Manuale",
38+
size: 9pt,
39+
)
40+
// Math
41+
show math.equation: set text(
42+
font: "Inter",
43+
size: 9pt,
44+
)
45+
// Code
46+
show raw: set text(
47+
font: "Fira Code",
48+
size: 9pt,
49+
)
50+
// Headings
51+
set heading(numbering: "1.1")
52+
show heading: it => block()[
53+
#let size = 16pt - it.depth * 2pt
54+
#if size < 10pt { size = 10pt }
55+
#set align(center)
56+
#set text(
57+
font: "Inter",
58+
size: size,
59+
weight: "bold",
60+
)
61+
#it
62+
]
63+
64+
let horizontalrule = line(start: (25%, 0%), end: (75%, 0%))
65+
66+
show terms: it => {
67+
it
68+
.children
69+
.map(child => [
70+
#strong[#child.term]
71+
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
72+
])
73+
.join()
74+
}
75+
76+
set table(
77+
inset: 6pt,
78+
stroke: 1pt,
79+
)
80+
81+
show figure.where(kind: table): set figure.caption(position: bottom)
82+
83+
show figure.where(kind: image): set figure.caption(position: bottom)
84+
85+
set align(center)
86+
text(17pt, title)
87+
88+
let count = authors.len()
89+
let ncols = calc.min(count, 3)
90+
grid(
91+
columns: (1fr,) * ncols,
92+
row-gutter: 24pt,
93+
..authors.map(author => [
94+
#author.name \
95+
#author.affiliation \
96+
#link("mailto:" + author.email)
97+
]),
98+
)
99+
100+
par(justify: false)[
101+
*Abstract* \
102+
#abstract
103+
]
104+
105+
set align(left)
106+
107+
pagebreak()
108+
109+
heading("Disclaimers, Notices, and License Terms", level: 1)
110+
111+
heading("Copyright Licenses", level: 2)
112+
113+
[
114+
Trusted Computing Group (TCG) grants to the user of the source code in this
115+
specification (the \"Source Code\") a worldwide, irrevocable, nonexclusive,
116+
royalty free, copyright license to reproduce, create derivative works,
117+
distribute, display and perform the Source Code and derivative works
118+
thereof, and to grant others the rights granted herein.
119+
120+
The TCG grants to the user of the other parts of the specification (other
121+
than the Source Code) the rights to reproduce, distribute, display, and
122+
perform the specification solely for the purpose of developing products
123+
based on such documents.
124+
]
125+
126+
heading("Source Code Distribution Conditions", level: 2)
127+
128+
[
129+
Redistributions of Source Code must retain the above copyright licenses,
130+
this list of conditions and the following disclaimers.
131+
132+
Redistributions in binary form must reproduce the above copyright licenses,
133+
this list of conditions and the following disclaimers in the documentation
134+
and/or other materials provided with the distribution.
135+
]
136+
137+
heading("Disclaimers", level: 2)
138+
139+
[
140+
THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF LICENSE
141+
OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH RESPECT TO
142+
PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) THAT MAY BE
143+
NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. Contact TCG
144+
Administration #link("mailto:[email protected]") for information on
145+
specification licensing rights available through TCG membership agreements.
146+
147+
THIS SPECIFICATION IS PROVIDED “AS IS” WITH NO EXPRESS OR IMPLIED WARRANTIES
148+
WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
149+
PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR NONINFRINGEMENT OF
150+
INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY
151+
PROPOSAL, SPECIFICATION OR SAMPLE.
152+
153+
Without limitation, TCG and its members and licensors disclaim all
154+
liability, including liability for infringement of any proprietary rights,
155+
relating to use of information in this specification and to the
156+
implementation of this specification, and TCG disclaims all liability for
157+
cost of procurement of substitute goods or services, lost profits, loss of
158+
use, loss of data or any incidental, consequential, direct, indirect, or
159+
special damages, whether under contract, tort, warranty or otherwise,
160+
arising in any way out of use or reliance upon this specification or any
161+
information herein.
162+
163+
Any marks and brands contained herein are the property of their respective
164+
owners.
165+
]
166+
167+
pagebreak()
168+
169+
170+
heading("Document Style", level: 1)
171+
172+
heading("Key Words", level: 2)
173+
174+
[
175+
The key words "MUST," "MUST NOT," "REQUIRED," "SHALL," "SHALL NOT," "SHOULD,"
176+
"SHOULD NOT," "RECOMMENDED," "MAY," and "OPTIONAL" in this document's normative
177+
statements are to be interpreted as described in
178+
[RFC 2119: Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt).
179+
]
180+
181+
heading("Statement Type", level: 2)
182+
183+
[
184+
Please note an important distinction between different sections of text
185+
throughout this document. There are two distinctive kinds of text: *informative
186+
comments* and *normative statements*. Because most of the text in this
187+
specification will be of the kind *normative statements*, the authors have
188+
informally defined it as the default and, as such, have specifically called out
189+
text of the kind *informative comment*. They have done this by flagging the
190+
beginning and end of each informative comment and highlighting its text in gray.
191+
This means that unless text is specifically marked as of the kind *informative
192+
comment*, it can be considered a *normative statement*.
193+
]
194+
195+
informative(
196+
[Reach out to #link("mailto:[email protected]") with any questions about this document.
197+
],
198+
kind: "Example",
199+
)
200+
201+
pagebreak()
202+
203+
doc
204+
}

0 commit comments

Comments
 (0)