paperlint 4.0.0 → 4.1.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 (172) hide show
  1. package/.github/workflows/ci.yml +16 -23
  2. package/CLAUDE.md +31 -11
  3. package/CONTRIBUTING.md +23 -7
  4. package/README.md +11 -8
  5. package/dist/adapters/banal/invocation.d.ts +1 -1
  6. package/dist/adapters/latex/document-class.d.ts +22 -0
  7. package/dist/adapters/latex/document-class.d.ts.map +1 -0
  8. package/dist/adapters/latex/document-class.js +102 -0
  9. package/dist/adapters/latex/document-class.js.map +1 -0
  10. package/dist/adapters/latex/hidden.d.ts +16 -0
  11. package/dist/adapters/latex/hidden.d.ts.map +1 -0
  12. package/dist/adapters/latex/hidden.js +49 -0
  13. package/dist/adapters/latex/hidden.js.map +1 -0
  14. package/dist/adapters/latex/index.d.ts +29 -0
  15. package/dist/adapters/latex/index.d.ts.map +1 -0
  16. package/dist/adapters/latex/index.js +18 -0
  17. package/dist/adapters/latex/index.js.map +1 -0
  18. package/dist/adapters/latex/nodes.d.ts +54 -0
  19. package/dist/adapters/latex/nodes.d.ts.map +1 -0
  20. package/dist/adapters/latex/nodes.js +93 -0
  21. package/dist/adapters/latex/nodes.js.map +1 -0
  22. package/dist/adapters/latex/outline.d.ts +10 -0
  23. package/dist/adapters/latex/outline.d.ts.map +1 -0
  24. package/dist/adapters/latex/outline.js +39 -0
  25. package/dist/adapters/latex/outline.js.map +1 -0
  26. package/dist/adapters/latex/parse.d.ts +42 -0
  27. package/dist/adapters/latex/parse.d.ts.map +1 -0
  28. package/dist/adapters/latex/parse.js +94 -0
  29. package/dist/adapters/latex/parse.js.map +1 -0
  30. package/dist/adapters/latex/rendered.d.ts +10 -0
  31. package/dist/adapters/latex/rendered.d.ts.map +1 -0
  32. package/dist/adapters/latex/rendered.js +39 -0
  33. package/dist/adapters/latex/rendered.js.map +1 -0
  34. package/dist/adapters/pdfjs/fill.d.ts.map +1 -1
  35. package/dist/adapters/pdfjs/fill.js +12 -12
  36. package/dist/adapters/pdfjs/fill.js.map +1 -1
  37. package/dist/build.js +4 -4
  38. package/dist/build.js.map +1 -1
  39. package/dist/cli.d.ts.map +1 -1
  40. package/dist/cli.js +29 -5
  41. package/dist/cli.js.map +1 -1
  42. package/dist/domain/tex-document.d.ts +84 -0
  43. package/dist/domain/tex-document.d.ts.map +1 -0
  44. package/dist/domain/tex-document.js +43 -0
  45. package/dist/domain/tex-document.js.map +1 -0
  46. package/dist/facts-file.d.ts.map +1 -1
  47. package/dist/facts-file.js +2 -2
  48. package/dist/facts-file.js.map +1 -1
  49. package/dist/new-paper.d.ts +5 -0
  50. package/dist/new-paper.d.ts.map +1 -1
  51. package/dist/new-paper.js +3 -0
  52. package/dist/new-paper.js.map +1 -1
  53. package/dist/package-dirs.d.ts +5 -0
  54. package/dist/package-dirs.d.ts.map +1 -0
  55. package/dist/package-dirs.js +14 -0
  56. package/dist/package-dirs.js.map +1 -0
  57. package/dist/ports/latex.d.ts +24 -0
  58. package/dist/ports/latex.d.ts.map +1 -0
  59. package/dist/ports/latex.js +2 -0
  60. package/dist/ports/latex.js.map +1 -0
  61. package/dist/presets.d.ts +15 -2
  62. package/dist/presets.d.ts.map +1 -1
  63. package/dist/presets.js +19 -6
  64. package/dist/presets.js.map +1 -1
  65. package/dist/tex-requirements.d.ts +11 -0
  66. package/dist/tex-requirements.d.ts.map +1 -1
  67. package/dist/tex-requirements.js +14 -8
  68. package/dist/tex-requirements.js.map +1 -1
  69. package/dist/tex-venue-rules.d.ts +83 -0
  70. package/dist/tex-venue-rules.d.ts.map +1 -0
  71. package/dist/tex-venue-rules.js +254 -0
  72. package/dist/tex-venue-rules.js.map +1 -0
  73. package/dist/venue-rules.d.ts +1 -1
  74. package/dist/venue-rules.d.ts.map +1 -1
  75. package/docs/configuration.md +3 -2
  76. package/docs/e2e.md +69 -40
  77. package/docs/install.md +1 -1
  78. package/docs/prior-art/README.md +1 -1
  79. package/docs/prior-art/package-location.md +5 -5
  80. package/docs/prior-art/repro/README.md +1 -1
  81. package/docs/prior-art/test-tooling.md +21 -10
  82. package/docs/rules/tex/required-section.md +73 -0
  83. package/docs/rules/tex/template.md +62 -0
  84. package/docs/rules/tex/venue-leftover.md +71 -0
  85. package/docs/rules.md +70 -48
  86. package/docs/testing.md +17 -4
  87. package/docs/texlive-install-decision.md +1 -1
  88. package/docs/toolchain.md +2 -2
  89. package/eslint.config.mjs +155 -15
  90. package/fixtures/build-e2e/acmart/expect.json +26 -0
  91. package/fixtures/build-e2e/aidc/PIPELINE-STATUS.md +3 -0
  92. package/fixtures/build-e2e/aidc/expect.json +14 -0
  93. package/fixtures/build-e2e/aidc/paper.tex +46 -0
  94. package/fixtures/build-e2e/aidc/paperlint.json +1 -0
  95. package/fixtures/build-e2e/broken/expect.json +11 -0
  96. package/fixtures/build-e2e/cite/expect.json +27 -0
  97. package/fixtures/build-e2e/empty/expect.json +12 -0
  98. package/fixtures/build-e2e/fallback/expect.json +53 -0
  99. package/fixtures/build-e2e/guards/expect.json +6 -0
  100. package/fixtures/build-e2e/no-source/expect.json +10 -0
  101. package/fixtures/build-e2e/unbalanced/expect.json +60 -0
  102. package/fixtures/pdf-facts/README.md +1 -1
  103. package/fixtures/real-markdown-paper/baseline.ts +1 -1
  104. package/fixtures/render-paper/build-clean.sh +3 -5
  105. package/package.json +13 -2
  106. package/{skills/submit-paper/references/venues → presets}/acm-sigconf.jsonc +4 -1
  107. package/{skills/submit-paper/references/venues → presets}/agenticdev.jsonc +4 -0
  108. package/presets/aidc.jsonc +73 -0
  109. package/{skills/submit-paper/references/venues → presets}/aisec.jsonc +4 -0
  110. package/presets/ieee-conference.jsonc +66 -0
  111. package/{skills/submit-paper/references/venues → presets}/realm.jsonc +8 -1
  112. package/{skills/submit-paper/references/venues → presets/tex}/paper-guards.tex +1 -1
  113. package/{skills/submit-paper/references/venues → presets}/venue-profile.schema.json +30 -2
  114. package/scripts/check.harness.ts +64 -10
  115. package/scripts/check.test.ts +60 -13
  116. package/scripts/check.ts +83 -30
  117. package/scripts/test.test.ts +1 -1
  118. package/scripts/test.ts +1 -1
  119. package/skills/paper-pipeline/PIPELINE-MAP.md +2 -2
  120. package/skills/paper-pipeline/SKILL.md +2 -2
  121. package/skills/paper-pipeline/SKILL.md.spec.ts +1 -1
  122. package/skills/paper-pipeline/scripts/consumer.d.mts +0 -2
  123. package/skills/paper-pipeline/scripts/consumer.mjs +1 -15
  124. package/skills/render-paper/SKILL.md +2 -2
  125. package/skills/render-paper/SKILL.md.spec.ts +1 -1
  126. package/skills/render-paper/check-render.sh +16 -63
  127. package/skills/render-paper/render-paper.harness.mjs +17 -59
  128. package/src/adapters/banal/index.test.ts +1 -1
  129. package/src/adapters/banal/invocation.ts +1 -1
  130. package/src/adapters/banal/output.test.ts +1 -1
  131. package/src/adapters/banal/run.test.ts +1 -1
  132. package/src/adapters/banal/xml.test.ts +1 -1
  133. package/src/adapters/latex/document-class.ts +147 -0
  134. package/src/adapters/latex/hidden.ts +70 -0
  135. package/src/adapters/latex/index.test.ts +361 -0
  136. package/src/adapters/latex/index.ts +55 -0
  137. package/src/adapters/latex/nodes.ts +141 -0
  138. package/src/adapters/latex/outline.ts +64 -0
  139. package/src/adapters/latex/parse.ts +136 -0
  140. package/src/adapters/latex/rendered.ts +59 -0
  141. package/src/adapters/pdfjs/fill.test.ts +1 -1
  142. package/src/adapters/pdfjs/fill.ts +18 -10
  143. package/src/build.harness.mjs +5 -7
  144. package/src/build.ts +4 -4
  145. package/src/cli.harness.mjs +1 -1
  146. package/src/cli.test.ts +2 -8
  147. package/src/cli.ts +33 -8
  148. package/src/domain/tex-document.test.ts +80 -0
  149. package/src/domain/tex-document.ts +110 -0
  150. package/src/engine.harness.mjs +1 -1
  151. package/src/facts-file.test.ts +4 -7
  152. package/src/facts-file.ts +2 -2
  153. package/src/latex-loop.harness.ts +1 -1
  154. package/src/new-paper.test.ts +28 -3
  155. package/src/new-paper.ts +8 -0
  156. package/src/package-dirs.ts +17 -0
  157. package/src/paper-settings-commands.test.ts +6 -1
  158. package/src/ports/latex.ts +29 -0
  159. package/src/presets.test.ts +65 -4
  160. package/src/presets.ts +38 -15
  161. package/src/rule-cases.test.ts +474 -0
  162. package/src/rule-docs.test.ts +159 -0
  163. package/src/tex-requirements.harness.ts +13 -23
  164. package/src/tex-requirements.ts +35 -8
  165. package/src/tex-venue-rules.test.ts +659 -0
  166. package/src/tex-venue-rules.ts +429 -0
  167. package/src/toolchain.harness.mjs +1 -1
  168. package/src/venue-rules.test.ts +96 -4
  169. package/src/venue-rules.ts +1 -1
  170. package/templates/paper/paper.tex +2 -1
  171. /package/{skills/submit-paper/references/venues → presets/tex}/agenticdev.tex +0 -0
  172. /package/{skills/submit-paper/references/venues → presets}/tex-base.jsonc +0 -0
