paperlint 18.0.0 → 18.2.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.
Files changed (130) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/hotcrp/index.d.ts +11 -1
  3. package/dist/adapters/hotcrp/index.d.ts.map +1 -1
  4. package/dist/adapters/hotcrp/index.js +11 -1
  5. package/dist/adapters/hotcrp/index.js.map +1 -1
  6. package/dist/adapters/hotcrp/site.d.ts.map +1 -1
  7. package/dist/adapters/hotcrp/site.js +3 -1
  8. package/dist/adapters/hotcrp/site.js.map +1 -1
  9. package/dist/adapters/hotcrp/token.d.ts +11 -0
  10. package/dist/adapters/hotcrp/token.d.ts.map +1 -1
  11. package/dist/adapters/hotcrp/token.js +34 -7
  12. package/dist/adapters/hotcrp/token.js.map +1 -1
  13. package/dist/adapters/latex/document-class.d.ts +28 -5
  14. package/dist/adapters/latex/document-class.d.ts.map +1 -1
  15. package/dist/adapters/latex/document-class.js +208 -21
  16. package/dist/adapters/latex/document-class.js.map +1 -1
  17. package/dist/adapters/latex/index.d.ts +4 -4
  18. package/dist/adapters/latex/index.d.ts.map +1 -1
  19. package/dist/adapters/latex/index.js +5 -2
  20. package/dist/adapters/latex/index.js.map +1 -1
  21. package/dist/adapters/latex/parse.d.ts.map +1 -1
  22. package/dist/adapters/latex/parse.js +5 -0
  23. package/dist/adapters/latex/parse.js.map +1 -1
  24. package/dist/cli.d.ts.map +1 -1
  25. package/dist/cli.js +4 -3
  26. package/dist/cli.js.map +1 -1
  27. package/dist/domain/body-pages.d.ts.map +1 -1
  28. package/dist/domain/body-pages.js +4 -2
  29. package/dist/domain/body-pages.js.map +1 -1
  30. package/dist/domain/portal-token.d.ts +26 -10
  31. package/dist/domain/portal-token.d.ts.map +1 -1
  32. package/dist/domain/portal-token.js +19 -12
  33. package/dist/domain/portal-token.js.map +1 -1
  34. package/dist/domain/tex-document.d.ts +52 -4
  35. package/dist/domain/tex-document.d.ts.map +1 -1
  36. package/dist/domain/tex-document.js +9 -0
  37. package/dist/domain/tex-document.js.map +1 -1
  38. package/dist/eslint-rules/latex-language.d.ts +10 -0
  39. package/dist/eslint-rules/latex-language.d.ts.map +1 -1
  40. package/dist/eslint-rules/latex-language.js +41 -2
  41. package/dist/eslint-rules/latex-language.js.map +1 -1
  42. package/dist/ports/latex.d.ts +13 -1
  43. package/dist/ports/latex.d.ts.map +1 -1
  44. package/dist/ports/submission-portal.d.ts +7 -0
  45. package/dist/ports/submission-portal.d.ts.map +1 -1
  46. package/dist/presets.d.ts +15 -0
  47. package/dist/presets.d.ts.map +1 -1
  48. package/dist/presets.js +9 -0
  49. package/dist/presets.js.map +1 -1
  50. package/dist/submission.d.ts +3 -2
  51. package/dist/submission.d.ts.map +1 -1
  52. package/dist/submission.js +24 -12
  53. package/dist/submission.js.map +1 -1
  54. package/dist/tex-requirements.d.ts +2 -0
  55. package/dist/tex-requirements.d.ts.map +1 -1
  56. package/dist/tex-requirements.js +7 -2
  57. package/dist/tex-requirements.js.map +1 -1
  58. package/dist/tex-venue-rules.d.ts +36 -3
  59. package/dist/tex-venue-rules.d.ts.map +1 -1
  60. package/dist/tex-venue-rules.js +181 -33
  61. package/dist/tex-venue-rules.js.map +1 -1
  62. package/docs/rules/cycle/port-done.md +3 -0
  63. package/docs/rules/tex/template.md +96 -1
  64. package/docs/rules.md +18 -13
  65. package/docs/submission.md +26 -9
  66. package/docs/venues.md +51 -12
  67. package/eslint-rules/latex-language.test.mjs +64 -1
  68. package/eslint-rules/latex-language.ts +44 -2
  69. package/eslint.config.mjs +1 -0
  70. package/fixtures/build-e2e/neurips/PIPELINE-STATUS.md +3 -0
  71. package/fixtures/build-e2e/neurips/expect.json +20 -0
  72. package/fixtures/build-e2e/neurips/paper.tex +60 -0
  73. package/fixtures/build-e2e/neurips/paperlint.json +1 -0
  74. package/fixtures/build-e2e/neurips-nostyle/PIPELINE-STATUS.md +3 -0
  75. package/fixtures/build-e2e/neurips-nostyle/expect.json +26 -0
  76. package/fixtures/build-e2e/neurips-nostyle/paper.tex +56 -0
  77. package/fixtures/build-e2e/neurips-nostyle/paperlint.json +1 -0
  78. package/fixtures/build-e2e/neurips-over/PIPELINE-STATUS.md +3 -0
  79. package/fixtures/build-e2e/neurips-over/expect.json +24 -0
  80. package/fixtures/build-e2e/neurips-over/paper.tex +56 -0
  81. package/fixtures/build-e2e/neurips-over/paperlint.json +1 -0
  82. package/fixtures/real-papers.test.ts +17 -6
  83. package/package.json +3 -1
  84. package/presets/aaai-2027.jsonc +126 -0
  85. package/presets/aaai-2027.md +127 -0
  86. package/presets/aaai-press.jsonc +167 -0
  87. package/presets/aaai-press.md +126 -0
  88. package/presets/icml-2027.jsonc +111 -0
  89. package/presets/icml-2027.md +130 -0
  90. package/presets/icml-style.jsonc +125 -0
  91. package/presets/icml-style.md +77 -0
  92. package/presets/neurips-2026.jsonc +123 -0
  93. package/presets/neurips-2026.md +137 -0
  94. package/presets/neurips-style.jsonc +113 -0
  95. package/presets/neurips-style.md +85 -0
  96. package/presets/venue-profile.schema.json +6 -0
  97. package/skills/build-label-page/scripts/label-page-browser.test.ts +275 -114
  98. package/src/adapters/hotcrp/cassette/README.md +1 -1
  99. package/src/adapters/hotcrp/index.ts +12 -0
  100. package/src/adapters/hotcrp/site.ts +4 -0
  101. package/src/adapters/hotcrp/token.test.ts +39 -1
  102. package/src/adapters/hotcrp/token.ts +40 -7
  103. package/src/adapters/latex/document-class.ts +292 -20
  104. package/src/adapters/latex/index.test.ts +263 -0
  105. package/src/adapters/latex/index.ts +12 -3
  106. package/src/adapters/latex/parse.ts +5 -0
  107. package/src/cli.test.ts +6 -1
  108. package/src/cli.ts +4 -3
  109. package/src/domain/body-pages.test.ts +22 -6
  110. package/src/domain/body-pages.ts +4 -2
  111. package/src/domain/portal-token.test.ts +121 -2
  112. package/src/domain/portal-token.ts +39 -15
  113. package/src/domain/tex-document.ts +64 -5
  114. package/src/folder-venue-rule.test.ts +51 -0
  115. package/src/new-paper.test.ts +2 -2
  116. package/src/paper-settings-commands.test.ts +1 -1
  117. package/src/ports/latex.ts +14 -0
  118. package/src/ports/submission-portal.ts +7 -0
  119. package/src/preset-card-rule.test.ts +44 -27
  120. package/src/presets.test.ts +177 -1
  121. package/src/presets.ts +27 -0
  122. package/src/rule-cases.test.ts +52 -0
  123. package/src/submission-show.test.ts +1 -1
  124. package/src/submission.test.ts +98 -7
  125. package/src/submission.ts +28 -11
  126. package/src/tex-requirements.harness.ts +17 -3
  127. package/src/tex-requirements.ts +13 -2
  128. package/src/tex-venue-rules.test.ts +1020 -0
  129. package/src/tex-venue-rules.ts +248 -38
  130. package/src/venue-rules.test.ts +369 -2
