latex-kit 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,7 +63,7 @@ latex-kit render letter.tex --json # machine-readable summary
63
63
  | `-o, --out <dir>` | `out` | Output directory, relative to `--root` |
64
64
  | `-e, --engine <name>` | `auto` | `auto` (from the packages the file loads), `lualatex`, `xelatex`, `pdflatex`, `pdfps` (PSTricks) |
65
65
  | `--root <dir>` | current directory | Directory TeX can see |
66
- | `--image <ref>` | pinned `ghcr.io/constructive-io/latex-kit` (TeX Live 2026) | Docker image |
66
+ | `--image <ref>` | pinned `constructiveio/latex-kit` on Docker Hub (TeX Live 2026) | Docker image |
67
67
  | `--platform <os/arch>` | native | Docker `--platform` |
68
68
  | `--local` | | Use `latexmk` on `PATH` instead of Docker (not pinned) |
69
69
  | `--source-date-epoch <s>` | `SOURCE_DATE_EPOCH`, else the last git commit | Build timestamp |
package/boilerplates.d.ts CHANGED
@@ -3,6 +3,19 @@
3
3
  * and amount is a placeholder.
4
4
  */
5
5
  export type FileMap = Record<string, string>;
6
+ /** Paper presets for `latex-kit init --paper --preset <name>`. */
7
+ export declare const PAPER_PRESETS: readonly ["whitepaper", "plain"];
8
+ export type PaperPreset = (typeof PAPER_PRESETS)[number];
6
9
  export declare function projectFiles(version: string): FileMap;
7
- export declare function paperFiles(): FileMap;
10
+ /** A minimal LuaLaTeX paper: fontspec, natbib. */
11
+ export declare function plainPaperFiles(): FileMap;
8
12
  export declare function templateFiles(name: string): FileMap;
13
+ /**
14
+ * The Constructive whitepaper style (rls-whitepaper, hyperweb-whitepaper):
15
+ * article class, the code colour palette and TypeScript listings style,
16
+ * TikZ and PSTricks, IEEE references. PSTricks means latex → dvips → ps2pdf,
17
+ * which `engine: auto` picks.
18
+ */
19
+ export declare function whitepaperFiles(): FileMap;
20
+ /** Files for `latex-kit init --paper`. */
21
+ export declare function paperFiles(preset?: PaperPreset): FileMap;
package/boilerplates.js CHANGED
@@ -4,9 +4,15 @@
4
4
  * and amount is a placeholder.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.PAPER_PRESETS = void 0;
7
8
  exports.projectFiles = projectFiles;
8
- exports.paperFiles = paperFiles;
9
+ exports.plainPaperFiles = plainPaperFiles;
9
10
  exports.templateFiles = templateFiles;
11
+ exports.whitepaperFiles = whitepaperFiles;
12
+ exports.paperFiles = paperFiles;
13
+ const paper_style_1 = require("./paper-style");
14
+ /** Paper presets for `latex-kit init --paper --preset <name>`. */
15
+ exports.PAPER_PRESETS = ['whitepaper', 'plain'];
10
16
  function projectFiles(version) {
11
17
  return {
12
18
  'package.json': `${JSON.stringify({
@@ -129,7 +135,8 @@ data:
129
135
  `,
130
136
  };
131
137
  }