@@ -19,7 +19,7 @@
19
19
  # vigiles lint . README.md 6 s
20
20
  # rules-see-files.mjs 5 s
21
21
  # layer-legacy-frozen.ts 3 s
22
- # install e2e --strict (npm + pnpm) 28 s
22
+ # npm run test:e2e:install (npm+pnpm) 38 s
23
23
  # ───────────────────────────────────────────
24
24
  # total work ~96 s, plus checkout + install + the claude binary
25
25
  #
@@ -178,10 +178,11 @@ jobs:
178
178
  run: corepack enable pnpm
179
179
  timeout-minutes: 2
180
180
 
181
- # Called directly with --strict, the same as the build e2e below. --strict: a manager that does not launch is a declared skip on a
182
- # contributor's clone and a FAILURE here, because in CI it means a broken environment.
183
- - name: install e2e (--strict)
184
- run: node test/e2e/install.ts --strict
181
+ # The vitest project `e2e-install`: pack, install under npm and pnpm, run the binary. A manager
182
+ # that does not launch is a skip on a contributor's clone and a FAILURE here, because `CI` is set
183
+ # and in CI it means a broken environment (test/e2e/need.ts).
184
+ - name: npm run test:e2e:install
185
+ run: npm run test:e2e:install
185
186
  timeout-minutes: 10
186
187
 