@@ -25,7 +25,10 @@ import {
25
25
  optional,
26
26
  outlineOf,
27
27
  parseLatex,
28
+ packagesOf,
29
+ packagesUnseen,
28
30
  parseTemplate,
31
+ parseTemplateStyle,
29
32
  placeOf,
30
33
  renderedRuns,
31
34
  replaceDocumentClass,
@@ -41,6 +44,8 @@ describe("documentClassOf — the class line's three states", () => {
41
44
  kind: "class",
42
45
  cls: "IEEEtran",
43
46
  options: ["conference", "compsoc"],
47
+ unread: [],
48
+ passed: [],
44
49
  place: {
45
50
  kind: "at",
46
51
  span: { start: 4, end: src.indexOf("}") + 1 },
@@ -77,6 +82,81 @@ describe("documentClassOf — the class line's three states", () => {
77
82
  });
78
83
  });
79
84
 
85
+ describe("documentClassOf — options passed before the line, and what a macro builds", () => {
86
+ it("🔴 `\\PassOptionsToClass` before the line, for its class: each option as written, with its place", () => {
87
+ const src =
88
+ "\\PassOptionsToClass{compsoc}{IEEEtran}\n\\PassOptionsToClass{x}{article}\n\\documentclass[conference]{IEEEtran}\n\\PassOptionsToClass{late}{IEEEtran}";
89
+ expect(documentClassOf(parseLatex(src))).toEqual({
90
+ kind: "class",
91
+ cls: "IEEEtran",
92
+ options: ["conference"],
93
+ unread: [],
94
+ passed: [
95
+ {
96
+ options: ["compsoc"],
97
+ unread: [],
98
+ place: { kind: "at", span: { start: 0, end: 38 } },
99
+ },
100
+ ],
101
+ place: {
102
+ kind: "at",
103
+ span: {
104
+ start: src.indexOf("\\documentclass"),
105
+ end: src.indexOf("}\n\\PassOptionsToClass{late}") + 1,
106
+ },
107
+ },
108
+ });
109
+ });
110
+
111
+ it("an option built by a macro is unread, in the line and in a passed list; braces do not hide one", () => {
112
+ const src =
113
+ "\\PassOptionsToClass{\\more}{IEEEtran}\\documentclass[\\opts, a, b={\\c}]{IEEEtran}";
114
+ const line = documentClassOf(parseLatex(src));
115
+ expect(
116
+ line.kind === "class" && [
117
+ line.options,
118
+ line.unread,
119
+ line.passed.map((p) => p.unread),
120
+ ],
121
+ ).toEqual([
122
+ ["\\opts", "a", "b={\\c}"],
123
+ ["\\opts", "b={\\c}"],
124
+ [["\\more"]],
125
+ ]);
126
+ });
127
+ });
128
+
129
+ describe("documentClassOf — a line with a part missing, a class from a macro, a class out of reach", () => {
130
+ it("a \\PassOptionsToClass missing an argument passes nothing; a \\documentclass with no name is empty", () => {
131
+ const line = (src: string) => documentClassOf(parseLatex(src));
132
+ // At the end of the file: before a line, the parser would take the line as its argument.
133
+ for (const pass of ["\\PassOptionsToClass", "\\PassOptionsToClass{a}"]) {
134
+ const l = line(`\\documentclass{IEEEtran}\n${pass}`);
135
+ expect(l.kind === "class" && l.passed).toEqual([]);
136
+ }
137
+ expect(line("\\documentclass[a]").kind).toBe("empty");
138
+ });
139
+
140
+ it("🔴 a class name built by a macro is unread, not empty", () => {
141
+ expect(documentClassOf(parseLatex("\\documentclass[a]{\\cls}")).kind).toBe(
142
+ "unread",
143
+ );
144
+ });
145
+
146
+ it("🔴 unseen: no class line at the top, and one inside another macro, or an \\input in the preamble", () => {
147
+ const kind = (src: string) => documentClassOf(parseLatex(src)).kind;
148
+ expect(kind("{\\documentclass{article}}")).toBe("unseen");
149
+ expect(kind("\\input{preamble}\n\\begin{document}\\end{document}")).toBe(
150
+ "unseen",
151
+ );
152
+ expect(kind("\\input{preamble}")).toBe("unseen");
153
+ // The other half: an \input in the body does not stand where a class line goes.
154
+ expect(kind("\\begin{document}\\input{intro}\\end{document}")).toBe(
155
+ "missing",
156
+ );
157
+ });
158
+ });
159
+
80
160
  describe("placeOf / macroPlace — a node the parser gave no position is unplaced, never offset 0", () => {
81
161
  const at = (start: number, end: number) => ({
82
162
  start: { offset: start, line: 1, column: start + 1 },
@@ -152,6 +232,173 @@ describe("parseTemplate — a preset's template", () => {
152
232
  });
153
233
  });
154
234
 
235
+ describe("parseTemplateStyle — a preset's template_style", () => {
236
+ it.each<[string, { name: string; options: string[] } | null]>([
237
+ ["\\usepackage{neurips_2026}", { name: "neurips_2026", options: [] }],
238
+ [
239
+ "% c\n\\usepackage[ main , final ]{neurips_2026}\n",
240
+ { name: "neurips_2026", options: ["main", "final"] },
241
+ ],
242
+ ["\\RequirePackage{icml2027}", { name: "icml2027", options: [] }],
243
+ ["\\usepackage{a,b}", null],
244
+ ["\\usepackage{}", null],
245
+ ["\\usepackage{a} \\usepackage{b}", null],
246
+ ["\\documentclass{article}", null],
247
+ ["neurips_2026", null],
248
+ ["", null],
249
+ ])("%j → %j", (text, want) => {
250
+ expect(parseTemplateStyle(text)).toEqual(want);
251
+ });
252
+ });
253
+
254
+ describe("packagesOf — options passed to a package before it is loaded (`\\PassOptionsToPackage`)", () => {
255
+ const optionsOf = (src: string) =>
256
+ packagesOf(parseLatex(src)).map((p) => [p.name, p.options]);
257
+
258
+ it("🔴 options passed before the load are in effect, to each package of a comma list", () => {
259
+ expect(
260
+ optionsOf(
261
+ "\\documentclass{article}\n\\PassOptionsToPackage{submission, x}{other, aaai2027}\n\\usepackage[y]{aaai2027}\n\\usepackage{other}\n",
262
+ ),
263
+ ).toEqual([
264
+ ["aaai2027", ["submission", "x", "y"]],
265
+ ["other", ["submission", "x"]],
266
+ ]);
267
+ });
268
+
269
+ it("options passed after the load, or to another package, are not", () => {
270
+ expect(
271
+ optionsOf(
272
+ "\\documentclass{article}\n\\PassOptionsToPackage{a}{other}\n\\usepackage{aaai2027}\n\\PassOptionsToPackage{submission}{aaai2027}\n\\PassOptionsToPackage{b}\n",
273
+ ),
274
+ ).toEqual([["aaai2027", []]]);
275
+ });
276
+ });
277
+
278
+ describe("packagesOf — only what TeX reads: nothing after \\end{document}", () => {
279
+ const doc =
280
+ "\\documentclass{article}\n\\usepackage{a}\n\\begin{document}\nx\n\\end{document}\n";
281
+
282
+ it("🔴 a load and a \\PassOptionsToPackage parked after it are not read", () => {
283
+ const src = `${doc}\\PassOptionsToPackage{o}{a}\n\\usepackage[p]{b}\n`;
284
+ expect(packagesOf(parseLatex(src)).map((p) => [p.name, p.options])).toEqual(
285
+ [["a", []]],
286
+ );
287
+ });
288
+
289
+ it("🔴 a load inside a macro after it hides nothing; one in the preamble's macro still does", () => {
290
+ const after = "\\newcommand{\\x}{\\usepackage{c}}\n";
291
+ expect(packagesUnseen(parseLatex(`${doc}${after}`))).toBe(false);
292
+ expect(packagesUnseen(parseLatex(`${after}${doc}`))).toBe(true);
293
+ });
294
+ });
295
+
296
+ describe("packagesOf — the options LaTeX hands a package: global, passed, its own (latex.ltx)", () => {
297
+ const loads = (src: string) =>
298
+ packagesOf(parseLatex(src)).map((p) => [p.name, p.options, p.unread]);
299
+
300
+ it("🔴 the class line's options are global: every package after it gets them, before its own", () => {
301
+ expect(
302
+ loads(
303
+ "\\documentclass[letterpaper, submission]{article}\n\\PassOptionsToPackage{x}{aaai2027}\n\\usepackage[y]{aaai2027}\n",
304
+ ),
305
+ ).toEqual([["aaai2027", ["letterpaper", "submission", "x", "y"], []]]);
306
+ });
307
+
308
+ it("options passed to the class with \\PassOptionsToClass are the class's alone, not global", () => {
309
+ expect(
310
+ loads(
311
+ "\\PassOptionsToClass{submission}{article}\n\\documentclass[letterpaper]{article}\n\\usepackage{aaai2027}\n",
312
+ ),
313
+ ).toEqual([["aaai2027", ["letterpaper"], []]]);
314
+ });
315
+
316
+ it("🔴 \\RequirePackageWithOptions loads the package with the global options, and what was passed to it is replaced", () => {
317
+ expect(
318
+ loads(
319
+ "\\documentclass[submission]{article}\n\\PassOptionsToPackage{x}{aaai2027}\n\\RequirePackageWithOptions{aaai2027}\n",
320
+ ),
321
+ ).toEqual([["aaai2027", ["submission"], []]]);
322
+ });
323
+
324
+ it("🔴 an option built by a macro, on the class line, passed, or on the load, is unread", () => {
325
+ expect(
326
+ loads(
327
+ "\\documentclass[\\cls]{article}\n\\PassOptionsToPackage{\\pass}{aaai2027}\n\\usepackage[\\own, y]{aaai2027}\n",
328
+ ),
329
+ ).toEqual([
330
+ [
331
+ "aaai2027",
332
+ ["\\cls", "\\pass", "\\own", "y"],
333
+ ["\\cls", "\\pass", "\\own"],
334
+ ],
335
+ ]);
336
+ });
337
+ });
338
+
339
+ describe("packagesUnseen — a preamble that may load what the reader does not see", () => {
340
+ const unseen = (preamble: string, body = "Text.") =>
341
+ packagesUnseen(
342
+ parseLatex(
343
+ `\\documentclass{article}\n${preamble}\n\\begin{document}\n${body}\n\\end{document}\n`,
344
+ ),
345
+ );
346
+
347
+ it("🔴 an \\input in the preamble, a package line inside a macro, a name a macro builds", () => {
348
+ expect(unseen("\\input{preamble}")).toBe(true);
349
+ expect(unseen("\\newcommand{\\load}{\\usepackage{x}}\n\\load")).toBe(true);
350
+ expect(unseen("\\usepackage{\\style}")).toBe(true);
351
+ });
352
+
353
+ it("🔴 options passed where the reader does not see them: inside a macro, or to a package a macro names", () => {
354
+ expect(
355
+ unseen("\\newcommand{\\opts}{\\PassOptionsToPackage{final}{x}}\n\\opts"),
356
+ ).toBe(true);
357
+ expect(unseen("\\PassOptionsToPackage{final}{\\style}")).toBe(true);
358
+ });
359
+
360
+ it("🔴 a file read through a loader the include reader does not follow, or a line built by \\csname", () => {
361
+ expect(unseen("\\InputIfFileExists{setup.tex}{}{}")).toBe(true);
362
+ expect(unseen("\\import{sections/}{preamble}")).toBe(true);
363
+ expect(unseen("\\csname usepackage\\endcsname{x}")).toBe(true);
364
+ expect(unseen("\\usepackage{x}", "\\import{sections/}{intro}")).toBe(false);
365
+ });
366
+
367
+ it("the whole preamble in view: plain lines and an \\input in the body; a bare \\usepackage hides nothing", () => {
368
+ expect(unseen("\\usepackage[a]{x,y}", "\\input{intro}")).toBe(false);
369
+ expect(packagesUnseen(parseLatex("\\usepackage"))).toBe(false);
370
+ expect(unseen("\\PassOptionsToPackage{\\opt}{x}\n\\usepackage{x}")).toBe(
371
+ false,
372
+ );
373
+ });
374
+ });
375
+
376
+ describe("packagesOf — the packages the preamble loads", () => {
377
+ it("a \\usepackage with no argument loads nothing", () => {
378
+ expect(
379
+ packagesOf(parseLatex("\\documentclass{article}\n\\usepackage\n")),
380
+ ).toEqual([]);
381
+ });
382
+
383
+ it("each package of each line, with the line's options and place; a comment loads nothing", () => {
384
+ const src =
385
+ "\\documentclass{article}\n% \\usepackage{x}\n\\usepackage[a, b]{p,q}\n\\RequirePackage{r}\n";
386
+ expect(
387
+ packagesOf(parseLatex(src)).map((p) => [
388
+ p.name,
389
+ p.options,
390
+ p.place.kind === "at"
391
+ ? src.slice(p.place.span.start, p.place.span.end)
392
+ : "",
393
+ ]),
394
+ ).toEqual([
395
+ ["p", ["a", "b"], "\\usepackage[a, b]{p,q}"],
396
+ ["q", ["a", "b"], "\\usepackage[a, b]{p,q}"],
397
+ ["r", [], "\\RequirePackage{r}"],
398
+ ]);
399
+ });
400
+ });
401
+
155
402
  const replaced = (src: string) => replaceDocumentClass(parseLatex(src), IEEE);
156
403
 
157
404
  describe("replaceDocumentClass — the class `paperlint new` writes", () => {
@@ -189,6 +436,22 @@ describe("replaceDocumentClass — the class `paperlint new` writes", () => {
189
436
  expect(replaced("\\documentclass{}\nx")).toBe("\\documentclass{}\nx");
190
437
  });
191
438
 
439
+ it("🔴 an option passed with \\PassOptionsToClass is not added again; only the one still missing is", () => {
440
+ expect(
441
+ replaced(
442
+ "\\PassOptionsToClass{compsoc}{IEEEtran}\n\\documentclass{IEEEtran}",
443
+ ),
444
+ ).toBe(
445
+ "\\PassOptionsToClass{compsoc}{IEEEtran}\n\\documentclass[conference]{IEEEtran}",
446
+ );
447
+ });
448
+
449
+ it("🔴 a line built by a macro is returned as it is: what it lacks is not known", () => {
450
+ const opts = "\\documentclass[\\opts]{IEEEtran}";
451
+ expect(replaced(opts)).toBe(opts);
452
+ expect(replaced("\\documentclass{\\cls}")).toBe("\\documentclass{\\cls}");
453
+ });
454
+
192
455
  it("the port does the same over a source", () => {
193
456
  expect(
194
457
  latexReader.withDocumentClass("\\documentclass{article}", IEEE),
@@ -15,16 +15,19 @@
15
15
  * the parser the language already uses.
16
16
  *
17
17
  * ── STATES, NOT NULL ─────────────────────────────────────────────────────────────
18
- * A class line is missing, empty or a class; a node the parser gave no position is `unplaced`, not
19
- * offset 0; a run of text is a non-empty list of contiguous segments, and a range outside it has
20
- * no span (`spanIn` in `src/domain/tex-document.ts`). A tree travels only with its own source
18
+ * A class line is missing, unseen, empty, unread or a class; a node the parser gave no position is
19
+ * `unplaced`, not offset 0; a run of text is a non-empty list of contiguous segments, and a range
20
+ * outside it has no span (`spanIn` in `src/domain/tex-document.ts`). A tree travels only with its own source
21
21
  * (`ParsedTex`, minted by `parseLatex` alone).
22
22
  */
23
23
  import type { LatexReader } from "../../ports/latex.ts";
24
24
  import { abstractSpan, abstractText } from "./abstract.ts";
25
25
  import {
26
26
  documentClassOf,
27
+ packagesOf,
28
+ packagesUnseen,
27
29
  parseTemplate,
30
+ parseTemplateStyle,
28
31
  replaceDocumentClass,
29
32
  } from "./document-class.ts";
30
33
  import { citeKeysOf, macroTextsOf, registeredNumbersOf } from "./facts.ts";
@@ -41,7 +44,10 @@ import { filecontentsOf } from "./filecontents.ts";
41
44
 
42
45
  export {
43
46
  documentClassOf,
47
+ packagesOf,
48
+ packagesUnseen,
44
49
  parseTemplate,
50
+ parseTemplateStyle,
45
51
  replaceDocumentClass,
46
52
  } from "./document-class.ts";
47
53
  export {
@@ -76,6 +82,9 @@ export const latexReader: LatexReader = {
76
82
  includes: (src) => includesOf(parseLatex(src)),
77
83
  documentBody: (src) => documentBodyOf(parseLatex(src)),
78
84
  template: parseTemplate,
85
+ packages: (src) => packagesOf(parseLatex(src)),
86
+ packagesUnseen: (src) => packagesUnseen(parseLatex(src)),
87
+ templateStyle: parseTemplateStyle,
79
88
  withDocumentClass: (src, want) => replaceDocumentClass(parseLatex(src), want),
80
89
  layoutOverrides: (src) => layoutOverridesOf(parseLatex(src)),
81
90
  filecontents: (src, jobname) => filecontentsOf(parseLatex(src), jobname),
@@ -107,6 +107,11 @@ export const KEY_SIGNATURES: Readonly<
107
107
  ...signed(["nobibliography"], "m"),
108
108
  ...signed(["includegraphics"], "s o o m"),
109
109
  ...signed(["usepackage", "RequirePackage", "documentclass"], "o m o"),
110
+ // Options for a class, given before its `\documentclass`: `tex/template` reads them as the line's.
111
+ // The same for a package, before its `\usepackage`.
112
+ ...signed(["PassOptionsToClass", "PassOptionsToPackage"], "m m"),
113
+ // A package given the options of the file that loads it: `\RequirePackageWithOptions{pkg}[date]`.
114
+ ...signed(["RequirePackageWithOptions"], "m o"),
110
115
  ]);
111
116
 
112
117
  /**
package/src/cli.test.ts CHANGED
@@ -34,7 +34,11 @@ import { texInputsDir } from "./package-dirs.ts";
34
34
 
35
35
  const root = useTempDir("cli-test-");
36
36
 
37
- /** `run(argv)` from `cwd`, the output as one string per stream. */
37
+ /**
38
+ * `run(argv)` from `cwd`, the output as one string per stream. Its clock stands still, so `lint`'s
39
+ * «linted N file(s) in 0.0 s» is the same however long the run took: under a loaded
40
+ * `npm run test:changed` two lints of one tree printed 0.2 s and 0.0 s.
41
+ */
38
42
  async function cli(
39
43
  argv: string[],
40
44
  cwd: string,
@@ -46,6 +50,7 @@ async function cli(
46
50
  log: (...a: unknown[]) => out.push(a.join(" ")),
47
51
  err: (...a: unknown[]) => err.push(a.join(" ")),
48
52
  cwd,
53
+ now: () => 0,
49
54
  ...deps,
50
55
  });
51
56
  return { code, out: out.join("\n"), err: err.join("\n") };
package/src/cli.ts CHANGED
@@ -365,9 +365,10 @@ submission:
365
365
  — and, for new, its "authors": [{ "name", "email", "affiliation"? }]. Its "fields" answer the
366
366
  form's own fields the preset records in "submission_fields" ({ "topics": [...], "pc_conflicts":
367
367
  { "<pc email>": "<type>" }, … }); new and update send them, checked first. The token comes only from
368
- the environment, one variable per site: HOTCRP_TOKEN_<subdomain> on *.hotcrp.com, else
369
- HOTCRP_TOKEN_<host and path> — e.g. HOTCRP_TOKEN_MSR2027 for msr2027.hotcrp.com,
370
- HOTCRP_TOKEN_AIDC_SUBMIT_ACSAC_ORG for aidc.submit.acsac.org (HotCRP: Account settings →
368
+ the environment: HOTCRP_TOKEN_HOTCRP_COM for every *.hotcrp.com site (an "All sites" token),
369
+ HOTCRP_TOKEN_<subdomain> to override it for one site, e.g. HOTCRP_TOKEN_MSR2027; a self-hosted
370
+ install only HOTCRP_TOKEN_<host and path>, e.g. HOTCRP_TOKEN_AIDC_SUBMIT_ACSAC_ORG for
371
+ aidc.submit.acsac.org, never the hotcrp.com one (HotCRP: Account settings →
371
372
  Developer). A plain HOTCRP_TOKEN is not read.
372
373
  [paper] the paper's folder; default the current directory
373
374
  --pdf <file> the PDF to compare (show) or send (update) instead of the paper's own
@@ -16,19 +16,35 @@ describe("isReferencesHeading", () => {
16
16
  "7 References",
17
17
  "VII. REFERENCES",
18
18
  " References ",
19
+ // lineno's line number, which pdf.js reads glued to the end of the line (a NeurIPS submission,
20
+ // measured 2026-11-19 on fixtures/build-e2e/neurips: «References346»).
21
+ "References346",
22
+ "7 References 12",
19
23
  ])("%j is a heading", (line) => {
20
24
  expect(isReferencesHeading(line)).toBe(true);
21
25
  });
22
26
 
23
- it.each(["See the references below", "References to prior work", "Refs", ""])(
24
- "%j is not",
25
- (line) => {
26
- expect(isReferencesHeading(line)).toBe(false);
27
- },
28
- );
27
+ it.each([
28
+ "See the references below",
29
+ "References to prior work",
30
+ "References to prior work 346",
31
+ "Refs",
32
+ "",
33
+ ])("%j is not", (line) => {
34
+ expect(isReferencesHeading(line)).toBe(false);
35
+ });
29
36
  });
30
37
 
31
38
  describe("bodyEnd", () => {
39
+ it("🔴 a line-numbered submission: the heading with its line number still ends the body", () => {
40
+ expect(
41
+ bodyEnd([
42
+ "Intro1\nbody2",
43
+ "end of the body345\nReferences346\n[1] A.347",
44
+ ]),
45
+ ).toEqual({ kind: "found", by: "references", page: 2, bodyPages: 2 });
46
+ });
47
+
32
48
  it("a heading below body text on its page: that page is a body page", () => {
33
49
  expect(
34
50
  bodyEnd([
@@ -65,9 +65,11 @@ export type BodyEnd =
65
65
  /**
66
66
  * A line that is a references heading: `References` or `Bibliography`, in any case (IEEEtran sets
67
67
  * `REFERENCES` in small caps, which pdf.js may split as `R EFERENCES`), optionally numbered
68
- * (`7 References`, `VII. REFERENCES`). The line is compared with every space removed.
68
+ * (`7 References`, `VII. REFERENCES`), and with the line number `lineno` sets in a submission's
69
+ * margin, which pdf.js reads glued to the end of the line (`References346`). The line is compared
70
+ * with every space removed.
69
71
  */
70
- const HEADING = /^(?:(?:\d+|[ivxlcdm]+)\.?)?(?:references|bibliography)$/iu;
72
+ const HEADING = /^(?:(?:\d+|[ivxlcdm]+)\.?)?(?:references|bibliography)\d*$/iu;
71
73
 
72
74
  /** Whether one line of a page's text is the references heading. */
73
75
  export const isReferencesHeading = (line: string): boolean =>
@@ -3,7 +3,13 @@ import assert from "node:assert/strict";
3
3
  import { test } from "vitest";
4
4
  import { hostOf, lookUpToken } from "./portal-token.ts";
5
5
 
6
- const NAMES = { variable: "HOTCRP_TOKEN_MSR2027", siteLess: "HOTCRP_TOKEN" };
6
+ const NAMES = {
7
+ variable: "HOTCRP_TOKEN_MSR2027",
8
+ shared: null,
9
+ siteOnly: (t: string) => t.startsWith("hct_"),
10
+ siteLess: "HOTCRP_TOKEN",
11
+ };
12
+ const HOSTED = { ...NAMES, shared: "HOTCRP_TOKEN_HOTCRP_COM" };
7
13
 
8
14
  test("hostOf: the URL's host; a text that is no URL stands for itself", () => {
9
15
  assert.equal(
@@ -36,6 +42,7 @@ test("🔴 lookUpToken: only the site-less variable set → refused by name, nev
36
42
  error: {
37
43
  kind: "site-less",
38
44
  variable: "HOTCRP_TOKEN_MSR2027",
45
+ shared: null,
39
46
  siteLess: "HOTCRP_TOKEN",
40
47
  },
41
48
  },
@@ -50,6 +57,118 @@ test("lookUpToken: neither set, or only blanks → missing, naming the site's va
50
57
  for (const read of [() => undefined, (n: string) => blank[n]])
51
58
  assert.deepEqual(lookUpToken(NAMES, read), {
52
59
  ok: false,
53
- error: { kind: "missing", variable: "HOTCRP_TOKEN_MSR2027" },
60
+ error: {
61
+ kind: "missing",
62
+ variable: "HOTCRP_TOKEN_MSR2027",
63
+ shared: null,
64
+ },
54
65
  });
55
66
  });
67
+
68
+ test("lookUpToken: a hosted site with only the shared variable set → the shared token, and its name", () => {
69
+ const env: Record<string, string> = {
70
+ HOTCRP_TOKEN_HOTCRP_COM: " hcT_all \n",
71
+ };
72
+ assert.deepEqual(
73
+ lookUpToken(HOSTED, (n) => env[n]),
74
+ {
75
+ ok: true,
76
+ value: { variable: "HOTCRP_TOKEN_HOTCRP_COM", token: "hcT_all" },
77
+ },
78
+ );
79
+ });
80
+
81
+ test("lookUpToken: a hosted site with both set → the site's own token wins", () => {
82
+ const env: Record<string, string> = {
83
+ HOTCRP_TOKEN_MSR2027: "hct_site",
84
+ HOTCRP_TOKEN_HOTCRP_COM: "hcT_all",
85
+ };
86
+ assert.deepEqual(
87
+ lookUpToken(HOSTED, (n) => env[n]),
88
+ {
89
+ ok: true,
90
+ value: { variable: "HOTCRP_TOKEN_MSR2027", token: "hct_site" },
91
+ },
92
+ );
93
+ });
94
+
95
+ test("lookUpToken: a hosted site with a blank own variable falls to the shared one", () => {
96
+ const env: Record<string, string> = {
97
+ HOTCRP_TOKEN_MSR2027: " ",
98
+ HOTCRP_TOKEN_HOTCRP_COM: "hcT_all",
99
+ };
100
+ assert.deepEqual(
101
+ lookUpToken(HOSTED, (n) => env[n]),
102
+ {
103
+ ok: true,
104
+ value: { variable: "HOTCRP_TOKEN_HOTCRP_COM", token: "hcT_all" },
105
+ },
106
+ );
107
+ });
108
+
109
+ test("🔴 lookUpToken: a site with no shared variable never reads it, set or not", () => {
110
+ const env: Record<string, string> = { HOTCRP_TOKEN_HOTCRP_COM: "hcT_all" };
111
+ const seen: string[] = [];
112
+ assert.deepEqual(
113
+ lookUpToken(NAMES, (n) => (seen.push(n), env[n])),
114
+ {
115
+ ok: false,
116
+ error: {
117
+ kind: "missing",
118
+ variable: "HOTCRP_TOKEN_MSR2027",
119
+ shared: null,
120
+ },
121
+ },
122
+ );
123
+ assert.deepEqual(seen, ["HOTCRP_TOKEN_MSR2027", "HOTCRP_TOKEN"]);
124
+ });
125
+
126
+ test("🔴 lookUpToken: a hosted site with only the site-less variable set → refused by name, shared named", () => {
127
+ const env: Record<string, string> = { HOTCRP_TOKEN: "hct_other" };
128
+ assert.deepEqual(
129
+ lookUpToken(HOSTED, (n) => env[n]),
130
+ {
131
+ ok: false,
132
+ error: {
133
+ kind: "site-less",
134
+ variable: "HOTCRP_TOKEN_MSR2027",
135
+ shared: "HOTCRP_TOKEN_HOTCRP_COM",
136
+ siteLess: "HOTCRP_TOKEN",
137
+ },
138
+ },
139
+ );
140
+ });
141
+
142
+ test("🔴 lookUpToken: a site-only token in the shared variable → refused, naming both variables, never used", () => {
143
+ const env: Record<string, string> = { HOTCRP_TOKEN_HOTCRP_COM: "hct_fake" };
144
+ assert.deepEqual(
145
+ lookUpToken(HOSTED, (n) => env[n]),
146
+ {
147
+ ok: false,
148
+ error: {
149
+ kind: "site-only",
150
+ variable: "HOTCRP_TOKEN_MSR2027",
151
+ shared: "HOTCRP_TOKEN_HOTCRP_COM",
152
+ },
153
+ },
154
+ );
155
+ });
156
+
157
+ test("lookUpToken: the same token in the site's own variable is used; an all-sites token in the shared one is used", () => {
158
+ const own: Record<string, string> = { HOTCRP_TOKEN_MSR2027: "hct_fake" };
159
+ assert.deepEqual(
160
+ lookUpToken(HOSTED, (n) => own[n]),
161
+ {
162
+ ok: true,
163
+ value: { variable: "HOTCRP_TOKEN_MSR2027", token: "hct_fake" },
164
+ },
165
+ );
166
+ const all: Record<string, string> = { HOTCRP_TOKEN_HOTCRP_COM: "hcT_fake" };
167
+ assert.deepEqual(
168
+ lookUpToken(HOSTED, (n) => all[n]),
169
+ {
170
+ ok: true,
171
+ value: { variable: "HOTCRP_TOKEN_HOTCRP_COM", token: "hcT_fake" },
172
+ },
173
+ );
174
+ });
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * WHICH TOKEN A PORTAL COMMAND USES — the policy, in one place. Pure.
3
3
  *
4
- * The site's own variable, and nothing else: there is NO fallback to a site-less variable. With one,
5
- * which token a command used is not visible, and a token from another site reads as "the portal
6
- * refused". A site-less variable that is set while the site's own is not is refused by name. The
7
- * names themselves are the portal's (`src/adapters/hotcrp/token.ts`).
4
+ * The site's own variable, then the one its portal's sites share (when it has one), and nothing else:
5
+ * there is NO fallback to a site-less variable. With one, which token a command used is not visible,
6
+ * and a token from another site reads as "the portal refused". A site-less variable that is set while
7
+ * neither of those is, is refused by name. The names themselves are the portal's
8
+ * (`src/adapters/hotcrp/token.ts`).
8
9
  */
9
10
  import { err, ok, type Result } from "./result.ts";
10
11
 
@@ -16,9 +17,15 @@ import { err, ok, type Result } from "./result.ts";
16
17
  export const hostOf = (url: string): string =>
17
18
  URL.canParse(url) ? new URL(url).host : url;
18
19
 
19
- /** The variables a lookup reads: the site's own, and the site-less one it refuses. */
20
+ /**
21
+ * The variables a lookup reads: the site's own, the one shared by the portal's sites (null: none),
22
+ * and the site-less one it refuses.
23
+ */
20
24
  export interface TokenNames {
21
25
  readonly variable: string;
26
+ readonly shared: string | null;
27
+ /** Whether a token is valid on one site only, so cannot stand in for the shared variable. */
28
+ readonly siteOnly: (token: string) => boolean;
22
29
  readonly siteLess: string;
23
30
  }
24
31
 
@@ -30,12 +37,23 @@ export interface FoundToken {
30
37
 
31
38
  /** Why there is no token to use. */
32
39
  export type TokenProblem =
33
- /** The site's variable is not set (or blank), and neither is the site-less one. */
34
- | { readonly kind: "missing"; readonly variable: string }
35
- /** The site's variable is not set, but the site-less one, no longer read, is. */
40
+ /** The site's variable is not set (or blank), nor the shared one, nor the site-less one. */
41
+ | {
42
+ readonly kind: "missing";
43
+ readonly variable: string;
44
+ readonly shared: string | null;
45
+ }
46
+ /** The shared variable holds a token that works on one site only. */
47
+ | {
48
+ readonly kind: "site-only";
49
+ readonly variable: string;
50
+ readonly shared: string;
51
+ }
52
+ /** Neither the site's variable nor the shared one is set, but the site-less one, no longer read, is. */
36
53
  | {
37
54
  readonly kind: "site-less";
38
55
  readonly variable: string;
56
+ readonly shared: string | null;
39
57
  readonly siteLess: string;
40
58
  };
41
59
 
@@ -48,16 +66,22 @@ const value = (
48
66
  };
49
67
 
50
68
  /**
51
- * The token for a portal, read through `read` (the root reads the environment): the site's variable
52
- * only. A set site-less variable never stands in for it — it is named as the problem instead.
69
+ * The token for a portal, read through `read` (the root reads the environment): the site's variable,
70
+ * else the shared one (unless that holds a token for one site only). A set site-less variable never stands in for either — it is named as the
71
+ * problem instead.
53
72
  */
54
73
  export function lookUpToken(
55
- { variable, siteLess }: TokenNames,
74
+ { variable, shared, siteOnly, siteLess }: TokenNames,
56
75
  read: (name: string) => string | undefined,
57
76
  ): Result<FoundToken, TokenProblem> {
58
- const token = value(read, variable);
59
- if (token !== null) return ok({ variable, token });
77
+ const own = value(read, variable);
78
+ if (own !== null) return ok({ variable, token: own });
79
+ const common = shared === null ? null : value(read, shared);
80
+ if (shared !== null && common !== null)
81
+ return siteOnly(common)
82
+ ? err({ kind: "site-only", variable, shared })
83
+ : ok({ variable: shared, token: common });
60
84
  return value(read, siteLess) === null
61
- ? err({ kind: "missing", variable })
62
- : err({ kind: "site-less", variable, siteLess });
85
+ ? err({ kind: "missing", variable, shared })
86
+ : err({ kind: "site-less", variable, shared, siteLess });
63
87
  }