132
- function paperFiles() {
138
+ /** A minimal LuaLaTeX paper: fontspec, natbib. */
139
+ function plainPaperFiles() {
133
140
  return {
134
141
  '.gitignore': 'out/\n',
135
142
  'paper/main.tex': `\\documentclass[11pt]{article}
@@ -223,3 +230,194 @@ export default z.object({
223
230
  `,
224
231
  };
225
232
  }
233
+ const PAPER_WORKFLOW = (file, name) => `name: Paper
234
+
235
+ on:
236
+ push:
237
+ branches: [main]
238
+ tags: ['v*']
239
+ pull_request:
240
+
241
+ jobs:
242
+ pdf:
243
+ runs-on: ubuntu-latest
244
+ permissions:
245
+ contents: read
246
+ steps:
247
+ - uses: actions/checkout@v4
248
+ with:
249
+ fetch-depth: 0 # the build date comes from the last commit
250
+ - uses: constructive-io/latex-kit/action@v1
251
+ with:
252
+ file: ${file}
253
+ engine: auto
254
+ verify: 'true'
255
+ artifact-name: ${name}.pdf
256
+
257
+ # pushing a tag like v1.0.0 attaches the PDF to a GitHub release
258
+ release:
259
+ needs: pdf
260
+ if: startsWith(github.ref, 'refs/tags/v')
261
+ runs-on: ubuntu-latest
262
+ permissions:
263
+ contents: write
264
+ steps:
265
+ - uses: actions/download-artifact@v4
266
+ with:
267
+ name: ${name}.pdf
268
+ path: pdf
269
+ - env:
270
+ GH_TOKEN: \${{ github.token }}
271
+ run: |
272
+ pdf=$(find pdf -name '*.pdf' | head -n 1)
273
+ cp "$pdf" "${name}-$GITHUB_REF_NAME.pdf"
274
+ gh release create "$GITHUB_REF_NAME" "${name}-$GITHUB_REF_NAME.pdf" -R "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --generate-notes
275
+ `;
276
+ /**
277
+ * The Constructive whitepaper style (rls-whitepaper, hyperweb-whitepaper):
278
+ * article class, the code colour palette and TypeScript listings style,
279
+ * TikZ and PSTricks, IEEE references. PSTricks means latex → dvips → ps2pdf,
280
+ * which `engine: auto` picks.
281
+ */
282
+ function whitepaperFiles() {
283
+ return {
284
+ '.gitignore': 'out/\n',
285
+ 'paper/main.tex': `% A paper in the Constructive whitepaper style (as rls-whitepaper and
286
+ % hyperweb-whitepaper). It loads PSTricks, so latex-kit builds it with
287
+ % latex -> bibtex -> dvips -> ps2pdf; \`latex-kit render paper/main.tex\` picks that.
288
+ \\documentclass{article}
289
+ \\usepackage{amsmath}
290
+ \\usepackage{graphicx}
291
+ \\usepackage{xcolor}
292
+ \\usepackage{listings}
293
+ \\usepackage{geometry}
294
+ \\usepackage{enumitem}
295
+ \\usepackage{amsfonts}
296
+ \\usepackage{amssymb}
297
+ \\usepackage[hidelinks]{hyperref}
298
+ \\usepackage{cleveref}
299
+
300
+ \\usepackage{pstricks}
301
+ \\usepackage{tikz}
302
+ \\usetikzlibrary{arrows.meta, positioning, shapes, calc}
303
+
304
+ \\input{headers/colors.tex}
305
+ \\input{headers/typescript.tex}
306
+
307
+ \\title{Paper Title: What the Paper Shows}
308
+ \\author{Your Name, A. Co-Author
309
+ \\\\ \\\\
310
+ \\texttt{info@example.com}}
311
+ \\date{v0.0.1 --- \\today}
312
+
313
+ \\begin{document}
314
+
315
+ \\maketitle
316
+
317
+ \\begin{abstract}
318
+ One paragraph: the problem, why existing approaches fall short, what this
319
+ paper presents, and what it achieves.
320
+ \\end{abstract}
321
+
322
+ \\tableofcontents
323
+
324
+ \\input{sections/introduction.tex}
325
+ \\input{sections/design.tex}
326
+ \\input{sections/conclusion.tex}
327
+
328
+ \\newpage
329
+
330
+ \\section{Bibliography}
331
+ \\bibliographystyle{IEEEtran}
332
+ \\bibliography{references}
333
+
334
+ \\end{document}
335
+ `,
336
+ 'paper/headers/colors.tex': paper_style_1.WHITEPAPER_COLORS_TEX,
337
+ 'paper/headers/typescript.tex': paper_style_1.WHITEPAPER_TYPESCRIPT_TEX,
338
+ 'paper/sections/introduction.tex': `\\section{Introduction}
339
+
340
+ State the problem and why it matters. Cite prior work like this~\\cite{stonebraker1986}.
341
+ \\Cref{fig:flow} is drawn with PSTricks.
342
+
343
+ \\begin{figure}[ht]
344
+ \\centering
345
+ \\begin{pspicture}(0,0)(9,3)
346
+ \\psframe[fillstyle=solid,fillcolor=lightpurple,framearc=0.2](0,0.75)(3,2.25)
347
+ \\rput(1.5,1.5){Client}
348
+ \\psline[linewidth=1pt]{->}(3,1.5)(6,1.5)
349
+ \\rput(4.5,1.85){\\small request}
350
+ \\pscircle[fillstyle=solid,fillcolor=codelightgreen](7.5,1.5){1.2}
351
+ \\rput(7.5,1.5){Server}
352
+ \\end{pspicture}
353
+ \\caption{A request flow, drawn with PSTricks.}
354
+ \\label{fig:flow}
355
+ \\end{figure}
356
+ `,
357
+ 'paper/sections/design.tex': `\\section{Design}
358
+
359
+ \\Cref{fig:layers} is drawn with TikZ, and \\cref{lst:counter} uses the
360
+ TypeScript listing style.
361
+
362
+ \\begin{figure}[ht]
363
+ \\centering
364
+ \\begin{tikzpicture}[
365
+ node distance=1.2cm,
366
+ box/.style={rectangle, draw, rounded corners, fill=blue!10, text width=2.8cm, text centered, minimum height=0.9cm},
367
+ store/.style={rectangle, draw, rounded corners, fill=orange!10, text width=2.8cm, text centered, minimum height=0.9cm},
368
+ arrow/.style={-{Stealth}, thick}
369
+ ]
370
+ \\node[box] (api) {API};
371
+ \\node[box, below=of api] (policy) {Policy check};
372
+ \\node[store, right=1.6cm of policy] (data) {Data};
373
+ \\draw[arrow] (api) -- (policy);
374
+ \\draw[arrow] (policy) -- node[above] {\\small allowed} (data);
375
+ \\end{tikzpicture}
376
+ \\caption{Layers, drawn with TikZ.}
377
+ \\label{fig:layers}
378
+ \\end{figure}
379
+
380
+ \\begin{lstlisting}[language=typescript, caption=A small contract, label=lst:counter, style=typescript]
381
+ export default class Counter {
382
+ state = { count: 0 };
383
+
384
+ increment(by: number) {
385
+ this.state.count += by;
386
+ return this.state.count;
387
+ }
388
+ }
389
+ \\end{lstlisting}
390
+ `,
391
+ 'paper/sections/conclusion.tex': `\\section{Conclusion}
392
+
393
+ Summarize what the paper showed and what comes next.
394
+ `,
395
+ 'paper/references.bib': `@techreport{stonebraker1986,
396
+ author = {Michael Stonebraker and Lawrence A. Rowe},
397
+ title = {The Design of {POSTGRES}},
398
+ institution = {University of California, Berkeley},
399
+ number = {UCB/ERL M85/95},
400
+ year = {1986}
401
+ }
402
+ `,
403
+ '.github/workflows/paper.yml': PAPER_WORKFLOW('paper/main.tex', 'paper'),
404
+ 'README.md': `# Paper
405
+
406
+ \`\`\`bash
407
+ npx latex-kit render paper/main.tex --verify # → out/main.pdf, byte-identical on every build
408
+ \`\`\`
409
+
410
+ The Constructive whitepaper style: \`paper/headers/colors.tex\` (code colours)
411
+ and \`paper/headers/typescript.tex\` (\`style=typescript\` listings), TikZ and
412
+ PSTricks figures, IEEE references. PSTricks builds through latex → dvips →
413
+ ps2pdf, which latex-kit picks by itself.
414
+
415
+ CI builds the PDF on every push and attaches it to the run. Pushing a tag
416
+ like \`v1.0.0\` publishes it as a GitHub release.
417
+ `,
418
+ };
419
+ }
420
+ /** Files for `latex-kit init --paper`. */
421
+ function paperFiles(preset = 'whitepaper') {
422
+ return preset === 'plain' ? plainPaperFiles() : whitepaperFiles();
423
+ }
package/build.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Engine, EngineChoice } from '@latex-kit/render';
2
- import { Diagnostic, Variant } from '@latex-kit/template';
2
+ import { BlankStyle, Diagnostic, Variant } from '@latex-kit/template';
3
3
  import { Project } from './project';