187
188
  # ── BUILDING THE PAPER WITH REAL pdflatex, ON LINUX AND macOS ──────────────────────────────────
@@ -199,7 +200,7 @@ jobs:
199
200
  # 🔴 WHY ON EVERY PUSH. It catches silent font substitution — a class that HAS ALREADY shipped a
200
201
  # paper typeset in the wrong font. This repository is public, so the macOS minutes are free.
201
202
  #
202
- # `--strict`: absence of TeX locally is a legitimate skip; here it is an environment failure.
203
+ # `CI` is set: absence of TeX locally is a legitimate skip; here it is an environment failure.
203
204
  build-e2e:
204
205
  if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
205
206
  strategy:
@@ -258,7 +259,7 @@ jobs:
258
259
  uses: actions/cache@v6
259
260
  with:
260
261
  path: ~/.cache/paperlint-texlive
261
- key: texlive-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('skills/submit-paper/references/venues/*.jsonc') }}
262
+ key: texlive-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('presets/*.jsonc') }}
262
263
 
263
264
  # The same command a user runs. On a cache hit it verifies and says "nothing to do"; on a miss
264
265
  # it installs from an empty directory and verifies every declared file with kpsewhich.
@@ -271,19 +272,11 @@ jobs:
271
272
  run: node bin/paperlint.mjs toolchain
272
273
  timeout-minutes: 15
273
274
 
274
- # Proves banal works without poppler. This runner has no poppler, and the test also limits
275
- # PATH to perl. paperlint turns each fixture PDF into XML with pdf.js, banal measures it, and the
276
- # result must equal the numbers banal gave on the same PDFs through poppler's pdftohtml
277
- # (recorded once, hardcoded in the test). Runs in seconds, hence the short timeout.
278
- - name: banal e2e (--strict)
279
- run: node test/e2e/banal.ts --strict
280
- timeout-minutes: 3
281
-
282
- # Called directly with --strict (see the install e2e step in the `gates` job).
283
- - name: build e2e (--strict)
284
- run: node test/e2e/build.ts --strict
285
- timeout-minutes: 10
286
-
287
- - name: toolchain e2e (--strict)
288
- run: node test/e2e/toolchain.ts --strict
289
- timeout-minutes: 10
275
+ # Every e2e test under test/e2e/tex/, found by the vitest project `e2e-tex`: the toolchain again
276
+ # (a no-op on the tree above, then a build with only it on PATH), the real banal on the XML
277
+ # paperlint writes (no poppler on this runner), and a real pdflatex build of every fixture in
278
+ # fixtures/build-e2e/, each against its own expect.json. `CI` is set on every runner, so a
279
+ # missing TeX Live or banal FAILS here instead of skipping (test/e2e/need.ts).
280
+ - name: npm run test:e2e:tex
281
+ run: npm run test:e2e:tex
282
+ timeout-minutes: 20
package/CLAUDE.md CHANGED
@@ -77,6 +77,13 @@ and stay QUIET on a clean fixture. A check that has only been seen quiet is
77
77
  indistinguishable from a dead one — silence is its success state. Prove the fire half by
78
78
  seeing the test go RED before the fix lands ([`docs/testing.md`](docs/testing.md)).
79
79
 
80
+ **A new rule ships with its page**, `docs/rules/<group>/<rule>.md`, in these sections: What it
81
+ catches · Why · Examples (failing / passing) · Options / preset fields · What it does not check ·
82
+ How to fix. Its `meta.docs.url` points at that page, and its row in `docs/rules.md` is one line
83
+ linking there. `src/rule-docs.test.ts` holds every rule the config registers to this; the rules
84
+ older than the convention wait in its `AWAITING_PAGE` list, which only shrinks — #131 writes their
85
+ pages.
86
+
80
87
  **4. `exit 0` with empty output is NOT "clean".** A rule whose glob matched no files reports
81
88
  exactly like a rule that passed. Any rule shipped here must be loud when its input set is
82
89
  empty. This is the specific defect that blocks stage 1 of the plan: in the source base a
@@ -150,13 +157,15 @@ Four proposals were made and withdrawn in one session on 2026-09-17 for exactly
150
157
 
151
158
  **10. Effects live in adapters, and WHERE paperlint IS INSTALLED lives in ONE of them.** Rule 6 generalised: the caller's cwd is one case of it. Checking logic — lint rules,
152
159
  skills, hooks — must not know its own location, nor its distance from anything else. Every
