paperlint 10.4.1 → 11.0.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/.github/workflows/deadlines.yml +27 -7
- package/README.md +16 -15
- package/dist/adapters/hotcrp/index.d.ts +6 -4
- package/dist/adapters/hotcrp/index.d.ts.map +1 -1
- package/dist/adapters/hotcrp/index.js +6 -4
- package/dist/adapters/hotcrp/index.js.map +1 -1
- package/dist/adapters/hotcrp/portal.io.d.ts +3 -1
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +36 -11
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts +6 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +17 -0
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/adapters/hotcrp/site.d.ts +9 -0
- package/dist/adapters/hotcrp/site.d.ts.map +1 -0
- package/dist/adapters/hotcrp/site.js +22 -0
- package/dist/adapters/hotcrp/site.js.map +1 -0
- package/dist/adapters/hotcrp/token.d.ts +13 -0
- package/dist/adapters/hotcrp/token.d.ts.map +1 -0
- package/dist/adapters/hotcrp/token.js +48 -0
- package/dist/adapters/hotcrp/token.js.map +1 -0
- package/dist/adapters/latex/abstract.d.ts +22 -0
- package/dist/adapters/latex/abstract.d.ts.map +1 -0
- package/dist/adapters/latex/abstract.js +187 -0
- package/dist/adapters/latex/abstract.js.map +1 -0
- package/dist/adapters/latex/headings.d.ts +6 -0
- package/dist/adapters/latex/headings.d.ts.map +1 -1
- package/dist/adapters/latex/headings.js +5 -4
- package/dist/adapters/latex/headings.js.map +1 -1
- package/dist/adapters/latex/index.d.ts.map +1 -1
- package/dist/adapters/latex/index.js +2 -0
- package/dist/adapters/latex/index.js.map +1 -1
- package/dist/adapters/latex/parse.d.ts +15 -0
- package/dist/adapters/latex/parse.d.ts.map +1 -1
- package/dist/adapters/latex/parse.js +58 -1
- package/dist/adapters/latex/parse.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +20 -8
- package/dist/cli.js.map +1 -1
- package/dist/cycle-rules.d.ts.map +1 -1
- package/dist/cycle-rules.js +3 -4
- package/dist/cycle-rules.js.map +1 -1
- package/dist/domain/deadline.d.ts +8 -1
- package/dist/domain/deadline.d.ts.map +1 -1
- package/dist/domain/deadline.js +26 -12
- package/dist/domain/deadline.js.map +1 -1
- package/dist/domain/portal-token.d.ts +44 -0
- package/dist/domain/portal-token.d.ts.map +1 -0
- package/dist/domain/portal-token.js +32 -0
- package/dist/domain/portal-token.js.map +1 -0
- package/dist/domain/submission.d.ts +30 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js +68 -0
- package/dist/domain/submission.js.map +1 -1
- package/dist/lib/paper-config.d.ts +1 -1
- package/dist/lib/paper-config.d.ts.map +1 -1
- package/dist/lib/paper-config.js +6 -4
- package/dist/lib/paper-config.js.map +1 -1
- package/dist/paper-settings.d.ts +3 -1
- package/dist/paper-settings.d.ts.map +1 -1
- package/dist/paper-settings.js +11 -5
- package/dist/paper-settings.js.map +1 -1
- package/dist/ports/latex.d.ts +23 -0
- package/dist/ports/latex.d.ts.map +1 -1
- package/dist/ports/submission-portal.d.ts +39 -2
- package/dist/ports/submission-portal.d.ts.map +1 -1
- package/dist/ports/venue-deadlines.d.ts +1 -1
- package/dist/submission.d.ts +49 -11
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +332 -44
- package/dist/submission.js.map +1 -1
- package/docs/configuration.md +2 -1
- package/docs/rules/cycle/record.md +9 -6
- package/docs/submission.md +47 -48
- package/eslint.config.mjs +3 -0
- package/lib/paper-config.ts +7 -4
- package/package.json +6 -1
- package/presets/msr.jsonc +9 -7
- package/presets/msr.md +14 -10
- package/scripts/check.ts +1 -1
- package/scripts/refresh-deadlines/compare.test.ts +75 -0
- package/scripts/refresh-deadlines/compare.ts +101 -0
- package/scripts/refresh-deadlines/main.test.ts +140 -0
- package/scripts/refresh-deadlines/main.ts +56 -0
- package/scripts/refresh-deadlines/refresh.test.ts +287 -0
- package/scripts/refresh-deadlines/refresh.ts +183 -0
- package/skills/submission-portal/SKILL.md +60 -44
- package/skills/submission-portal/SKILL.md.spec.ts +62 -43
- package/skills/submission-portal/submission-portal.test.ts +4 -73
- package/src/adapters/hotcrp/cassette/README.md +4 -4
- package/src/adapters/hotcrp/cassette/deadlines-msr2027.html +9 -9
- package/src/adapters/hotcrp/deadlines.io.test.ts +2 -2
- package/src/adapters/hotcrp/deadlines.test.ts +3 -3
- package/src/adapters/hotcrp/index.ts +15 -3
- package/src/adapters/hotcrp/portal.io.ts +61 -17
- package/src/adapters/hotcrp/portal.test.ts +105 -1
- package/src/adapters/hotcrp/response.ts +21 -0
- package/src/adapters/hotcrp/site.ts +34 -0
- package/src/adapters/hotcrp/token.test.ts +69 -0
- package/src/adapters/hotcrp/token.ts +51 -0
- package/src/adapters/latex/abstract.test.ts +280 -0
- package/src/adapters/latex/abstract.ts +272 -0
- package/src/adapters/latex/headings.ts +5 -4
- package/src/adapters/latex/index.test.ts +31 -1
- package/src/adapters/latex/index.ts +2 -0
- package/src/adapters/latex/parse.ts +64 -3
- package/src/cli.test.ts +20 -8
- package/src/cli.ts +22 -13
- package/src/cycle-rules.test.ts +6 -6
- package/src/cycle-rules.ts +7 -4
- package/src/domain/deadline.test.ts +31 -2
- package/src/domain/deadline.ts +42 -16
- package/src/domain/portal-token.test.ts +55 -0
- package/src/domain/portal-token.ts +63 -0
- package/src/domain/submission.test.ts +88 -0
- package/src/domain/submission.ts +99 -0
- package/src/new-paper.test.ts +1 -0
- package/src/paper-settings.test.ts +20 -0
- package/src/paper-settings.ts +17 -5
- package/src/ports/latex.ts +25 -0
- package/src/ports/submission-portal.ts +43 -1
- package/src/ports/venue-deadlines.ts +1 -1
- package/src/presets.test.ts +8 -5
- package/src/submission-new.test.ts +569 -0
- package/src/submission-show.test.ts +210 -0
- package/src/submission-update.test.ts +160 -0
- package/src/submission.test.ts +140 -518
- package/src/submission.ts +494 -61
- package/scripts/refresh-deadlines.test.ts +0 -431
- package/scripts/refresh-deadlines.ts +0 -387
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE ABSTRACT AS PLAIN TEXT, FROM THE SOURCE — the body of `\begin{abstract}…\end{abstract}`, as
|
|
3
|
+
* `paperlint submission new` sends it. Pure.
|
|
4
|
+
*
|
|
5
|
+
* unified-latex does the TeX: util-macros reads `\newcommand`/`\renewcommand`/`\providecommand` and
|
|
6
|
+
* expands them, util-ligatures turns `--`, ``` `` ```, `~`, `\%`, `\ldots`, accents… into the
|
|
7
|
+
* characters TeX prints. The macro categories are the adapter's shared sets (parse.ts, headings.ts).
|
|
8
|
+
* What is ours is the policy. A macro the source defines once, before the abstract, is expanded (`\def`, which
|
|
9
|
+
* util-macros does not read, by hand). One it defines more than once is refused with every
|
|
10
|
+
* definition's place: which one TeX uses depends on order, groups and the definer
|
|
11
|
+
* (`\providecommand` keeps an earlier one), and paperlint does not reimplement that. Refused too, with
|
|
12
|
+
* where it stands: a macro nobody defined, one that takes arguments or expands into itself, math
|
|
13
|
+
* beyond digits and symbols, any other construct. Never guessed.
|
|
14
|
+
*/
|
|
15
|
+
import type * as Ast from "@unified-latex/unified-latex-types";
|
|
16
|
+
import { expandUnicodeLigatures } from "@unified-latex/unified-latex-util-ligatures";
|
|
17
|
+
import {
|
|
18
|
+
expandMacros,
|
|
19
|
+
newcommandMacroToName,
|
|
20
|
+
newcommandMacroToSpec,
|
|
21
|
+
newcommandMacroToSubstitutionAst,
|
|
22
|
+
newcommandMatcher,
|
|
23
|
+
} from "@unified-latex/unified-latex-util-macros";
|
|
24
|
+
import { replaceNode } from "@unified-latex/unified-latex-util-replace";
|
|
25
|
+
import { fieldOf } from "../../domain/record.ts";
|
|
26
|
+
import { err, ok, type Result } from "../../domain/result.ts";
|
|
27
|
+
import type { AbstractProblem } from "../../ports/latex.ts";
|
|
28
|
+
import { INVISIBLE, LINE_BREAKS, TRANSPARENT } from "./headings.ts";
|
|
29
|
+
import {
|
|
30
|
+
argumentsOf,
|
|
31
|
+
isNode,
|
|
32
|
+
visited,
|
|
33
|
+
type Macro,
|
|
34
|
+
type Node,
|
|
35
|
+
} from "./nodes.ts";
|
|
36
|
+
import {
|
|
37
|
+
ACCENT_SYMBOLS,
|
|
38
|
+
CITATION_MACROS,
|
|
39
|
+
DEF_MACROS,
|
|
40
|
+
liveRoot,
|
|
41
|
+
LOGO_MACROS,
|
|
42
|
+
MATH_CHARACTERS,
|
|
43
|
+
parseLatex,
|
|
44
|
+
SET_APART_MACROS,
|
|
45
|
+
SILENT_MACROS,
|
|
46
|
+
} from "./parse.ts";
|
|
47
|
+
|
|
48
|
+
/** What an author's macro stands for: its body (null: it takes arguments), and where each definition stands. */
|
|
49
|
+
interface Definition {
|
|
50
|
+
readonly body: readonly Node[] | null;
|
|
51
|
+
readonly at: readonly number[];
|
|
52
|
+
/** Where this body's own definition stands: the last one read. */
|
|
53
|
+
readonly own: number;
|
|
54
|
+
}
|
|
55
|
+
type Text = Result<string, Exclude<AbstractProblem, { readonly kind: "none" }>>;
|
|
56
|
+
|
|
57
|
+
const PLAIN_MATH = /^[\p{L}\p{N}\s.,:;+\-=<>()/!|']*$/u;
|
|
58
|
+
/** Rounds of expansion before a macro still standing is taken to expand into itself. */
|
|
59
|
+
const DEPTH = 16;
|
|
60
|
+
|
|
61
|
+
const at = (n: Node): number => n.position?.start.offset ?? -1;
|
|
62
|
+
const end = (n: Node): number => n.position?.end.offset ?? at(n);
|
|
63
|
+
const refuse = (what: string, n: Node): Text =>
|
|
64
|
+
err({ kind: "unreadable", what, at: at(n) });
|
|
65
|
+
|
|
66
|
+
/** `\def\x{body}` → its body; `\def\x#1{…}` takes arguments. util-macros does not read `\def`. */
|
|
67
|
+
function defDefinition(m: Macro): readonly [string, Definition["body"]][] {
|
|
68
|
+
const [name, body] = argumentsOf(m);
|
|
69
|
+
const macro = name?.content.find((n) => n.type === "macro");
|
|
70
|
+
if (macro?.type !== "macro" || body === undefined) return [];
|
|
71
|
+
const hash = body.content.some(
|
|
72
|
+
(n) => n.type === "string" && n.content.includes("#"),
|
|
73
|
+
);
|
|
74
|
+
return [[macro.content, hash ? null : body.content]];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** `\newcommand` and its kin, read by util-macros. */
|
|
78
|
+
function definitionOf(m: Macro): readonly [string, Definition["body"]][] {
|
|
79
|
+
if (DEF_MACROS.has(m.content)) return defDefinition(m);
|
|
80
|
+
// A \newcommand the parser gave no name has none here either: util-macros answers "".
|
|
81
|
+
const name = newcommandMatcher(m) ? newcommandMacroToName(m) : "";
|
|
82
|
+
if (name === "") return [];
|
|
83
|
+
const plain = newcommandMacroToSpec(m) === "";
|
|
84
|
+
return [[name, plain ? newcommandMacroToSubstitutionAst(m) : null]];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Every macro the source defines, with each of its definitions' places. */
|
|
88
|
+
function definitionsIn(
|
|
89
|
+
nodes: readonly Node[],
|
|
90
|
+
): ReadonlyMap<string, Definition> {
|
|
91
|
+
const found = nodes.flatMap((n) =>
|
|
92
|
+
n.type === "macro"
|
|
93
|
+
? definitionOf(n).map(([name, body]) => ({ name, body, at: at(n) }))
|
|
94
|
+
: [],
|
|
95
|
+
);
|
|
96
|
+
return new Map(
|
|
97
|
+
found.map((d) => [
|
|
98
|
+
d.name,
|
|
99
|
+
{
|
|
100
|
+
body: d.body,
|
|
101
|
+
at: found.filter((e) => e.name === d.name).map((e) => e.at),
|
|
102
|
+
own: d.at,
|
|
103
|
+
},
|
|
104
|
+
]),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Nodes in order, joined; the first refusal stops the reading. */
|
|
109
|
+
const joined = (nodes: readonly Node[], one: (n: Node) => Text): Text =>
|
|
110
|
+
nodes.reduce<Text>((acc, n) => {
|
|
111
|
+
if (!acc.ok) return acc;
|
|
112
|
+
const t = one(n);
|
|
113
|
+
return t.ok ? ok(acc.value + t.value) : t;
|
|
114
|
+
}, ok(""));
|
|
115
|
+
|
|
116
|
+
interface Reading {
|
|
117
|
+
/** Where `\\begin{abstract}` stands: a definition from here on is not applied backwards. */
|
|
118
|
+
readonly start: number;
|
|
119
|
+
readonly src: string;
|
|
120
|
+
readonly defs: ReadonlyMap<string, Definition>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A macro of the author's still standing after expansion: why it is. */
|
|
124
|
+
function definedProblem(m: Macro, r: Reading): Text | null {
|
|
125
|
+
const def = r.defs.get(m.content);
|
|
126
|
+
if (def === undefined) return null;
|
|
127
|
+
if (def.at.length > 1)
|
|
128
|
+
return err({ kind: "redefined", name: m.content, at: def.at });
|
|
129
|
+
if (def.own >= r.start)
|
|
130
|
+
return err({
|
|
131
|
+
kind: "unreadable",
|
|
132
|
+
what: `\\${m.content}, which the paper defines only after the abstract begins`,
|
|
133
|
+
at: def.own,
|
|
134
|
+
});
|
|
135
|
+
const why = def.body === null ? "takes arguments" : "expands into itself";
|
|
136
|
+
return refuse(`\\${m.content}, which ${why}`, m);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** What a macro of the shared sets prints regardless of its arguments; null for any other. */
|
|
140
|
+
function fixedText(name: string): string | null {
|
|
141
|
+
if (CITATION_MACROS.has(name) || INVISIBLE.has(name)) return "";
|
|
142
|
+
if (SILENT_MACROS.has(name)) return "";
|
|
143
|
+
if (LINE_BREAKS.has(name)) return " ";
|
|
144
|
+
return LOGO_MACROS.get(name) ?? null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function macroText(m: Macro, r: Reading): Text {
|
|
148
|
+
const name = m.content;
|
|
149
|
+
const fixed = fixedText(name);
|
|
150
|
+
if (fixed !== null) return ok(fixed);
|
|
151
|
+
if (TRANSPARENT.has(name) || SET_APART_MACROS.has(name))
|
|
152
|
+
return joined(m.args?.at(-1)?.content ?? [], (n) => textNode(n, r));
|
|
153
|
+
return (
|
|
154
|
+
definedProblem(m, r) ??
|
|
155
|
+
refuse(
|
|
156
|
+
`\\${name}, which no \\newcommand, \\renewcommand or \\def in the paper defines`,
|
|
157
|
+
m,
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** `$…$`: digits, letters and plain symbols, or refused whole. A group in math only groups. */
|
|
163
|
+
function mathText(math: Readonly<Ast.InlineMath>, r: Reading): Text {
|
|
164
|
+
const whole = refuse(`the math ${r.src.slice(at(math), end(math))}`, math);
|
|
165
|
+
const one = (n: Node): Text => {
|
|
166
|
+
if (n.type === "whitespace") return ok(" ");
|
|
167
|
+
if (n.type === "group") return joined(n.content, one);
|
|
168
|
+
if (n.type === "string")
|
|
169
|
+
return PLAIN_MATH.test(n.content) ? ok(n.content) : whole;
|
|
170
|
+
if (n.type !== "macro") return whole;
|
|
171
|
+
const symbol = MATH_CHARACTERS.get(n.content);
|
|
172
|
+
return symbol === undefined ? (definedProblem(n, r) ?? whole) : ok(symbol);
|
|
173
|
+
};
|
|
174
|
+
return joined(math.content, one);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** A math environment's name as the parser gives it: typed a string, a string node at run time. */
|
|
178
|
+
const mathEnvName = (n: { readonly env: unknown }): unknown => n.env;
|
|
179
|
+
|
|
180
|
+
/** A node that holds no text of its own to read: a comment, or a construct with no plain reading. */
|
|
181
|
+
function leafText(n: Node): Text {
|
|
182
|
+
if (n.type === "whitespace" || n.type === "parbreak") return ok(" ");
|
|
183
|
+
if (n.type === "comment")
|
|
184
|
+
// A comment eats its line's end; the space before the `%`, which the parser folds into it, stays.
|
|
185
|
+
return ok(n.leadingWhitespace === true ? " " : "");
|
|
186
|
+
if (n.type === "environment") return refuse(`the ${n.env} environment`, n);
|
|
187
|
+
if (n.type === "mathenv") {
|
|
188
|
+
const env = String(fieldOf(mathEnvName(n), "content"));
|
|
189
|
+
return refuse(`the ${env} environment`, n);
|
|
190
|
+
}
|
|
191
|
+
return refuse(`the ${n.type}`, n);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function textNode(n: Node, r: Reading): Text {
|
|
195
|
+
if (n.type === "string") return ok(n.content);
|
|
196
|
+
if (n.type === "group") return joined(n.content, (c) => textNode(c, r));
|
|
197
|
+
if (n.type === "macro") return macroText(n, r);
|
|
198
|
+
if (n.type === "inlinemath") return mathText(n, r);
|
|
199
|
+
return leafText(n);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** A control symbol that is no accent: TeX keeps the space after it (`50\% of`, `it\/ and`). */
|
|
203
|
+
const keepsSpace = (
|
|
204
|
+
n: Readonly<Ast.Node | Ast.Argument> | undefined,
|
|
205
|
+
): boolean =>
|
|
206
|
+
n?.type === "macro" &&
|
|
207
|
+
n.content.length === 1 &&
|
|
208
|
+
!/\p{L}/u.test(n.content) &&
|
|
209
|
+
!ACCENT_SYMBOLS.has(n.content);
|
|
210
|
+
|
|
211
|
+
/** One paragraph: runs of space as one, none before closing punctuation; `\-` (U+00AD) prints nothing. */
|
|
212
|
+
const paragraph = (raw: string): string =>
|
|
213
|
+
raw
|
|
214
|
+
.replaceAll("", "")
|
|
215
|
+
.replace(/\s+/gu, " ")
|
|
216
|
+
.replace(/ ([,.;:!?)])/gu, "$1")
|
|
217
|
+
.trim();
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The abstract's nodes as TeX would set them, as a new tree: each macro defined once expanded, one
|
|
221
|
+
* level per round (a macro still standing after DEPTH rounds expands into itself), then ligatures.
|
|
222
|
+
*/
|
|
223
|
+
function typeset(
|
|
224
|
+
content: readonly Node[],
|
|
225
|
+
defs: ReadonlyMap<string, Definition>,
|
|
226
|
+
start: number,
|
|
227
|
+
): Readonly<Ast.Root> {
|
|
228
|
+
// Expanded: a macro with one definition, standing before the abstract.
|
|
229
|
+
const plain = [...defs].flatMap(([name, d]) =>
|
|
230
|
+
d.body === null || d.at.length > 1 || d.own >= start
|
|
231
|
+
? []
|
|
232
|
+
: [{ name, body: structuredClone([...d.body]) }],
|
|
233
|
+
);
|
|
234
|
+
// eslint-disable-next-line functional/prefer-immutable-types -- a clone the three library calls below rewrite in place
|
|
235
|
+
const body: Ast.Root = {
|
|
236
|
+
type: "root",
|
|
237
|
+
content: structuredClone([...content]),
|
|
238
|
+
};
|
|
239
|
+
Array.from({ length: DEPTH }).forEach(() => {
|
|
240
|
+
expandMacros(body, plain);
|
|
241
|
+
});
|
|
242
|
+
// util-ligatures swallows the space after a control symbol, as it must after an accent.
|
|
243
|
+
replaceNode(body, (n, info) =>
|
|
244
|
+
n.type === "whitespace" &&
|
|
245
|
+
keepsSpace(info.containingArray?.slice(0, info.index).at(-1))
|
|
246
|
+
? { type: "string", content: " " }
|
|
247
|
+
: undefined,
|
|
248
|
+
);
|
|
249
|
+
expandUnicodeLigatures(body);
|
|
250
|
+
return body;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The abstract of `src` as one paragraph of plain text, or what stops it; nothing after `\\end{document}` is read. */
|
|
254
|
+
export const abstractText = (src: string): Result<string, AbstractProblem> =>
|
|
255
|
+
abstractOfTree(liveRoot(parseLatex(src)), src);
|
|
256
|
+
|
|
257
|
+
/** The same, over a tree already parsed from `src`. */
|
|
258
|
+
export function abstractOfTree(
|
|
259
|
+
root: Readonly<Ast.Root>,
|
|
260
|
+
src: string,
|
|
261
|
+
): Result<string, AbstractProblem> {
|
|
262
|
+
const nodes = visited(root, () => false).filter(isNode);
|
|
263
|
+
const env = nodes.find(
|
|
264
|
+
(n) => n.type === "environment" && n.env === "abstract",
|
|
265
|
+
);
|
|
266
|
+
if (env?.type !== "environment") return err({ kind: "none" });
|
|
267
|
+
const defs = definitionsIn(nodes);
|
|
268
|
+
const start = at(env);
|
|
269
|
+
const body = typeset(env.content, defs, start);
|
|
270
|
+
const t = joined(body.content, (n) => textNode(n, { src, defs, start }));
|
|
271
|
+
return t.ok ? ok(paragraph(t.value)) : t;
|
|
272
|
+
}
|
|
@@ -43,7 +43,7 @@ const LEVELS: ReadonlyMap<string, HeadingLevel> = new Map<string, HeadingLevel>(
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
/** Formatting commands: they say what their argument says. */
|
|
46
|
-
const TRANSPARENT: ReadonlySet<string> = new Set([
|
|
46
|
+
export const TRANSPARENT: ReadonlySet<string> = new Set([
|
|
47
47
|
"emph",
|
|
48
48
|
"textit",
|
|
49
49
|
"textbf",
|
|
@@ -56,14 +56,15 @@ const TRANSPARENT: ReadonlySet<string> = new Set([
|
|
|
56
56
|
]);
|
|
57
57
|
|
|
58
58
|
/** Commands that break the line: the title goes on as a second part, a subtitle. */
|
|
59
|
-
const LINE_BREAKS: ReadonlySet<string> = new Set([
|
|
60
|
-
"
|
|
59
|
+
export const LINE_BREAKS: ReadonlySet<string> = new Set([
|
|
60
|
+
// `\\` is the macro unified-latex names with ONE backslash (`{ type: "macro", content: "\\" }`).
|
|
61
|
+
"\\",
|
|
61
62
|
"newline",
|
|
62
63
|
"linebreak",
|
|
63
64
|
]);
|
|
64
65
|
|
|
65
66
|
/** Commands that put nothing in the title's words: a label, a footnote, an index entry. */
|
|
66
|
-
const INVISIBLE: ReadonlySet<string> = new Set([
|
|
67
|
+
export const INVISIBLE: ReadonlySet<string> = new Set([
|
|
67
68
|
"label",
|
|
68
69
|
"footnote",
|
|
69
70
|
"thanks",
|
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type * as Ast from "@unified-latex/unified-latex-types";
|
|
8
8
|
import { describe, expect, it } from "vitest";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
OPAQUE,
|
|
11
|
+
runText,
|
|
12
|
+
spanIn,
|
|
13
|
+
type ProsePiece,
|
|
14
|
+
} from "../../domain/tex-document.ts";
|
|
10
15
|
import {
|
|
11
16
|
bodyEmphasis,
|
|
12
17
|
bodyProse,
|
|
@@ -770,3 +775,28 @@ describe("latexReader.filecontents — a file name on a line of its own", () =>
|
|
|
770
775
|
]);
|
|
771
776
|
});
|
|
772
777
|
});
|
|
778
|
+
|
|
779
|
+
/** The text of each heading of a document whose `\title` is `t`. */
|
|
780
|
+
const titleTexts = (t: string): readonly string[] =>
|
|
781
|
+
latexReader
|
|
782
|
+
.headings(
|
|
783
|
+
`\\documentclass{article}\\title{${t}}\\begin{document}\\end{document}`,
|
|
784
|
+
)
|
|
785
|
+
.map((h) => runText(h.title));
|
|
786
|
+
|
|
787
|
+
describe("headings — the paper's \\title as text", () => {
|
|
788
|
+
it("`\\\\`, `\\newline` and `\\linebreak` are line breaks, never an opaque command", () => {
|
|
789
|
+
expect(
|
|
790
|
+
["A\\\\ B", "A\\\\[1ex] B", "A\\newline B", "A\\linebreak[3] B"].map(
|
|
791
|
+
titleTexts,
|
|
792
|
+
),
|
|
793
|
+
).toEqual([["A\u2028 B"], ["A\u2028 B"], ["A\u2028 B"], ["A\u2028 B"]]);
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
it("plain words read as written, a run of spaces as one; a macro of the author's own stands as OPAQUE", () => {
|
|
797
|
+
expect(["Plain Title", "\\ours{}: Lies"].map(titleTexts)).toEqual([
|
|
798
|
+
["Plain Title"],
|
|
799
|
+
[`${OPAQUE}: Lies`],
|
|
800
|
+
]);
|
|
801
|
+
});
|
|
802
|
+
});
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* (`ParsedTex`, minted by `parseLatex` alone).
|
|
22
22
|
*/
|
|
23
23
|
import type { LatexReader } from "../../ports/latex.ts";
|
|
24
|
+
import { abstractText } from "./abstract.ts";
|
|
24
25
|
import {
|
|
25
26
|
documentClassOf,
|
|
26
27
|
parseTemplate,
|
|
@@ -72,4 +73,5 @@ export const latexReader: LatexReader = {
|
|
|
72
73
|
withDocumentClass: (src, want) => replaceDocumentClass(parseLatex(src), want),
|
|
73
74
|
layoutOverrides: (src) => layoutOverridesOf(parseLatex(src)),
|
|
74
75
|
filecontents: (src, jobname) => filecontentsOf(parseLatex(src), jobname),
|
|
76
|
+
abstractText,
|
|
75
77
|
};
|
|
@@ -39,6 +39,61 @@ export const CITATION_MACROS: ReadonlySet<string> = new Set([
|
|
|
39
39
|
"footcite",
|
|
40
40
|
]);
|
|
41
41
|
|
|
42
|
+
/** Commands that print nothing: line-breaking and spacing hints, and the two that only protect. */
|
|
43
|
+
export const SILENT_MACROS: ReadonlySet<string> = new Set([
|
|
44
|
+
"allowbreak",
|
|
45
|
+
"nobreak",
|
|
46
|
+
"nolinebreak",
|
|
47
|
+
"xspace",
|
|
48
|
+
"noindent",
|
|
49
|
+
"relax",
|
|
50
|
+
"protect",
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Formatting that prints its argument but sets it apart — code, small caps, a box: read as its
|
|
55
|
+
* words where the text is read whole (an abstract), not judged as prose (a heading's case).
|
|
56
|
+
*/
|
|
57
|
+
export const SET_APART_MACROS: ReadonlySet<string> = new Set([
|
|
58
|
+
"texttt",
|
|
59
|
+
"textsc",
|
|
60
|
+
"mbox",
|
|
61
|
+
"text",
|
|
62
|
+
"underline",
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
/** The logos that print a fixed word. */
|
|
66
|
+
export const LOGO_MACROS: ReadonlyMap<string, string> = new Map([
|
|
67
|
+
["LaTeX", "LaTeX"],
|
|
68
|
+
["TeX", "TeX"],
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
/** Accents: control symbols that take the next letter, across a space (`\' e` is é). */
|
|
72
|
+
export const ACCENT_SYMBOLS: ReadonlySet<string> = new Set([
|
|
73
|
+
"'",
|
|
74
|
+
'"',
|
|
75
|
+
"^",
|
|
76
|
+
"~",
|
|
77
|
+
".",
|
|
78
|
+
"=",
|
|
79
|
+
"`",
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
/** Math symbols with one plain-text character. */
|
|
83
|
+
export const MATH_CHARACTERS: ReadonlyMap<string, string> = new Map([
|
|
84
|
+
["%", "%"],
|
|
85
|
+
[",", " "],
|
|
86
|
+
["times", "×"],
|
|
87
|
+
["approx", "≈"],
|
|
88
|
+
["le", "≤"],
|
|
89
|
+
["leq", "≤"],
|
|
90
|
+
["ge", "≥"],
|
|
91
|
+
["geq", "≥"],
|
|
92
|
+
["pm", "±"],
|
|
93
|
+
["sim", "∼"],
|
|
94
|
+
["cdot", "·"],
|
|
95
|
+
]);
|
|
96
|
+
|
|
42
97
|
/** Macros whose arguments are keys, labels, files or URLs — never text a reader sees. */
|
|
43
98
|
export const KEY_SIGNATURES: Readonly<
|
|
44
99
|
Record<string, { readonly signature: string }>
|
|
@@ -117,9 +172,15 @@ export const DEFINITION_MACROS: ReadonlySet<string> = new Set([
|
|
|
117
172
|
"xdef",
|
|
118
173
|
]);
|
|
119
174
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
175
|
+
/** The TeX primitives that define a macro: `\\def\\x{…}` and its kin. */
|
|
176
|
+
export const DEF_MACROS: ReadonlySet<string> = new Set([
|
|
177
|
+
"def",
|
|
178
|
+
"gdef",
|
|
179
|
+
"edef",
|
|
180
|
+
"xdef",
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
const DEF_SIGNATURES = Object.fromEntries(signed([...DEF_MACROS], "m m"));
|
|
123
184
|
|
|
124
185
|
// Not exported: a `ParsedTex` carries this property, and the one way to write it is `parseLatex`.
|
|
125
186
|
const PARSED = Symbol("ParsedTex");
|
package/src/cli.test.ts
CHANGED
|
@@ -789,17 +789,27 @@ const submissionPaper = (dir: string, site: string): void => {
|
|
|
789
789
|
});
|
|
790
790
|
};
|
|
791
791
|
|
|
792
|
-
test("🔴 submission: without
|
|
792
|
+
test("🔴 submission: without the site's token variable it names it and asks the portal nothing", async () => {
|
|
793
793
|
const dir = join(root, "submission-no-token");
|
|
794
794
|
submissionPaper(dir, "http://127.0.0.1:9");
|
|
795
|
-
const saved =
|
|
795
|
+
const saved = {
|
|
796
|
+
site: process.env["HOTCRP_TOKEN_127_0_0_1_9"],
|
|
797
|
+
plain: process.env["HOTCRP_TOKEN"],
|
|
798
|
+
};
|
|
799
|
+
delete process.env["HOTCRP_TOKEN_127_0_0_1_9"];
|
|
796
800
|
delete process.env["HOTCRP_TOKEN"];
|
|
797
801
|
try {
|
|
798
802
|
const r = await cli(["submission", "show", "papers/p"], dir);
|
|
799
803
|
assert.equal(r.code, 2);
|
|
800
|
-
assert.match(
|
|
804
|
+
assert.match(
|
|
805
|
+
r.err,
|
|
806
|
+
/^no hotcrp token for http:\/\/127\.0\.0\.1:9: HOTCRP_TOKEN_127_0_0_1_9 is not set$/m,
|
|
807
|
+
);
|
|
808
|
+
assert.match(r.err, /export HOTCRP_TOKEN_127_0_0_1_9=<the token>/);
|
|
801
809
|
} finally {
|
|
802
|
-
if (saved !== undefined)
|
|
810
|
+
if (saved.site !== undefined)
|
|
811
|
+
process.env["HOTCRP_TOKEN_127_0_0_1_9"] = saved.site;
|
|
812
|
+
if (saved.plain !== undefined) process.env["HOTCRP_TOKEN"] = saved.plain;
|
|
803
813
|
}
|
|
804
814
|
});
|
|
805
815
|
|
|
@@ -820,8 +830,10 @@ test("submission show: through the HotCRP adapter to a local portal, the token i
|
|
|
820
830
|
assert.ok(address !== null && typeof address === "object");
|
|
821
831
|
const dir = join(root, "submission-show");
|
|
822
832
|
submissionPaper(dir, `http://127.0.0.1:${String(address.port)}`);
|
|
823
|
-
|
|
824
|
-
|
|
833
|
+
// The site's variable carries its port: the server's, picked by the system.
|
|
834
|
+
const variable = `HOTCRP_TOKEN_127_0_0_1_${String(address.port)}`;
|
|
835
|
+
const saved = process.env[variable];
|
|
836
|
+
process.env[variable] = "hct_cli_test";
|
|
825
837
|
try {
|
|
826
838
|
const r = await cli(["submission", "show"], join(dir, "papers/p"));
|
|
827
839
|
assert.equal(r.code, 0, r.err);
|
|
@@ -835,8 +847,8 @@ test("submission show: through the HotCRP adapter to a local portal, the token i
|
|
|
835
847
|
assert.match(r.out, /^match {9}NO — the portal holds no PDF$/m);
|
|
836
848
|
assert.doesNotMatch(r.out + r.err, /hct_cli_test/);
|
|
837
849
|
} finally {
|
|
838
|
-
if (saved === undefined)
|
|
839
|
-
else process.env[
|
|
850
|
+
if (saved === undefined) Reflect.deleteProperty(process.env, variable);
|
|
851
|
+
else process.env[variable] = saved;
|
|
840
852
|
await new Promise<void>((r) => {
|
|
841
853
|
server.close(() => {
|
|
842
854
|
r();
|
package/src/cli.ts
CHANGED
|
@@ -100,10 +100,10 @@ import { texOutput } from "./adapters/tex-output/index.ts";
|
|
|
100
100
|
import { BIB_RULE_LEVELS, bibRules } from "./bib-rules.ts";
|
|
101
101
|
import { bibliographyReader } from "./references.ts";
|
|
102
102
|
import { onlineReferences } from "./adapters/references/index.ts";
|
|
103
|
-
import {
|
|
103
|
+
import { hotcrpSite } from "./adapters/hotcrp/index.ts";
|
|
104
104
|
import { runSubmission } from "./submission.ts";
|
|
105
105
|
import type { PortalKind, SupportedPortal } from "./domain/submission.ts";
|
|
106
|
-
import type {
|
|
106
|
+
import type { PortalSite } from "./ports/submission-portal.ts";
|
|
107
107
|
import type { CheckReferences } from "./ports/check-references.ts";
|
|
108
108
|
import {
|
|
109
109
|
narrowToOwners,
|
|
@@ -234,6 +234,11 @@ const USAGE = `paperlint — machine-checkable gates for a paper kept in git
|
|
|
234
234
|
into ~/.cache/paperlint/texlive (PAPERLINT_TEXLIVE_DIR overrides); a second
|
|
235
235
|
run does nothing. --check: report what is missing, change nothing
|
|
236
236
|
npx paperlint doctor say what is actually wired — and what only LOOKS wired
|
|
237
|
+
npx paperlint submission new [paper] [--abstract <file>] [--save]
|
|
238
|
+
create the paper's submission on the venue's portal: the title
|
|
239
|
+
and abstract from the build, the authors from paperlint.json,
|
|
240
|
+
the PDF. A DRY RUN unless --save; a save records the new id in
|
|
241
|
+
paperlint.json
|
|
237
242
|
npx paperlint submission show [paper]
|
|
238
243
|
the paper's submission on the venue's portal: status, title,
|
|
239
244
|
type, topics, abstract length, the PDF the portal holds, and
|
|
@@ -285,13 +290,18 @@ studies:
|
|
|
285
290
|
|
|
286
291
|
submission:
|
|
287
292
|
The venue preset declares the portal — "portal": { "kind": "hotcrp", "url": "<site>" } — and the
|
|
288
|
-
paper's paperlint.json its submission there — "submission": { "id": <number> }
|
|
289
|
-
|
|
293
|
+
paper's paperlint.json its submission there — "submission": { "id": <number> }, written by new
|
|
294
|
+
— and, for new, its "authors": [{ "name", "email", "affiliation"? }]. The token comes only from
|
|
295
|
+
the environment, one variable per site: HOTCRP_TOKEN_<subdomain> on *.hotcrp.com, else
|
|
296
|
+
HOTCRP_TOKEN_<host and path> — e.g. HOTCRP_TOKEN_MSR2027 for msr2027.hotcrp.com,
|
|
297
|
+
HOTCRP_TOKEN_AIDC_SUBMIT_ACSAC_ORG for aidc.submit.acsac.org (HotCRP: Account settings →
|
|
298
|
+
Developer). A plain HOTCRP_TOKEN is not read.
|
|
290
299
|
[paper] the paper's folder; default the current directory
|
|
291
300
|
--pdf <file> the PDF to compare (show) or send (update) instead of the paper's own
|
|
292
|
-
--abstract <file> update: a plain-text file whose text
|
|
301
|
+
--abstract <file> new, update: a plain-text file whose text is sent as the abstract
|
|
293
302
|
--submit update: mark the submission submitted
|
|
294
|
-
--save update: really change the submission. Without it, nothing
|
|
303
|
+
--save new, update: really create or change the submission. Without it, nothing
|
|
304
|
+
is saved
|
|
295
305
|
|
|
296
306
|
lint:
|
|
297
307
|
npx paperlint lint [paths…] [--fix] [--config <file.json>] [--json]
|
|
@@ -1737,7 +1747,9 @@ const SIMPLE: Readonly<
|
|
|
1737
1747
|
presets: PRESET_DEPS,
|
|
1738
1748
|
cwd,
|
|
1739
1749
|
env: (name) => process.env[name],
|
|
1740
|
-
|
|
1750
|
+
site: portalSite,
|
|
1751
|
+
latex: latexReader,
|
|
1752
|
+
codec: sourcesCodec,
|
|
1741
1753
|
log,
|
|
1742
1754
|
err,
|
|
1743
1755
|
},
|
|
@@ -1745,13 +1757,10 @@ const SIMPLE: Readonly<
|
|
|
1745
1757
|
};
|
|
1746
1758
|
|
|
1747
1759
|
/** The adapter of each portal kind — one per kind, chosen here at the root. */
|
|
1748
|
-
const PORTALS: Readonly<
|
|
1749
|
-
|
|
1750
|
-
> = {
|
|
1751
|
-
hotcrp: (url, token) => hotcrpPortal({ url, token }),
|
|
1760
|
+
const PORTALS: Readonly<Record<PortalKind, (url: string) => PortalSite>> = {
|
|
1761
|
+
hotcrp: hotcrpSite,
|
|
1752
1762
|
};
|
|
1753
|
-
const
|
|
1754
|
-
PORTALS[p.kind](p.url, token);
|
|
1763
|
+
const portalSite = (p: SupportedPortal): PortalSite => PORTALS[p.kind](p.url);
|
|
1755
1764
|
|
|
1756
1765
|
/** banal's installer, wired from this process's environment: the composition root's work. */
|
|
1757
1766
|
function hostBanalInstaller(): ToolInstaller {
|
package/src/cycle-rules.test.ts
CHANGED
|
@@ -155,8 +155,8 @@ describe("cycle/record", () => {
|
|
|
155
155
|
|
|
156
156
|
describe("cycle/record — the deadlines, over the venue preset's readings", () => {
|
|
157
157
|
it("MSR 2027 as a newcomer records the call: abstract → registration, paper → submission; the preset's portal readings are derived — silent", () => {
|
|
158
|
-
// The portal's submission (2026-10-
|
|
159
|
-
// registration (
|
|
158
|
+
// The portal's submission (2026-10-21T11:59:59Z, from the preset) is the end of the call's
|
|
159
|
+
// registration day (2026-10-20 AoE), before the call's submission: no contradiction.
|
|
160
160
|
const fs = lint({
|
|
161
161
|
cycles: [
|
|
162
162
|
msr([
|
|
@@ -185,7 +185,7 @@ describe("cycle/record — the deadlines, over the venue preset's readings", ()
|
|
|
185
185
|
});
|
|
186
186
|
expect(fs.map((f) => f.messageId)).toEqual(["order"]);
|
|
187
187
|
expect(fs[0]?.message).toBe(
|
|
188
|
-
'paperlint.json, cycle «msr-2027»: the call\'s "registration" (2026-10-26T11:59:59Z) is after its "submission" (2026-10-24T11:59:59Z) — a date typed wrong, or an AoE day miscounted (write a call\'s date as "YYYY-MM-DD AoE" and paperlint converts it)',
|
|
188
|
+
'paperlint.json, cycle «msr-2027»: the call\'s "registration" (2026-10-26T11:59:59Z, the call\'s reading on 2026-10-05 from https://2027.msrconf.org/track/msr-2027-technical-papers) is after its "submission" (2026-10-24T11:59:59Z, the call\'s reading on 2026-10-05 from https://2027.msrconf.org/track/msr-2027-technical-papers) — a date typed wrong, or an AoE day miscounted (write a call\'s date as "YYYY-MM-DD AoE" and paperlint converts it)',
|
|
189
189
|
);
|
|
190
190
|
});
|
|
191
191
|
});
|
|
@@ -199,10 +199,10 @@ describe("cycle/record — a portal reading beside the preset's", () => {
|
|
|
199
199
|
what: "submission",
|
|
200
200
|
observed: [
|
|
201
201
|
{
|
|
202
|
-
at: "2026-10-
|
|
202
|
+
at: "2026-10-21T11:59:59Z",
|
|
203
203
|
source: "portal",
|
|
204
204
|
url: "https://msr2027.hotcrp.com/deadlines",
|
|
205
|
-
read: "2026-10-
|
|
205
|
+
read: "2026-10-19",
|
|
206
206
|
},
|
|
207
207
|
],
|
|
208
208
|
},
|
|
@@ -210,7 +210,7 @@ describe("cycle/record — a portal reading beside the preset's", () => {
|
|
|
210
210
|
],
|
|
211
211
|
});
|
|
212
212
|
expect(fs.map((f) => f.message)).toEqual([
|
|
213
|
-
"paperlint.json, cycle «msr-2027»: the \"submission\" deadline records a portal reading, and the preset paperlint:msr carries the portal's reading
|
|
213
|
+
"paperlint.json, cycle «msr-2027»: the \"submission\" deadline records a portal reading, and the preset paperlint:msr carries it (2026-10-21T11:59:59Z, the portal's reading on 2026-10-19 from https://msr2027.hotcrp.com/deadlines — venues move dates: re-check there before relying on it) — a second copy drifts when paperlint updates the preset: delete this one (the call's reading and an override stay)",
|
|
214
214
|
]);
|
|
215
215
|
});
|
|
216
216
|
|
package/src/cycle-rules.ts
CHANGED
|
@@ -41,7 +41,11 @@ import {
|
|
|
41
41
|
type Cycle,
|
|
42
42
|
type Cycles,
|
|
43
43
|
} from "./domain/cycle.ts";
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
deadlineOrderProblems,
|
|
46
|
+
readingText,
|
|
47
|
+
type Reading,
|
|
48
|
+
} from "./domain/deadline.ts";
|
|
45
49
|
import { resolvePreset } from "./presets.ts";
|
|
46
50
|
import { fieldOf } from "./domain/record.ts";
|
|
47
51
|
import { err, ok, type Result } from "./domain/result.ts";
|
|
@@ -104,8 +108,7 @@ function presetCopies(c: Cycle, preset: PresetOfCycle): readonly Finding[] {
|
|
|
104
108
|
id: c.id,
|
|
105
109
|
what: d.what,
|
|
106
110
|
preset: preset.spec,
|
|
107
|
-
|
|
108
|
-
read: theirs.read,
|
|
111
|
+
reading: readingText(theirs),
|
|
109
112
|
},
|
|
110
113
|
},
|
|
111
114
|
]
|
|
@@ -190,7 +193,7 @@ const META: Readonly<Record<CycleRuleName, FolderRuleModule["meta"]>> = {
|
|
|
190
193
|
messages: {
|
|
191
194
|
broken: `${CONFIG_FILE}: {{why}}`,
|
|
192
195
|
order: `${CONFIG_FILE}, cycle «{{id}}»: {{why}} — a date typed wrong, or an AoE day miscounted (write a call's date as "YYYY-MM-DD AoE" and paperlint converts it)`,
|
|
193
|
-
presetCopy: `${CONFIG_FILE}, cycle «{{id}}»: the "{{what}}" deadline records a portal reading, and the preset {{preset}} carries
|
|
196
|
+
presetCopy: `${CONFIG_FILE}, cycle «{{id}}»: the "{{what}}" deadline records a portal reading, and the preset {{preset}} carries it ({{reading}}) — a second copy drifts when paperlint updates the preset: delete this one (the call's reading and an override stay)`,
|
|
194
197
|
},
|
|
195
198
|
},
|
|
196
199
|
evidence: {
|