4
4
  export interface BuildOptions {
5
5
  variant?: Variant;
@@ -21,6 +21,15 @@ export interface BuildOptions {
21
21
  platform?: string | null;
22
22
  /** Build twice and fail unless the PDFs are byte-identical. */
23
23
  verify?: boolean;
24
+ /** How blanks print in blank builds: `labelled` (default), `lines` to write on, or `names` in brackets. */
25
+ blanks?: BlankStyle;
26
+ /**
27
+ * Draft builds: print every filled-in value in red, to review what came from
28
+ * the record. Writes `<document>-highlight.pdf`.
29
+ */
30
+ highlight?: boolean;
31
+ /** Draft builds: print a missing value as a red marker (default) or as a blank to fill in. */
32
+ missing?: 'marker' | 'blank';
24
33
  /** Stop after writing the .tex (no TeX run). */
25
34
  texOnly?: boolean;
26
35
  /** Use this ID when the record has none, instead of minting one (for redlines). */
@@ -38,6 +47,8 @@ export interface BuildResult {
38
47
  pdf: string | null;
39
48
  sha256: string | null;
40
49
  docId: string | null;
50
+ /** `<document>.form.json`: where the spots to sign or fill in landed, when the template marks any. */
51
+ form: string | null;
41
52
  /** The ID was minted by this build and written to the record. */
42
53
  minted: boolean;
43
54
  sourceDateEpoch: number;
package/build.js CHANGED
@@ -13,6 +13,7 @@ const crypto_1 = require("crypto");
13
13
  const fs_1 = require("fs");
14
14
  const os_1 = require("os");
15
15
  const path_1 = require("path");
16
+ const form_1 = require("./form");
16
17
  class BuildError extends Error {
17
18
  diagnostics;
18
19
  constructor(message, diagnostics) {
@@ -102,7 +103,8 @@ async function run(job) {
102
103
  snippets.add((0, path_1.resolve)(s.file));
103
104
  return s;
104
105
  };
105
- const strict = options.strict ?? isCI();
106
+ // asking for blanks where values are missing means missing values are expected
107
+ const strict = options.strict ?? (options.missing === 'blank' ? false : isCI());
106
108
  const files = [...job.inputs, template.texFile, ...(template.schemaFile ? [template.schemaFile] : [])];
107
109
  const { epoch, reproducible } = buildEpoch(files);
108
110
  let docId = job.docId;
@@ -112,7 +114,11 @@ async function run(job) {
112
114
  minted = true;
113
115
  }
114
116
  const outDir = options.outDir ?? (0, path_1.join)(project.outDir, job.name);
115
- const job_ = variant === 'final' ? job.name : `${job.name}-${variant}`;
117
+ const blanks = variant === 'blank' ? (options.blanks ?? project.config.blanks) : undefined;
118
+ // the names view is its own file, so it can sit next to the form to fill in
119
+ const highlight = variant === 'draft' && Boolean(options.highlight);
120
+ const missingAs = variant === 'draft' ? options.missing : undefined;
121
+ const job_ = variant === 'final' ? job.name : blanks === 'names' ? `${job.name}-names` : highlight ? `${job.name}-highlight` : `${job.name}-${variant}`;
116
122
  // signed builds: copy signature images next to the .tex for this build only
117
123
  const stageDir = (0, path_1.join)(outDir, 'lk-signatures');
118
124
  const staged = [];
@@ -158,6 +164,7 @@ async function run(job) {
158
164
  docId,
159
165
  template: template.name,
160
166
  allowMissing: variant === 'draft' ? !strict : undefined,
167
+ markValues: highlight,
161
168
  loadSnippet,
162
169
  loadClause: project.loadClause,
163
170
  components: project.components,
@@ -176,7 +183,7 @@ async function run(job) {
176
183
  (0, fs_1.mkdirSync)(outDir, { recursive: true });
177
184
  const texPath = (0, path_1.join)(outDir, `${job_}.tex`);
178
185
  const stamp = `${new Date(finalEpoch.epoch * 1000).toISOString().slice(0, 10)} ${gitShortHead(project.root)}`;
179
- const tex = (0, template_1.wrapDocument)(evaluated.tex, { variant, stamp });
186
+ const tex = (0, template_1.wrapDocument)(evaluated.tex, { variant, stamp, blanks, missing: missingAs });
180
187
  (0, fs_1.writeFileSync)(texPath, tex);
181
188
  (0, fs_1.writeFileSync)((0, path_1.join)(outDir, 'latex-kit.sty'), template_1.LATEX_KIT_STY);
182
189
  const result = {
@@ -193,6 +200,7 @@ async function run(job) {
193
200
  engine: null,
194
201
  engineReason: null,
195
202
  cached: false,
203
+ form: null,
196
204
  diagnostics,
197
205
  };
198
206
  if (options.texOnly)
@@ -234,6 +242,7 @@ async function run(job) {
234
242
  const keyInputs = [...filesUnder(template.dir), ...staged].map((f) => [posixRel(project.root, f), sha256((0, fs_1.readFileSync)(f))]);
235
243
  const cacheKey = sha256(JSON.stringify({ v: 1, tex: sha256(tex), sty: sha256(template_1.LATEX_KIT_STY), engine, backend, image: backend === 'docker' ? (image ?? 'default') : null, platform: platform ?? null, epoch: finalEpoch.epoch, inputs: keyInputs }));
236
244
  const manifestPath = (0, path_1.join)(outDir, `${job_}.manifest.json`);
245
+ const formBase = (0, path_1.join)(outDir, job_);
237
246
  const pdfPath = (0, path_1.join)(outDir, `${job_}.pdf`);
238
247
  if (!options.force && !options.verify && (0, fs_1.existsSync)(manifestPath) && (0, fs_1.existsSync)(pdfPath)) {
239
248
  try {
@@ -243,6 +252,7 @@ async function run(job) {
243
252
  result.pdf = pdfPath;
244
253
  result.sha256 = pdfSha;
245
254
  result.cached = true;
255
+ result.form = (0, fs_1.existsSync)(formBase + '.form.json') ? formBase + '.form.json' : null;
246
256
  return result;
247
257
  }
248
258
  }
@@ -250,6 +260,8 @@ async function run(job) {
250
260
  // an unreadable manifest just means a rebuild
251
261
  }
252
262
  }
263
+ // TeX writes marked spots to <job>.form; a file from an earlier run must not survive
264
+ (0, fs_1.rmSync)(formBase + '.form', { force: true });
253
265
  let rendered;
254
266
  try {
255
267
  rendered = await (0, render_1.render)({ ...renderOpts, outDir: (0, path_1.relative)(project.root, outDir) });
@@ -265,6 +277,7 @@ async function run(job) {
265
277
  }
266
278
  result.pdf = rendered.pdf;
267
279
  result.sha256 = rendered.sha256;
280
+ result.form = (0, form_1.writeFormJson)(formBase);
268
281
  if (options.verify) {
269
282
  // same output path: some tools (Ghostscript) hash the path into the PDF ID
270
283
  const again = await (0, render_1.render)({ ...renderOpts, outDir: (0, path_1.relative)(project.root, outDir) });
package/cli.js CHANGED
@@ -20,8 +20,8 @@ const app = new inquirerer_1.CLI(commands_1.commands, {
20
20
  version: (0, commands_1.version)(),
21
21
  minimistOpts: {
22
22
  alias: { h: 'help', v: 'version', o: 'out', e: 'engine' },
23
- boolean: ['help', 'version', 'local', 'verify', 'json', 'final', 'strict', 'tex-only', 'force', 'schema', 'paper', 'check'],
24
- string: ['out', 'engine', 'image', 'root', 'platform', 'source-date-epoch', 'variant', 'template', 'name', 'against', 'only', 'locale', 'signatures'],
23
+ boolean: ['help', 'version', 'local', 'verify', 'json', 'final', 'strict', 'tex-only', 'force', 'schema', 'paper', 'check', 'highlight'],
24
+ string: ['out', 'engine', 'image', 'root', 'platform', 'source-date-epoch', 'variant', 'template', 'name', 'against', 'only', 'locale', 'signatures', 'preset', 'blanks', 'missing'],
25
25
  default: { strict: undefined, schema: true },
26
26
  },
27
27
  });
package/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Backend, EngineChoice } from '@latex-kit/render';
2
+ import type { BlankStyle } from '@latex-kit/template';
2
3
  /** latex-kit.config.ts (or .js, .mjs, .cjs, .json) at the project root. */
3
4
  export interface LatexKitConfig {
4
5
  /** One folder per template: `<templates>/<name>/template.tex` and optional `schema.ts`. Default `templates`. */
@@ -25,11 +26,17 @@ export interface LatexKitConfig {
25
26
  * override it. A leading ~ is the home folder.
26
27
  */
27
28
  signatures?: string;
29
+ /**
30
+ * How blanks print in blank builds: `labelled` (default, the field's name on
31
+ * a line), `lines` (an empty line to write on) or `names` (the name in
32
+ * brackets). `--blanks` overrides it.
33
+ */
34
+ blanks?: BlankStyle;
28
35
  backend?: Backend;
29
36
  image?: string;
30
37
  platform?: string | null;
31
38
  }
32
- export type ResolvedConfig = Required<Pick<LatexKitConfig, 'templates' | 'snippets' | 'clauses' | 'components' | 'data' | 'documents' | 'out' | 'locale'>> & Pick<LatexKitConfig, 'engine' | 'backend' | 'image' | 'platform' | 'signatures'> & {
39
+ export type ResolvedConfig = Required<Pick<LatexKitConfig, 'templates' | 'snippets' | 'clauses' | 'components' | 'data' | 'documents' | 'out' | 'locale'>> & Pick<LatexKitConfig, 'engine' | 'backend' | 'image' | 'platform' | 'signatures' | 'blanks'> & {
33
40
  file: string | null;
34
41
  };
35
42
  export declare function defineConfig(config: LatexKitConfig): LatexKitConfig;
@@ -3,6 +3,19 @@
3
3
  * and amount is a placeholder.
4
4
  */
5
5
  export type FileMap = Record<string, string>;
6
+ /** Paper presets for `latex-kit init --paper --preset <name>`. */
7
+ export declare const PAPER_PRESETS: readonly ["whitepaper", "plain"];
8
+ export type PaperPreset = (typeof PAPER_PRESETS)[number];
6
9
  export declare function projectFiles(version: string): FileMap;
7
- export declare function paperFiles(): FileMap;
10
+ /** A minimal LuaLaTeX paper: fontspec, natbib. */
11
+ export declare function plainPaperFiles(): FileMap;
8
12
  export declare function templateFiles(name: string): FileMap;
13
+ /**
14
+ * The Constructive whitepaper style (rls-whitepaper, hyperweb-whitepaper):
15
+ * article class, the code colour palette and TypeScript listings style,
16
+ * TikZ and PSTricks, IEEE references. PSTricks means latex → dvips → ps2pdf,
17
+ * which `engine: auto` picks.
18
+ */
19
+ export declare function whitepaperFiles(): FileMap;
20
+ /** Files for `latex-kit init --paper`. */
21
+ export declare function paperFiles(preset?: PaperPreset): FileMap;
@@ -2,6 +2,9 @@
2
2
  * Files written by `latex-kit init` and `latex-kit new`. Every name, address
3
3
  * and amount is a placeholder.
4
4
  */
5
+ import { WHITEPAPER_COLORS_TEX, WHITEPAPER_TYPESCRIPT_TEX } from './paper-style';
6
+ /** Paper presets for `latex-kit init --paper --preset <name>`. */
7
+ export const PAPER_PRESETS = ['whitepaper', 'plain'];
5
8
  export function projectFiles(version) {
6
9
  return {
7
10
  'package.json': `${JSON.stringify({
@@ -124,7 +127,8 @@ data:
124
127
  `,
125
128
  };
126
129
  }
127
- export function paperFiles() {
130
+ /** A minimal LuaLaTeX paper: fontspec, natbib. */
131
+ export function plainPaperFiles() {
128
132
  return {
129
133
  '.gitignore': 'out/\n',
130
134
  'paper/main.tex': `\\documentclass[11pt]{article}
@@ -218,3 +222,194 @@ export default z.object({
218
222
  `,
219
223
  };
220
224
  }
225
+ const PAPER_WORKFLOW = (file, name) => `name: Paper
226
+
227
+ on:
228
+ push:
229
+ branches: [main]
230
+ tags: ['v*']
231
+ pull_request:
232
+
233
+ jobs:
234
+ pdf:
235
+ runs-on: ubuntu-latest
236
+ permissions:
237
+ contents: read
238
+ steps:
239
+ - uses: actions/checkout@v4
240
+ with:
241
+ fetch-depth: 0 # the build date comes from the last commit
242
+ - uses: constructive-io/latex-kit/action@v1
243
+ with:
244
+ file: ${file}
245
+ engine: auto
246
+ verify: 'true'
247
+ artifact-name: ${name}.pdf
248
+
249
+ # pushing a tag like v1.0.0 attaches the PDF to a GitHub release
250
+ release:
251
+ needs: pdf
252
+ if: startsWith(github.ref, 'refs/tags/v')
253
+ runs-on: ubuntu-latest
254
+ permissions:
255
+ contents: write
256
+ steps:
257
+ - uses: actions/download-artifact@v4
258
+ with:
259
+ name: ${name}.pdf
260
+ path: pdf
261
+ - env:
262
+ GH_TOKEN: \${{ github.token }}
263
+ run: |
264
+ pdf=$(find pdf -name '*.pdf' | head -n 1)
265
+ cp "$pdf" "${name}-$GITHUB_REF_NAME.pdf"
266
+ gh release create "$GITHUB_REF_NAME" "${name}-$GITHUB_REF_NAME.pdf" -R "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --generate-notes
267
+ `;
268
+ /**
269
+ * The Constructive whitepaper style (rls-whitepaper, hyperweb-whitepaper):
270
+ * article class, the code colour palette and TypeScript listings style,
271
+ * TikZ and PSTricks, IEEE references. PSTricks means latex → dvips → ps2pdf,
272
+ * which `engine: auto` picks.
273
+ */
274
+ export function whitepaperFiles() {
275
+ return {
276
+ '.gitignore': 'out/\n',
277
+ 'paper/main.tex': `% A paper in the Constructive whitepaper style (as rls-whitepaper and
278
+ % hyperweb-whitepaper). It loads PSTricks, so latex-kit builds it with
279
+ % latex -> bibtex -> dvips -> ps2pdf; \`latex-kit render paper/main.tex\` picks that.
280
+ \\documentclass{article}
281
+ \\usepackage{amsmath}
282
+ \\usepackage{graphicx}
283
+ \\usepackage{xcolor}
284
+ \\usepackage{listings}
285
+ \\usepackage{geometry}
286
+ \\usepackage{enumitem}
287
+ \\usepackage{amsfonts}
288
+ \\usepackage{amssymb}
289
+ \\usepackage[hidelinks]{hyperref}
290
+ \\usepackage{cleveref}
291
+
292
+ \\usepackage{pstricks}
293
+ \\usepackage{tikz}
294
+ \\usetikzlibrary{arrows.meta, positioning, shapes, calc}
295
+
296
+ \\input{headers/colors.tex}
297
+ \\input{headers/typescript.tex}
298
+
299
+ \\title{Paper Title: What the Paper Shows}
300
+ \\author{Your Name, A. Co-Author
301
+ \\\\ \\\\
302
+ \\texttt{info@example.com}}
303
+ \\date{v0.0.1 --- \\today}
304
+
305
+ \\begin{document}
306
+
307
+ \\maketitle
308
+
309
+ \\begin{abstract}
310
+ One paragraph: the problem, why existing approaches fall short, what this
311
+ paper presents, and what it achieves.
312
+ \\end{abstract}
313
+
314
+ \\tableofcontents
315
+
316
+ \\input{sections/introduction.tex}
317
+ \\input{sections/design.tex}
318
+ \\input{sections/conclusion.tex}
319
+
320
+ \\newpage
321
+
322
+ \\section{Bibliography}
323
+ \\bibliographystyle{IEEEtran}
324
+ \\bibliography{references}
325
+
326
+ \\end{document}
327
+ `,
328
+ 'paper/headers/colors.tex': WHITEPAPER_COLORS_TEX,
329
+ 'paper/headers/typescript.tex': WHITEPAPER_TYPESCRIPT_TEX,
330
+ 'paper/sections/introduction.tex': `\\section{Introduction}
331
+
332
+ State the problem and why it matters. Cite prior work like this~\\cite{stonebraker1986}.
333
+ \\Cref{fig:flow} is drawn with PSTricks.
334
+
335
+ \\begin{figure}[ht]
336
+ \\centering
337
+ \\begin{pspicture}(0,0)(9,3)
338
+ \\psframe[fillstyle=solid,fillcolor=lightpurple,framearc=0.2](0,0.75)(3,2.25)
339
+ \\rput(1.5,1.5){Client}
340
+ \\psline[linewidth=1pt]{->}(3,1.5)(6,1.5)
341
+ \\rput(4.5,1.85){\\small request}
342
+ \\pscircle[fillstyle=solid,fillcolor=codelightgreen](7.5,1.5){1.2}
343
+ \\rput(7.5,1.5){Server}
344
+ \\end{pspicture}
345
+ \\caption{A request flow, drawn with PSTricks.}
346
+ \\label{fig:flow}
347
+ \\end{figure}
348
+ `,
349
+ 'paper/sections/design.tex': `\\section{Design}
350
+
351
+ \\Cref{fig:layers} is drawn with TikZ, and \\cref{lst:counter} uses the
352
+ TypeScript listing style.
353
+
354
+ \\begin{figure}[ht]
355
+ \\centering
356
+ \\begin{tikzpicture}[
357
+ node distance=1.2cm,
358
+ box/.style={rectangle, draw, rounded corners, fill=blue!10, text width=2.8cm, text centered, minimum height=0.9cm},
359
+ store/.style={rectangle, draw, rounded corners, fill=orange!10, text width=2.8cm, text centered, minimum height=0.9cm},
360
+ arrow/.style={-{Stealth}, thick}
361
+ ]
362
+ \\node[box] (api) {API};
363
+ \\node[box, below=of api] (policy) {Policy check};
364
+ \\node[store, right=1.6cm of policy] (data) {Data};
365
+ \\draw[arrow] (api) -- (policy);
366
+ \\draw[arrow] (policy) -- node[above] {\\small allowed} (data);
367
+ \\end{tikzpicture}
368
+ \\caption{Layers, drawn with TikZ.}
369
+ \\label{fig:layers}
370
+ \\end{figure}
371
+
372
+ \\begin{lstlisting}[language=typescript, caption=A small contract, label=lst:counter, style=typescript]
373
+ export default class Counter {
374
+ state = { count: 0 };
375
+
376
+ increment(by: number) {
377
+ this.state.count += by;
378
+ return this.state.count;
379
+ }
380
+ }
381
+ \\end{lstlisting}
382
+ `,
383
+ 'paper/sections/conclusion.tex': `\\section{Conclusion}
384
+
385
+ Summarize what the paper showed and what comes next.
386
+ `,
387
+ 'paper/references.bib': `@techreport{stonebraker1986,
388
+ author = {Michael Stonebraker and Lawrence A. Rowe},
389
+ title = {The Design of {POSTGRES}},
390
+ institution = {University of California, Berkeley},
391
+ number = {UCB/ERL M85/95},
392
+ year = {1986}
393
+ }
394
+ `,
395
+ '.github/workflows/paper.yml': PAPER_WORKFLOW('paper/main.tex', 'paper'),
396
+ 'README.md': `# Paper
397
+
398
+ \`\`\`bash
399
+ npx latex-kit render paper/main.tex --verify # → out/main.pdf, byte-identical on every build
400
+ \`\`\`
401
+
402
+ The Constructive whitepaper style: \`paper/headers/colors.tex\` (code colours)
403
+ and \`paper/headers/typescript.tex\` (\`style=typescript\` listings), TikZ and
404
+ PSTricks figures, IEEE references. PSTricks builds through latex → dvips →
405
+ ps2pdf, which latex-kit picks by itself.
406
+
407
+ CI builds the PDF on every push and attaches it to the run. Pushing a tag
408
+ like \`v1.0.0\` publishes it as a GitHub release.
409
+ `,
410
+ };
411
+ }
412
+ /** Files for `latex-kit init --paper`. */
413
+ export function paperFiles(preset = 'whitepaper') {
414
+ return preset === 'plain' ? plainPaperFiles() : whitepaperFiles();
415
+ }
package/esm/build.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Engine, EngineChoice } from '@latex-kit/render';
2
- import { Diagnostic, Variant } from '@latex-kit/template';
2
+ import { BlankStyle, Diagnostic, Variant } from '@latex-kit/template';
3
3
  import { Project } from './project';
4
4
  export interface BuildOptions {
5
5
  variant?: Variant;
@@ -21,6 +21,15 @@ export interface BuildOptions {
21
21
  platform?: string | null;
22
22
  /** Build twice and fail unless the PDFs are byte-identical. */
23
23
  verify?: boolean;
24
+ /** How blanks print in blank builds: `labelled` (default), `lines` to write on, or `names` in brackets. */
25
+ blanks?: BlankStyle;
26
+ /**
27
+ * Draft builds: print every filled-in value in red, to review what came from
28
+ * the record. Writes `<document>-highlight.pdf`.
29
+ */
30
+ highlight?: boolean;
31
+ /** Draft builds: print a missing value as a red marker (default) or as a blank to fill in. */
32
+ missing?: 'marker' | 'blank';
24
33
  /** Stop after writing the .tex (no TeX run). */
25
34
  texOnly?: boolean;
26
35
  /** Use this ID when the record has none, instead of minting one (for redlines). */
@@ -38,6 +47,8 @@ export interface BuildResult {
38
47
  pdf: string | null;
39
48
  sha256: string | null;
40
49
  docId: string | null;
50
+ /** `<document>.form.json`: where the spots to sign or fill in landed, when the template marks any. */
51
+ form: string | null;
41
52
  /** The ID was minted by this build and written to the record. */
42
53
  minted: boolean;
43
54
  sourceDateEpoch: number;