153
- answer to _where_ comes from `skills/paper-pipeline/scripts/consumer.mjs`, which adapts per
154
- channel: own checkout · `node_modules` · plugin cache · CI. A skill naming a script by an
155
- install-specific path in its own prose walks around that door, and 208 such literals across 190
156
- lines do exactly that.
160
+ answer to _where_ comes from one of two modules, each for one side: the consumer (its root, the
161
+ package's name) from `skills/paper-pipeline/scripts/consumer.mjs`, which adapts per channel — own
162
+ checkout · `node_modules` · plugin cache · CI; the package's own data (`presets/`, `presets/tex/`)
163
+ from `src/package-dirs.ts`. A skill naming a script by an install-specific path in its own prose
164
+ walks around that door, and 208 such literals across 190 lines do exactly that.
157
165
 
158
- <!-- The port's path above is resolved by `npm run check` (vigiles lint), since #67. -->
166
+ <!-- The ports' paths above are resolved by `npm run check` (vigiles lint), since #67. -->
159
167
  <!-- vigiles:file skills/paper-pipeline/scripts/consumer.mjs -->
168
+ <!-- vigiles:file src/package-dirs.ts -->
160
169
 
161
170
  The layer rules for `src/` live in [`src/CLAUDE.md`](src/CLAUDE.md) and are enforced by the linter.
162
171
 
@@ -493,18 +502,29 @@ justified two hundred lines above precisely by these minutes being free.
493
502
 
494
503
  ## Testing
495
504
 
496
- | you are testing | kind |
497
- | -------------------------------------------------------------------------- | --------------------------------------------- |
498
- | a pure function | unit — vitest, `<module>.test.ts` beside it |
499
- | a use case or adapter that reaches disk, a process, the network, the clock | integration — vitest, fakes through the ports |
500
- | a hook's decision, a skill's contract | harness — vigiles, `<surface>.harness.ts` |
501
- | the installed package, a real TeX build | e2e — `test/e2e/*.ts` |
505
+ | you are testing | kind |
506
+ | -------------------------------------------------------------------------- | ----------------------------------------------------------- |
507
+ | a pure function | unit — vitest, `<module>.test.ts` beside it |
508
+ | a use case or adapter that reaches disk, a process, the network, the clock | integration — vitest, fakes through the ports |
509
+ | a hook's decision, a skill's contract | harness — vigiles, `<surface>.harness.ts` |
510
+ | the installed package, a real TeX build | e2e — `test/e2e/<area>/*.e2e.ts`, `npm run test:e2e:<area>` |
502
511
 
503
512
  Red first · assert the whole value · test what the code does, never what its source says · no test
504
513
  touches the real network · 100% coverage, no `c8 ignore`. **Before every push: `npm run check`,
505
514
  exit code read without a pipe.** Everything else — where files live, how fakes are injected, the
506
515
  `--min=1` trap: [`docs/testing.md`](docs/testing.md).
507
516
 
517
+ **A new rule** needs unit tests beside it and a reporting and a silent case in
518
+ `src/rule-cases.test.ts`, which runs every registered rule through real ESLint and fails on one
519
+ without cases. An e2e fixture only when [`docs/e2e.md`](docs/e2e.md)'s triggers say so.
520
+
521
+ **New code is functional.** In `src/`, `eslint-rules/` and `lib/` (tests aside) there is no
522
+ `let`, no mutation, no loop, and types are read-only (`eslint-plugin-functional`); a `switch` over a
523
+ union names every member. Collections go through [Remeda](https://remedajs.com/) — `lodash`,
524
+ `lodash-es` and `ramda` are refused by `npm run lint`. Old code is listed in
525
+ `eslint-suppressions.json`, ESLint's own bulk suppressions, which may only shrink: fixing a listed
526
+ site without `npx eslint . --prune-suppressions` fails lint, and #134 burns the list down.
527
+
508
528
  ## Commits
509
529
 
510
530
  Conventional-commit subject, body says what was MEASURED, not what was intended. A number in
package/CONTRIBUTING.md CHANGED
@@ -37,12 +37,14 @@ install e2e under npm and pnpm, and a real `pdflatex` build — and ends
37
37
  by printing **which CI jobs it does not reproduce, and why**.
38
38
 
39
39
  🔴 **There is no `--fast` flag, and that is the point.** On 2026-09-19 a rule change was pushed
40
- that broke the suite: the gates were run afterwards and were green, but `npm test` and
41
- `test:install` were not among them, because there were eleven separate scripts and the only way
40
+ that broke the suite: the gates were run afterwards and were green, but `npm test` and the
41
+ install e2e were not among them, because there were eleven separate scripts and the only way
42
42
  to run them all was from memory. A subset flag re-creates exactly that — the cheap half gets run
43
43
  and reported as "the gates". If a step genuinely cannot run here, it says so out loud rather than
44
- being skipped quietly: an e2e that finds no TeX or no pnpm exits 77 _having stated_ why, and
45
- `npm run check` lists it as skipped instead of counting it as passed.
44
+ being skipped quietly: an e2e test that finds no TeX or no pnpm is reported SKIPPED by vitest,
45
+ and `npm run check` reads that count from vitest's JSON report and lists the gate as skipped
46
+ instead of counting it as passed. The e2e areas also run alone: `npm run test:e2e:install`,
47
+ `npm run test:e2e:tex`, or both with `npm run test:e2e`.
46
48
 
47
49
  Each gate's command is listed in `scripts/check.ts`; run one of them directly while iterating on
48
50
  one rule. They are not what you run before pushing.
@@ -75,6 +77,13 @@ Most of the package's rules run on users' papers and are described for users in
75
77
  [`docs/rules.md`](docs/rules.md); the rest lint this package's own source and never see a user's
76
78
  files.
77
79
 
80
+ A new rule ships with its page, `docs/rules/<group>/<rule>.md`, in these sections: What it
81
+ catches · Why · Examples (failing / passing) · Options / preset fields · What it does not check ·
82
+ How to fix. Its `meta.docs.url` points at that page, and its row in `docs/rules.md` is one line
83
+ linking there. `src/rule-docs.test.ts` holds every rule the config registers to this; the rules
84
+ older than the convention wait in its `AWAITING_PAGE` list, which only shrinks — #131 writes their
85
+ pages.
86
+
78
87
  ## Maintainer docs
79
88
 
80
89
  The README links only what a user needs. These are for people changing the package:
@@ -102,6 +111,13 @@ npm run coverage # the same, under c8, failing below the thresholds in .
102
111
  None of these are needed to USE the tool — they are here because the gates are part of the
103
112
  argument, not decoration.
104
113
 
114
+ **New code is functional.** In `src/`, `eslint-rules/` and `lib/` (tests aside) there is no
115
+ `let`, no mutation, no loop, and types are read-only (`eslint-plugin-functional`); a `switch` over a
116
+ union names every member. Collections go through [Remeda](https://remedajs.com/) — `lodash`,
117
+ `lodash-es` and `ramda` are refused by `npm run lint`. Old code is listed in
118
+ `eslint-suppressions.json`, ESLint's own bulk suppressions, which may only shrink: fixing a listed
119
+ site without `npx eslint . --prune-suppressions` fails lint, and #134 burns the list down.
120
+
105
121
  New code is TypeScript (#78). The last block of [`eslint.config.mjs`](eslint.config.mjs) makes any
106
122
  `.js`, `.mjs` or `.cjs` file an error in the directories already converted (`TYPESCRIPT_ONLY`), so
107
123
  `npm run lint` fails on one; a directory that still mixes the two is not listed yet, and the change
@@ -139,17 +155,17 @@ change to `.c8rc.json`'s exclude list that was not made there on purpose.
139
155
 
140
156
  ## Adding a venue
141
157
 
142
- A venue is a **preset**, a JSONC file in `skills/submit-paper/references/venues/`, validated by
158
+ A venue is a **preset**, a JSONC file in `presets/`, validated by
143
159
  `venue-profile.schema.json` beside it. Adding one is three files and no code:
144
160
 
145
- 1. **The preset, thin.** `venues/<name>.jsonc` extends the template family it is built on
161
+ 1. **The preset, thin.** `presets/<name>.jsonc` extends the template family it is built on
146
162
  (`"extends": "paperlint:acm-sigconf"` for an ACM venue) and adds only what the call for papers
147
163
  sets: `format.kinds` (the page limit of each kind of paper) and, when the venue's producer asks
148
164
  for something an optional rule checks, `rules`. Every number carries the quote it came from.
149
165
  A venue on a template with no family yet stands alone (`template`, `tex`, `format`) — or, better,
150
166
  add the family first: measured on a real template build (banal + pdf.js), not copied from
151
167
  documentation ([#88](https://github.com/zernie/paperlint/issues/88)).
152
- 2. **The card.** `venues/<name>.md` — prose about the venue: deadlines, tracks, the blind model,
168
+ 2. **The card.** `skills/submit-paper/references/venues/<name>.md` — prose about the venue: deadlines, tracks, the blind model,
153
169
  what the form asks.
154
170
  3. **A test.** A case in `src/presets.test.ts` that `paperlint:<name>` resolves over its family with
155
171
  the kinds you declared; `src/tex-requirements.harness.ts` already checks every shipped preset
package/README.md CHANGED
@@ -69,14 +69,17 @@ build: compiles and measures the PDF; lint then checks pages, fonts, references
69
69
  A **venue preset** holds a venue's format and page limits. A paper's **kind** picks which limit
70
70
  applies: at AgenticDev a `short` paper gets 5 pages and a `full` one 10. You choose it once per paper.
71
71
 
72
- | preset | venue | format | kinds and page limits |
73
- | ----------------------- | ------------------ | ------------------ | ------------------------------------------------------------------------------------------- |
74
- | `paperlint:acm-sigconf` | any ACM conference | ACM two-column | no kinds: the format only, no page limit |
75
- | `paperlint:agenticdev` | AgenticDev @ ASE | ACM two-column | `short` 5, `full` 10, `demo` 5 pages, + 2 pages of references |
76
- | `paperlint:aisec` | AISec @ ACM CCS | ACM two-column | `research`, `benchmark`, `position`, `sok`: 10 pages + 2 pages of references |
77
- | `paperlint:realm` | REALM @ EMNLP | ACL two-column, A4 | `long` 8, `short` 4 — recorded, not checked ([why](docs/rules.md#checks-against-the-venue)) |
78
-
79
- Not shipped yet: IEEE, USENIX, NeurIPS, Springer, and ACL venues other than REALM.
72
+ | preset | venue | format | kinds and page limits |
73
+ | --------------------------- | ------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
74
+ | `paperlint:acm-sigconf` | any ACM conference | ACM two-column | no kinds: the format only, no page limit |
75
+ | `paperlint:agenticdev` | AgenticDev @ ASE | ACM two-column | `short` 5, `full` 10, `demo` 5 pages, + 2 pages of references |
76
+ | `paperlint:aisec` | AISec @ ACM CCS | ACM two-column | `research`, `benchmark`, `position`, `sok`: 10 pages + 2 pages of references |
77
+ | `paperlint:realm` | REALM @ EMNLP | ACL two-column, A4 | `long` 8, `short` 4 — recorded, not checked ([why](docs/rules.md#checks-against-the-venue)) |
78
+ | `paperlint:ieee-conference` | any IEEE conference | IEEE two-column | no kinds: the format only, no page limit |
79
+ | `paperlint:aidc` | AIDC @ IEEE ACSAC | IEEE two-column, `compsoc` | `regular` 12, `short` 6 — recorded, not checked ([why](docs/rules.md#checks-against-the-venue)); requires the «LLM Usage Statement» |
80
+
81
+ Not shipped yet: USENIX, NeurIPS, Springer, IEEE venues other than AIDC, and ACL venues other than
82
+ REALM.
80
83
  [Add yours](#-add-a-venue-that-isnt-listed) in one small file.
81
84
 
82
85
  ## 🚀 Getting started
@@ -7,7 +7,7 @@
7
7
  * (`Error: Failed to run pdftohtml`, measured); told a version below 0.85 it applies a larger
8
8
  * correction and every font size moves. So `$PDFTOHTML` (banal's own override, line 166) points at a
9
9
  * stub that answers `-v` with `XML_DIALECT.version` — the pdftohtml whose XML `xml.ts` writes — and
10
- * refuses anything else. `test/e2e/banal.ts` shows both failures with the real banal.
10
+ * refuses anything else. `test/e2e/tex/banal.e2e.ts` shows both failures with the real banal.
11
11
  */
12
12
  import type { Opaque } from "ts-essentials";
13
13
  import type { AbsolutePath } from "../../domain/paths.ts";
@@ -0,0 +1,22 @@
1
+ /** The paper's `\documentclass`, a preset's template, and setting a class in a source. */
2
+ import { type ClassLine, type DocumentClass } from "../../domain/tex-document.ts";
3
+ import { type ParsedTex } from "./parse.ts";
4
+ /**
5
+ * The first `\documentclass` at the top of the tree: missing; empty (`\documentclass{}`); or the
6
+ * class with each of its options as written (`foo={a,b}` stays one option, braces kept), whitespace
7
+ * collapsed. Its place spans the macro and its arguments.
8
+ */
9
+ export declare function documentClassOf(t: ParsedTex): ClassLine;
10
+ /**
11
+ * A preset's `template` → the class it names: a whole `\documentclass[…]{…}` line, or a bare class
12
+ * name (`article`), which names no option. Anything else is null.
13
+ */
14
+ export declare function parseTemplate(text: string): DocumentClass | null;
15
+ /**
16
+ * The source with its `\documentclass` line changed to satisfy `want` (see `venueClass`): another
17
+ * class is replaced by the template's line; the same class gains the options it lacks in place. A
18
+ * source whose class already satisfies `want`, or that has no class line the parser could place, is
19
+ * returned as it is.
20
+ */
21
+ export declare function replaceDocumentClass(t: ParsedTex, want: DocumentClass): string;
22
+ //# sourceMappingURL=document-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-class.d.ts","sourceRoot":"","sources":["../../../src/adapters/latex/document-class.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAUtC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAoDxD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAGvD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAShE;AA0BD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,SAAS,EACZ,IAAI,EAAE,aAAa,GAClB,MAAM,CAoBR"}
@@ -0,0 +1,102 @@
1
+ /** The paper's `\documentclass`, a preset's template, and setting a class in a source. */
2
+ import { documentClassLine, venueClass, } from "../../domain/tex-document.js";
3
+ import { collapse, macroPlace, mandatory, optional, textOf, } from "./nodes.js";
4
+ import { parseLatex } from "./parse.js";
5
+ const isDocumentClass = (n) => n.type === "macro" && n.content === "documentclass";
6
+ const isComma = (n) => n.type === "string" && n.content === ",";
7
+ /** Nodes split wherever `at` holds, the separators dropped: a comma inside braces is its group's. */
8
+ function splitWhere(nodes, at) {
9
+ const cuts = nodes.flatMap((n, i) => (at(n) ? [i] : []));
10
+ return [-1, ...cuts].map((from, k) => nodes.slice(from + 1, cuts[k] ?? nodes.length));
11
+ }
12
+ /** The source text a run of nodes spans; its markup-free text if unplaced. */
13
+ function sourceOf(src, nodes) {
14
+ const start = nodes[0]?.position?.start.offset;
15
+ const end = nodes.at(-1)?.position?.end.offset;
16
+ return start === undefined || end === undefined
17
+ ? textOf(nodes)
18
+ : src.slice(start, end);
19
+ }
20
+ /**
21
+ * One option as TeX reads it, whitespace collapsed. A line comment is not part of it, and it joins
22
+ * its two sides with no space: `foo=bar% note⏎baz` is `foo=barbaz`.
23
+ */
24
+ const optionText = (src, part) => collapse(splitWhere(part, (n) => n.type === "comment")
25
+ .map((run) => sourceOf(src, run))
26
+ .join(""));
27
+ const classNode = (t) => t.root.content.find(isDocumentClass);
28
+ /** A `\documentclass` node as a class line: empty, or the class with its options as read. */
29
+ function classLine(src, node) {
30
+ const place = macroPlace(node);
31
+ const cls = collapse(textOf(mandatory(node)[0]?.content));
32
+ if (cls === "")
33
+ return { kind: "empty", place };
34
+ const options = splitWhere(optional(node)?.content ?? [], isComma)
35
+ .map((part) => optionText(src, part))
36
+ .filter(Boolean);
37
+ return { kind: "class", cls, options, place };
38
+ }
39
+ /**
40
+ * The first `\documentclass` at the top of the tree: missing; empty (`\documentclass{}`); or the
41
+ * class with each of its options as written (`foo={a,b}` stays one option, braces kept), whitespace
42
+ * collapsed. Its place spans the macro and its arguments.
43
+ */
44
+ export function documentClassOf(t) {
45
+ const node = classNode(t);
46
+ return node === undefined ? { kind: "missing" } : classLine(t.src, node);
47
+ }
48
+ /**
49
+ * A preset's `template` → the class it names: a whole `\documentclass[…]{…}` line, or a bare class
50
+ * name (`article`), which names no option. Anything else is null.
51
+ */
52
+ export function parseTemplate(text) {
53
+ const t = parseLatex(text);
54
+ const [only, ...rest] = t.root.content.filter((n) => n.type !== "whitespace" && n.type !== "comment");
55
+ if (only === undefined || rest.length > 0)
56
+ return null;
57
+ const line = documentClassOf(t);
58
+ if (line.kind === "class")
59
+ return { cls: line.cls, options: line.options };
60
+ return only.type === "string" ? { cls: only.content, options: [] } : null;
61
+ }
62
+ /** `src` with `text` in place of `[from, to)`. */
63
+ const splice = (src, from, to, text) => src.slice(0, from) + text + src.slice(to);
64
+ /**
65
+ * `options` written into the class line's own source: before the `]` of its `[…]` — right after the
66
+ * last node inside, or right after the `[` when there is none — or as a new `[…]` after the name.
67
+ * The bytes between `[` and `]` stay as the author wrote them, comments and braces included.
68
+ */
69
+ function addOptions(src, node, line, options) {
70
+ const list = options.join(",");
71
+ const nameEnd = line.start + 1 + node.content.length; // `\` and the macro's name
72
+ const opt = optional(node);
73
+ if (opt === undefined)
74
+ return splice(src, nameEnd, nameEnd, `[${list}]`);
75
+ const close = opt.content.at(-1)?.position?.end.offset ?? src.indexOf("[", nameEnd) + 1;
76
+ return splice(src, close, close, line.empty ? list : `,${list}`);
77
+ }
78
+ /**
79
+ * The source with its `\documentclass` line changed to satisfy `want` (see `venueClass`): another
80
+ * class is replaced by the template's line; the same class gains the options it lacks in place. A
81
+ * source whose class already satisfies `want`, or that has no class line the parser could place, is
82
+ * returned as it is.
83
+ */
84
+ export function replaceDocumentClass(t, want) {
85
+ const node = classNode(t);
86
+ if (node === undefined)
87
+ return t.src;
88
+ const line = classLine(t.src, node);
89
+ if (line.kind !== "class" || line.place.kind === "unplaced")
90
+ return t.src;
91
+ const { start, end } = line.place.span;
92
+ const change = venueClass(line, want);
93
+ switch (change.kind) {
94
+ case "keep":
95
+ return t.src;
96
+ case "replace":
97
+ return splice(t.src, start, end, documentClassLine(change.by));
98
+ case "add":
99
+ return addOptions(t.src, node, { start, empty: line.options.length === 0 }, change.options);
100
+ }
101
+ }
102
+ //# sourceMappingURL=document-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-class.js","sourceRoot":"","sources":["../../../src/adapters/latex/document-class.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,EACL,iBAAiB,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AAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACvC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,CAAC,CAAC,GAAG,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QACjE,KAAK,KAAK;YACR,OAAO,UAAU,CACf,CAAC,CAAC,GAAG,EACL,IAAI,EACJ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,EAC3C,MAAM,CAAC,OAAO,CACf,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What a reader of the PDF never sees, as a walk over the tree prunes it: comments, math and code,
3
+ * the bibliography's body, and the arguments that are keys, labels, files or URLs. The rendered
4
+ * text and the outline both prune with it.
5
+ *
6
+ * A macro definition's body is NOT pruned here. It is text once the macro is used, and nothing here
7
+ * expands macros, so the rendered text reads the body where it is written — a definition naming
8
+ * another venue is a leftover whether it is used or not. The outline prunes it on top
9
+ * (`isDefinition`): a heading in a definition body is not a section where it is written.
10
+ */
11
+ import { type Visited } from "./nodes.ts";
12
+ /** Whether the walk prunes `v` (given the node that holds it): see the module comment. */
13
+ export declare const isUnrendered: (v: Visited, parent: Visited | undefined) => boolean;
14
+ /** A macro that defines another macro or an environment (`\newcommand`, `\def`, …). */
15
+ export declare const isDefinition: (v: Visited) => boolean;
16
+ //# sourceMappingURL=hidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hidden.d.ts","sourceRoot":"","sources":["../../../src/adapters/latex/hidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,YAAY,CAAC;AA4CpB,0FAA0F;AAC1F,eAAO,MAAM,YAAY,GACvB,GAAG,OAAO,EACV,QAAQ,OAAO,GAAG,SAAS,KAC1B,OACsE,CAAC;AAE1E,uFAAuF;AACvF,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,OAC2B,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * What a reader of the PDF never sees, as a walk over the tree prunes it: comments, math and code,
3
+ * the bibliography's body, and the arguments that are keys, labels, files or URLs. The rendered
4
+ * text and the outline both prune with it.
5
+ *
6
+ * A macro definition's body is NOT pruned here. It is text once the macro is used, and nothing here
7
+ * expands macros, so the rendered text reads the body where it is written — a definition naming
8
+ * another venue is a leftover whether it is used or not. The outline prunes it on top
9
+ * (`isDefinition`): a heading in a definition body is not a section where it is written.
10
+ */
11
+ import { isArgument, isNode, } from "./nodes.js";
12
+ import { DEFINITION_MACROS, KEY_ARGUMENT, KEY_SIGNATURES } from "./parse.js";
13
+ /** Environments whose body is not text a reader sees as prose: code, the bibliography, comments. */
14
+ const HIDDEN_ENVS = new Set([
15
+ "thebibliography",
16
+ "verbatim",
17
+ "Verbatim",
18
+ "lstlisting",
19
+ "minted",
20
+ "comment",
21
+ ]);
22
+ /** Node types a reader does not see as prose: comments, code, math. */
23
+ const HIDDEN_TYPES = new Set([
24
+ "comment",
25
+ "verbatim",
26
+ "verb",
27
+ "inlinemath",
28
+ "displaymath",
29
+ "mathenv",
30
+ ]);
31
+ const KEY_MACROS = new Set(Object.keys(KEY_SIGNATURES));
32
+ /** A key macro that prints none of its arguments (`\label`, `\url`, …). */
33
+ const isHiddenMacro = (name) => KEY_MACROS.has(name) && !KEY_ARGUMENT.has(name);
34
+ const isHiddenNode = (n) => HIDDEN_TYPES.has(n.type) ||
35
+ (n.type === "environment" && HIDDEN_ENVS.has(n.env)) ||
36
+ (n.type === "macro" && isHiddenMacro(n.content));
37
+ /**
38
+ * The one argument of a partly printed macro (`KEY_ARGUMENT`) that is a key or a URL. What holds an
39
+ * argument is a macro or an environment; the first three tests only narrow the type.
40
+ */
41
+ const isKeyArgument = (a, parent) => parent !== undefined &&
42
+ isNode(parent) &&
43
+ parent.type === "macro" &&
44
+ parent.args?.indexOf(a) === KEY_ARGUMENT.get(parent.content);
45
+ /** Whether the walk prunes `v` (given the node that holds it): see the module comment. */
46
+ export const isUnrendered = (v, parent) => isArgument(v) ? isKeyArgument(v, parent) : isNode(v) && isHiddenNode(v);
47
+ /** A macro that defines another macro or an environment (`\newcommand`, `\def`, …). */
48
+ export const isDefinition = (v) => isNode(v) && v.type === "macro" && DEFINITION_MACROS.has(v.content);
49
+ //# sourceMappingURL=hidden.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hidden.js","sourceRoot":"","sources":["../../../src/adapters/latex/hidden.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,MAAM,GAIP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7E,oGAAoG;AACpG,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC;IAC/C,iBAAiB;IACjB,UAAU;IACV,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;CACV,CAAC,CAAC;AAEH,uEAAuE;AACvE,MAAM,YAAY,GAA8B,IAAI,GAAG,CAAe;IACpE,SAAS;IACT,UAAU;IACV,MAAM;IACN,YAAY;IACZ,aAAa;IACb,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;AAE7E,2EAA2E;AAC3E,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAC9C,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAElD,MAAM,YAAY,GAAG,CAAC,CAAO,EAAW,EAAE,CACxC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACxB,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,aAAa,GAAG,CAAC,CAAW,EAAE,MAA2B,EAAW,EAAE,CAC1E,MAAM,KAAK,SAAS;IACpB,MAAM,CAAC,MAAM,CAAC;IACd,MAAM,CAAC,IAAI,KAAK,OAAO;IACvB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAE/D,0FAA0F;AAC1F,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,CAAU,EACV,MAA2B,EAClB,EAAE,CACX,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAE1E,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAAW,EAAE,CAClD,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Reads a paper.tex and answers three questions — checks nothing itself: `documentClassOf` (which
3
+ * class, with which options, and where), `outlineOf` (the sections in order, where the back matter
4
+ * starts, where the document ends) and `renderedRuns` (the text a reader sees, each character with
5
+ * its source offset). Used by `tex/template`, `tex/required-section`, `tex/venue-leftover` and
6
+ * `paperlint new`, through the `LatexReader` port (`src/ports/latex.ts`); `src/cli.ts` wires it.
7
+ *
8
+ * ── WHY THE PARSE TREE AND NOT THE `tex/latex` PROJECTION ────────────────────────
9
+ * The ESLint language's projection (`eslint-rules/latex-language.ts`) blanks the preamble,
10
+ * `\documentclass`, `\author` and every other macro in its OPAQUE list, because prose rules must
11
+ * not see markup. These questions are about exactly that markup: the class line, a `\section*`
12
+ * title, an `\institution{…}` in the author block. So the source is parsed here with unified-latex,
13
+ * the parser the language already uses.
14
+ *
15
+ * ── STATES, NOT NULL ─────────────────────────────────────────────────────────────
16
+ * A class line is missing, empty or a class; a node the parser gave no position is `unplaced`, not
17
+ * offset 0; a run of text is a non-empty list of contiguous segments, and a range outside it has
18
+ * no span (`spanIn` in `src/domain/tex-document.ts`). A tree travels only with its own source
19
+ * (`ParsedTex`, minted by `parseLatex` alone).
20
+ */
21
+ import type { LatexReader } from "../../ports/latex.ts";
22
+ export { documentClassOf, parseTemplate, replaceDocumentClass, } from "./document-class.ts";
23
+ export { collapse, macroPlace, mandatory, optional, placeOf, textOf, } from "./nodes.ts";
24
+ export { outlineOf } from "./outline.ts";
25
+ export { parseLatex, type ParsedTex } from "./parse.ts";
26
+ export { renderedRuns } from "./rendered.ts";
27
+ /** The `LatexReader` port over unified-latex: each call parses its source once. */
28
+ export declare const latexReader: LatexReader;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/latex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,OAAO,EACL,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,mFAAmF;AACnF,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { documentClassOf, parseTemplate, replaceDocumentClass, } from "./document-class.js";
2
+ import { outlineOf } from "./outline.js";
3
+ import { parseLatex } from "./parse.js";
4
+ import { renderedRuns } from "./rendered.js";
5
+ export { documentClassOf, parseTemplate, replaceDocumentClass, } from "./document-class.js";
6
+ export { collapse, macroPlace, mandatory, optional, placeOf, textOf, } from "./nodes.js";
7
+ export { outlineOf } from "./outline.js";
8
+ export { parseLatex } from "./parse.js";
9
+ export { renderedRuns } from "./rendered.js";
10
+ /** The `LatexReader` port over unified-latex: each call parses its source once. */
11
+ export const latexReader = {
12
+ documentClass: (src) => documentClassOf(parseLatex(src)),
13
+ outline: (src) => outlineOf(parseLatex(src)),
14
+ renderedRuns: (src) => renderedRuns(parseLatex(src)),
15
+ template: parseTemplate,
16
+ withDocumentClass: (src, want) => replaceDocumentClass(parseLatex(src), want),
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/latex/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACxD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5C,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpD,QAAQ,EAAE,aAAa;IACvB,iBAAiB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;CAC9E,CAAC"}
@@ -0,0 +1,54 @@
1
+ /** What the three readers share about unified-latex nodes: places, text, and the walk. */
2
+ import type * as Ast from "@unified-latex/unified-latex-types";
3
+ import type { Place } from "../../domain/tex-document.ts";
4
+ export { collapse } from "../../domain/tex-document.ts";
5
+ /** unified-latex's node types, read-only: nothing here writes to a tree. */
6
+ export type Node = Readonly<Ast.Node>;
7
+ export type Macro = Readonly<Ast.Macro>;
8
+ export type Argument = Readonly<Ast.Argument>;
9
+ /** Anything the parser may have given a position: offsets of its first and past its last character. */
10
+ interface Positioned {
11
+ readonly position?: {
12
+ readonly start: {
13
+ readonly offset: number;
14
+ };
15
+ readonly end: {
16
+ readonly offset: number;
17
+ };
18
+ };
19
+ }
20
+ /** Where a node stands, or that it has no position. */
21
+ export declare const placeOf: (n: Positioned) => Place;
22
+ /** The first mandatory (`{…}`) and optional (`[…]`) arguments' contents, and the last mandatory one's. */
23
+ export declare const mandatory: (m: Macro) => readonly Argument[];
24
+ export declare const optional: (m: Macro) => Argument | undefined;
25
+ /** What a string node reads as: itself, except a tie (`~`), which is a space the reader sees. */
26
+ export declare const stringText: (content: string) => string;
27
+ /**
28
+ * The text of a node list with markup dropped: strings, spaces, what groups hold, and the argument a
29
+ * formatting macro typesets — its last mandatory one (`\textbf{Usage}`, `\textcolor{red}{Usage}`,
30
+ * `\href{url}{Usage}` → `Usage`) unless `SHOWN_ARGUMENT` says otherwise. A key macro's arguments
31
+ * (`\label{…}`, `\cite{…}`) are not text.
32
+ */
33
+ export declare const textOf: (nodes: readonly Node[] | undefined) => string;
34
+ /**
35
+ * A macro's place with its arguments: from its name to past the closing mark of the last argument
36
+ * that holds text. unified-latex positions the name and the arguments' contents, never the
37
+ * arguments themselves, so an empty trailing argument is not covered.
38
+ */
39
+ export declare function macroPlace(m: Macro): Place;
40
+ /** What visit reaches: a node, an argument, or a node list (a content array, an argument list). */
41
+ export type Visited = Readonly<Ast.Ast> | readonly (Node | Argument)[];
42
+ /**
43
+ * Everything visit reaches under `tree`, in document order, node lists included; `skip` prunes what
44
+ * it is given (a node or an argument, with the node that holds it) and everything under it. visit
45
+ * reports through a callback and returns nothing, so the one collection point of this adapter is here.
46
+ */
47
+ export declare function visited(tree: Ast.Ast, skip: (v: Visited, parent: Visited | undefined) => boolean): readonly Visited[];
48
+ /** A node list visit reached. `Array.isArray` alone does not narrow a readonly array. */
49
+ export declare const isList: (v: Visited) => v is readonly (Node | Argument)[];
50
+ /** A macro's argument, as visit reports it. */
51
+ export declare const isArgument: (v: Visited) => v is Argument;
52
+ /** A node, as opposed to a node list or an argument (which visit also reports). */
53
+ export declare const isNode: (v: Visited) => v is Node;
54
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/adapters/latex/nodes.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