docrev 0.11.1 → 0.11.2

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 (116) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +202 -197
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +433 -433
  5. package/bin/rev.js +11 -11
  6. package/bin/rev.ts +145 -145
  7. package/completions/rev.bash +127 -127
  8. package/completions/rev.ps1 +210 -210
  9. package/completions/rev.zsh +207 -207
  10. package/dist/lib/build.d.ts +28 -0
  11. package/dist/lib/build.d.ts.map +1 -1
  12. package/dist/lib/build.js +81 -4
  13. package/dist/lib/build.js.map +1 -1
  14. package/dist/lib/commands/utilities.js +164 -164
  15. package/dist/lib/commands/word-tools.js +8 -8
  16. package/dist/lib/grammar.js +3 -3
  17. package/dist/lib/macro-filter.lua +201 -201
  18. package/dist/lib/pdf-comments.js +44 -44
  19. package/dist/lib/plugins.js +57 -57
  20. package/dist/lib/pptx-color-filter.lua +37 -37
  21. package/dist/lib/pptx-themes.js +115 -115
  22. package/dist/lib/schema.d.ts.map +1 -1
  23. package/dist/lib/schema.js +8 -2
  24. package/dist/lib/schema.js.map +1 -1
  25. package/dist/lib/spelling.js +2 -2
  26. package/dist/lib/templates.js +387 -387
  27. package/dist/lib/themes.js +51 -51
  28. package/eslint.config.js +27 -27
  29. package/lib/anchor-match.ts +307 -307
  30. package/lib/annotations.ts +664 -664
  31. package/lib/build.ts +2047 -1956
  32. package/lib/citations.ts +160 -160
  33. package/lib/commands/build.ts +885 -885
  34. package/lib/commands/citations.ts +515 -515
  35. package/lib/commands/comments.ts +1050 -1050
  36. package/lib/commands/context.ts +176 -176
  37. package/lib/commands/core.ts +309 -309
  38. package/lib/commands/doi.ts +451 -451
  39. package/lib/commands/file-ops.ts +372 -372
  40. package/lib/commands/history.ts +320 -320
  41. package/lib/commands/index.ts +87 -87
  42. package/lib/commands/init.ts +259 -259
  43. package/lib/commands/merge-resolve.ts +378 -378
  44. package/lib/commands/preview.ts +178 -178
  45. package/lib/commands/project-info.ts +244 -244
  46. package/lib/commands/quality.ts +517 -517
  47. package/lib/commands/response.ts +454 -454
  48. package/lib/commands/section-boundaries.ts +82 -82
  49. package/lib/commands/sections.ts +451 -451
  50. package/lib/commands/sync.ts +689 -689
  51. package/lib/commands/text-ops.ts +449 -449
  52. package/lib/commands/utilities.ts +448 -448
  53. package/lib/commands/verify-anchors.ts +272 -272
  54. package/lib/commands/word-tools.ts +340 -340
  55. package/lib/comment-realign.ts +99 -99
  56. package/lib/config.ts +84 -84
  57. package/lib/crossref.ts +781 -781
  58. package/lib/csl.ts +191 -191
  59. package/lib/dependencies.ts +132 -132
  60. package/lib/diff-engine.ts +465 -465
  61. package/lib/doi-cache.ts +115 -115
  62. package/lib/doi.ts +879 -879
  63. package/lib/equations.ts +506 -506
  64. package/lib/errors.ts +350 -350
  65. package/lib/format.ts +541 -541
  66. package/lib/git.ts +326 -326
  67. package/lib/grammar.ts +303 -303
  68. package/lib/image-registry.ts +180 -180
  69. package/lib/import.ts +906 -906
  70. package/lib/journals.ts +543 -543
  71. package/lib/macro-filter.lua +201 -201
  72. package/lib/macros.ts +273 -273
  73. package/lib/merge.ts +633 -633
  74. package/lib/ooxml.ts +768 -768
  75. package/lib/orcid.ts +144 -144
  76. package/lib/pdf-comments.ts +263 -263
  77. package/lib/pdf-import.ts +524 -524
  78. package/lib/plugins.ts +362 -362
  79. package/lib/postprocess.ts +188 -188
  80. package/lib/pptx-color-filter.lua +37 -37
  81. package/lib/pptx-template.ts +469 -469
  82. package/lib/pptx-themes.ts +483 -483
  83. package/lib/protect-restore.ts +520 -520
  84. package/lib/rate-limiter.ts +127 -127
  85. package/lib/response.ts +197 -197
  86. package/lib/restore-references.ts +240 -240
  87. package/lib/review.ts +327 -327
  88. package/lib/schema.ts +494 -488
  89. package/lib/scientific-words.ts +73 -73
  90. package/lib/sections.ts +428 -428
  91. package/lib/slides.ts +756 -756
  92. package/lib/spelling.ts +334 -334
  93. package/lib/templates.ts +526 -526
  94. package/lib/themes.ts +742 -742
  95. package/lib/trackchanges.ts +166 -166
  96. package/lib/tui.ts +450 -450
  97. package/lib/types.ts +546 -546
  98. package/lib/undo.ts +250 -250
  99. package/lib/utils.ts +69 -69
  100. package/lib/variables.ts +179 -179
  101. package/lib/word-extraction.ts +525 -525
  102. package/lib/word.ts +526 -526
  103. package/lib/wordcomments.ts +789 -789
  104. package/package.json +1 -1
  105. package/scripts/postbuild.js +47 -47
  106. package/skill/REFERENCE.md +550 -550
  107. package/skill/SKILL.md +302 -302
  108. package/tsconfig.json +26 -26
  109. package/types/index.d.ts +531 -531
  110. package/issues.md +0 -180
  111. package/site/assets/extra.css +0 -208
  112. package/site/commands.html +0 -926
  113. package/site/configuration.html +0 -469
  114. package/site/index.html +0 -288
  115. package/site/troubleshooting.html +0 -461
  116. package/site/workflow.html +0 -518
package/issues.md DELETED
@@ -1,180 +0,0 @@
1
- # docrev — Open Issues
2
-
3
- Three issues identified during real-world use on the ADAPT proposal build. Working through one by one.
4
-
5
- Status legend: `[ ]` planned · `[~]` in progress · `[x]` shipped
6
-
7
- ---
8
-
9
- ## Issue 1 — Allow custom pandoc filters / args through `rev build` `[x]`
10
-
11
- ### Problem
12
-
13
- Source markdown with custom raw-LaTeX commands needs a pandoc filter to convert them for docx (e.g. `\tofill{X}` → bold `[X]`). `rev build docx` has no escape hatch:
14
-
15
- - `rev build --help` exposes no `--filter` / `--lua-filter` / `--pandoc-arg`.
16
- - `rev.yaml` exposes `docx.reference` and `docx.keepComments` but no generic pandoc passthrough.
17
-
18
- Working around it requires letting `rev build` produce `paper.md` as a side effect, then calling pandoc manually — which defeats the point of `rev build`.
19
-
20
- ### Design (agreed)
21
-
22
- **rev.yaml**: top-level `pandoc-args` (applied to every format) plus per-format `<format>.pandoc-args` (concatenated *after* the top-level list so format-specific can override):
23
-
24
- ```yaml
25
- pandoc-args:
26
- - --lua-filter=tofill_filter.lua
27
- docx:
28
- pandoc-args:
29
- - --lua-filter=docx_only.lua
30
- pdf:
31
- pandoc-args:
32
- - --variable=papersize:a4
33
- ```
34
-
35
- **CLI**: repeatable `--pandoc-arg <arg>` on `rev build`, appended *after* config args so CLI wins:
36
-
37
- ```bash
38
- rev build docx --pandoc-arg=--lua-filter=tofill.lua --pandoc-arg=--shift-heading-level-by=1
39
- ```
40
-
41
- **Verbose mode**: `rev build --verbose` already exists but doesn't echo the pandoc invocation. Print the full `pandoc <args>` command (one line per format) so users can copy-paste to replicate manually.
42
-
43
- ### Touch points
44
-
45
- - `lib/build.ts` — `BuildConfig` + `DEFAULT_CONFIG` (add `pandocArgs: string[]`; add `pandocArgs` to each format config), `buildPandocArgs()` (append top-level then format-specific), `runPandoc()` (echo command under verbose), `loadConfig()` (read hyphenated `pandoc-args` key and map to camelCase `pandocArgs`).
46
- - `lib/commands/build.ts` — add `--pandoc-arg <arg>` (repeatable via custom collector), forward through `BuildOptions`, ensure CLI args are appended last.
47
- - `lib/schema.ts` — declare `pandoc-args` (array of strings) at top level and inside each format object.
48
- - `skill/SKILL.md` + `skill/REFERENCE.md` — document new field and flag with a `--lua-filter=` example.
49
- - `test/build.test.js` — cover (a) top-level only, (b) format-specific only, (c) both concatenated in order, (d) CLI overrides config.
50
-
51
- ### Open questions
52
-
53
- None. Hyphenated YAML key + camelCase TS field is consistent with how the rest of the schema is read (we're already free-form on the JS side, just need a small key transform in `loadConfig`).
54
-
55
- ---
56
-
57
- ## Issue 2 — Output filename is auto-truncated mid-word and not configurable `[x]`
58
-
59
- ### Problem
60
-
61
- Default output landed at `output/adapt-alien-dark-diversity-across-plant-communitie.docx` — title slugified and hard-truncated at 50 chars (`communitie` missing the trailing `s`). No `-o` flag, no `output:` field in `rev.yaml`.
62
-
63
- Root cause: `lib/build.ts:1055-1056` (`runPandoc`) and `lib/commands/build.ts:591-592` (`--show-changes` path):
64
-
65
- ```ts
66
- const baseName = config.title
67
- ? config.title.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 50)
68
- : 'paper';
69
- ```
70
-
71
- `.slice(0, 50)` is a blind cut.
72
-
73
- ### Design (agreed)
74
-
75
- **rev.yaml**: per-format `output:` map. Extensions optional — added if missing.
76
-
77
- ```yaml
78
- output:
79
- docx: ADAPT_proposal_draft.docx
80
- pdf: ADAPT_proposal_draft.pdf
81
- ```
82
-
83
- **CLI**: `-o, --output <path>` on `rev build`. When multiple formats are built, applies as basename to all (extension swapped per format); for single-format builds, used verbatim.
84
-
85
- **Truncation fix**: when no `output:` is configured, slug at last `-` boundary at-or-before 50 chars instead of mid-word. Also bump the cap to 80 — 50 is conservative.
86
-
87
- **Doc fix**: surface the default `output/` directory in `rev build --help` and SKILL.md "Project Structure" tree (already mentioned in passing — make it explicit).
88
-
89
- ### Touch points
90
-
91
- - `lib/build.ts` — `BuildConfig` (`output?: Record<string, string>`), `DEFAULT_CONFIG`, `runPandoc()` (resolve filename: `config.output[format]` → CLI `-o` → slug). Helper: `resolveOutputName(config, format, cliOverride)`.
92
- - `lib/commands/build.ts` — add `-o, --output <path>` flag, wire into `BuildOptions`; same fix applied to the `--show-changes` branch's `baseName` construction.
93
- - `lib/schema.ts` — declare `output` as object mapping format → string.
94
- - `skill/SKILL.md` — "Project Structure" tree explicitly notes `output/`; new `output:` example under config.
95
- - `test/build.test.js` — cover (a) `output:` per-format honored, (b) `-o` CLI override, (c) word-boundary truncation when title >50 chars.
96
-
97
- ### Resolved
98
-
99
- - `-o` relative paths resolve under `outputDir`; absolute paths bypass it. Same rule applies to values in `output:`.
100
- - Cap raised from 50 → 80 chars; fallback truncates at the last `-` boundary at-or-before the cap so words stay whole (the ADAPT title now slugs cleanly without losing the trailing "s" on "communities").
101
- - `--show-changes` and `--dual` derived filenames (`-changes.docx`, `_comments.docx`, `_comments.pdf`) follow the chosen base name.
102
- - Fixed an unrelated misleading example in SKILL.md that showed `output: { docx: { reference-doc: ... } }` — the real config key is `docx.reference` (top-level), not nested under `output:`.
103
-
104
- ---
105
-
106
- ## Issue 3 — Raw LaTeX figure blocks silently disappear in docx builds `[x]`
107
-
108
- ### Problem
109
-
110
- Source markdown with `\begin{figure}[H]\includegraphics{...}\end{figure}` blocks renders correctly in the PDF target but produces a docx where all figures are silently missing. Pandoc strips the raw LaTeX because docx has no LaTeX rendering pipeline. No warning is emitted.
111
-
112
- This catches you only on careful inspection — a less careful user would ship a docx with no figures and not notice until a reviewer asks.
113
-
114
- ### Design (agreed)
115
-
116
- Three layers, combined:
117
-
118
- **1. Warn during build (always on).** In `applyFormatTransforms()` for docx, scan for raw LaTeX figure environments (`\begin{figure}` … `\end{figure}` containing `\includegraphics`). Emit:
119
-
120
- ```
121
- Warning: 3 raw LaTeX figure block(s) won't render in docx.
122
- intro.md:42 \begin{figure}[H] ... \includegraphics{figures/map.pdf} ...
123
- methods.md:118
124
- results.md:201
125
- Hint: use ![caption](path){#fig:label width=80%} for format-portable figures, or
126
- pass --pandoc-arg=--lua-filter=<your.lua> to translate them yourself.
127
- ```
128
-
129
- Counted by file/line so the user can jump to fix.
130
-
131
- **2. Auto-translate the common shape (opt-out via `docx.translateRawFigures: false`).** Convert
132
-
133
- ```latex
134
- \begin{figure}[H]
135
- \centering
136
- \includegraphics[width=0.8\textwidth]{figures/map.pdf}
137
- \caption{Map of study sites.}
138
- \label{fig:map}
139
- \end{figure}
140
- ```
141
-
142
-
143
-
144
- ```markdown
145
- ![Map of study sites.](figures/map.pdf){#fig:map width=80%}
146
- ```
147
-
148
- Cover the 80% case. If the block has anything more exotic (`\subfloat`, `\rotatebox`, multi-`\includegraphics`), skip auto-translate, warn loudly, and leave the block as-is.
149
-
150
- Width conversion: `0.8\textwidth` → `80%`; bare `8cm` → `8cm`; missing → omit.
151
-
152
- **3. Document.** SKILL.md "Cross-References" section currently mentions `@fig:label` and `{#fig:label}` but doesn't show how to *insert* a figure. Add:
153
-
154
- ```markdown
155
- ![Caption text.](figures/foo.pdf){#fig:foo width=80%}
156
- ```
157
-
158
- Note this is the format-portable form. Also mention that raw `\begin{figure}` blocks are PDF-only.
159
-
160
- ### Touch points
161
-
162
- - `lib/build.ts` — new helper `detectRawLatexFigures(content): {file?, line, block}[]` and `translateRawLatexFigures(content): {translated, untranslatedCount}`. Wire into `applyFormatTransforms()` for docx (after `convertDynamicRefsToDisplay`).
163
- - `lib/build.ts` — propagate warnings up via the existing `warnings: string[]` returned by `build()`. `rev build` already prints from there.
164
- - `lib/commands/build.ts` — surface warnings in normal output (not just verbose).
165
- - `lib/schema.ts` — declare `docx.translateRawFigures: boolean` (default true).
166
- - `skill/SKILL.md` — figure-insertion example under "Cross-References".
167
- - `test/build.test.js` — cover (a) detection counts blocks correctly, (b) auto-translate of `\includegraphics{path}`, (c) auto-translate of `\includegraphics[width=0.8\textwidth]{path}` → `width=80%`, (d) exotic block → not translated, warned, left alone, (e) opt-out via `translateRawFigures: false`.
168
-
169
- ### Open questions
170
-
171
- - Should auto-translate also handle bare `\includegraphics{...}` outside a `figure` env? Lean no — keep scope to figure environments. If a user writes raw `\includegraphics` without wrapping, that's a deliberate choice we shouldn't second-guess.
172
- - Width unit handling: `0.8\textwidth` → `80%` is unambiguous. `\linewidth` → `100%`? Yes. Other relative units → leave raw and warn.
173
-
174
- ---
175
-
176
- ## Working order
177
-
178
- 1. **Issue 1** first — unblocks immediate workflow needs and provides the manual escape hatch for issue 3 even before auto-translate ships.
179
- 2. **Issue 2** next — small, low-risk, quality-of-life win.
180
- 3. **Issue 3** last — biggest behavior change; benefits from the verbose pandoc echo (Issue 1) for debugging the lua-filter fallback path.
@@ -1,208 +0,0 @@
1
- /* ── Base ──────────────────────────────────────────────── */
2
- html, body {
3
- height: 100%;
4
- }
5
-
6
- body {
7
- background-color: #F5F6F8;
8
- color: #3E3F3A;
9
- display: flex;
10
- flex-direction: column;
11
- min-height: 100vh;
12
- padding-top: 4rem;
13
- font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
14
- }
15
-
16
- .container { flex: 1; }
17
- footer { margin-top: auto; }
18
-
19
- /* ── Navbar (pkgdown-style subtle tint, not bg-primary) ── */
20
- .navbar {
21
- background: color-mix(in oklab, color-mix(in oklab, var(--bs-body-bg) 95%, var(--bs-primary)) 95%, var(--bs-body-color));
22
- border-bottom: 1px solid #DFD7CA;
23
- line-height: initial;
24
- }
25
-
26
- .navbar .nav-link.active {
27
- font-weight: 600;
28
- color: var(--bs-primary) !important;
29
- }
30
-
31
- /* ── Links ─────────────────────────────────────────────── */
32
- a { color: #325D88; }
33
- a:hover { color: #1E3D5C; }
34
-
35
- /* ── Headings ──────────────────────────────────────────── */
36
- h1 { font-size: 2rem; font-weight: 600; margin-bottom: 1rem; }
37
- h2 {
38
- font-size: 1.4rem; font-weight: 600;
39
- margin-top: 2rem; margin-bottom: .65rem;
40
- padding-bottom: .3rem;
41
- border-bottom: 1px solid #DFD7CA;
42
- }
43
- h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.5rem; }
44
- h4 { font-size: 1rem; font-weight: 600; margin-top: 1.2rem; }
45
-
46
- /* ── Code ──────────────────────────────────────────────── */
47
- pre, div.sourceCode {
48
- background-color: #EEEEED;
49
- border: 1px solid #DFD7CA;
50
- border-radius: .375rem;
51
- padding: .9rem 1.1rem;
52
- font-size: .85rem;
53
- overflow-x: auto;
54
- margin: 1em 0;
55
- }
56
-
57
- code {
58
- background-color: #EEEEED;
59
- color: #3E3F3A;
60
- border-radius: .25rem;
61
- padding: .1em .35em;
62
- font-size: .875em;
63
- }
64
-
65
- pre code, div.sourceCode code {
66
- background: none;
67
- padding: 0;
68
- border-radius: 0;
69
- font-size: inherit;
70
- color: inherit;
71
- }
72
-
73
- div.sourceCode { padding: 0; }
74
- div.sourceCode pre { border: none; margin: 0; }
75
-
76
- /* ── Tables ────────────────────────────────────────────── */
77
- table {
78
- width: 100%;
79
- border-collapse: collapse;
80
- margin: 1em 0;
81
- font-size: .9rem;
82
- }
83
-
84
- thead th {
85
- background-color: #DFD7CA;
86
- color: #3E3F3A;
87
- font-weight: 600;
88
- padding: .5rem .75rem;
89
- border-bottom: 2px solid #c8c0b4;
90
- text-align: left;
91
- }
92
-
93
- td, th { padding: .4rem .75rem; border-bottom: 1px solid #e8e2d8; }
94
- tbody tr:hover { background-color: rgba(223,215,202,.2); }
95
-
96
- /* ── TOC sidebar ───────────────────────────────────────── */
97
- aside#toc, aside .toc, aside nav.toc { font-size: .875rem; }
98
-
99
- aside h2.h6 {
100
- text-transform: uppercase;
101
- font-size: .68rem;
102
- letter-spacing: .07em;
103
- color: #6c757d;
104
- font-weight: 600;
105
- margin-bottom: .5rem;
106
- border: none;
107
- padding: 0;
108
- }
109
-
110
- aside .toc, aside #TOC {
111
- position: sticky;
112
- top: 5rem;
113
- max-height: calc(100vh - 6rem);
114
- overflow-y: auto;
115
- }
116
-
117
- aside ul {
118
- list-style: none;
119
- padding-left: .9rem;
120
- margin: 0;
121
- }
122
- aside > nav > .toc > ul,
123
- aside .toc > ul { padding-left: 0; }
124
-
125
- aside li { margin: .1rem 0; }
126
-
127
- aside a {
128
- color: #6c757d;
129
- text-decoration: none;
130
- display: block;
131
- line-height: 1.55;
132
- }
133
- aside a:hover { color: #325D88; }
134
-
135
- /* ── Home page cards ───────────────────────────────────── */
136
- .doc-card {
137
- border: 1px solid #DFD7CA;
138
- border-radius: .375rem;
139
- padding: 1.1rem 1.25rem;
140
- height: 100%;
141
- background: #fff;
142
- transition: border-color .15s, box-shadow .15s;
143
- }
144
- .doc-card:hover {
145
- border-color: #325D88;
146
- box-shadow: 0 2px 8px rgba(50,93,136,.1);
147
- }
148
- .doc-card h5 { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; }
149
- .doc-card p { font-size: .875rem; color: #6c757d; margin-bottom: .6rem; }
150
- .doc-card a.stretched-link::after { z-index: 1; }
151
-
152
- /* ── Badges row ────────────────────────────────────────── */
153
- .badge-row { margin-bottom: 1rem; line-height: 2; }
154
- .badge-row img { margin-right: .25rem; }
155
-
156
- /* ── ── ── DARK MODE ── ── ── ──────────────────────────── */
157
-
158
- [data-bs-theme="dark"] body { background-color: #343739; color: #DFD7CA; }
159
-
160
- [data-bs-theme="dark"] .navbar {
161
- background: color-mix(in oklab, color-mix(in oklab, #343739 92%, var(--bs-primary)) 95%, #DFD7CA);
162
- border-bottom-color: #495057;
163
- }
164
-
165
- [data-bs-theme="dark"] a { color: #7ba8d0; }
166
- [data-bs-theme="dark"] a:hover { color: #a5c4e8; }
167
-
168
- [data-bs-theme="dark"] .navbar .nav-link.active { color: #7ba8d0 !important; }
169
-
170
- [data-bs-theme="dark"] h1,
171
- [data-bs-theme="dark"] h2,
172
- [data-bs-theme="dark"] h3,
173
- [data-bs-theme="dark"] h4 { color: #DFD7CA; }
174
-
175
- [data-bs-theme="dark"] h2 { border-color: #495057; }
176
-
177
- [data-bs-theme="dark"] pre,
178
- [data-bs-theme="dark"] div.sourceCode {
179
- background-color: #2C2F31;
180
- border-color: #495057;
181
- color: #DFD7CA;
182
- }
183
-
184
- [data-bs-theme="dark"] code {
185
- background-color: #2C2F31;
186
- color: #DFD7CA;
187
- }
188
-
189
- [data-bs-theme="dark"] div.sourceCode span[class] { color: #DFD7CA !important; }
190
-
191
- [data-bs-theme="dark"] thead th {
192
- background-color: #3d4043;
193
- color: #DFD7CA;
194
- border-color: #495057;
195
- }
196
- [data-bs-theme="dark"] td,
197
- [data-bs-theme="dark"] th { border-color: #3d4043; }
198
- [data-bs-theme="dark"] tbody tr:hover { background-color: rgba(73,80,87,.3); }
199
-
200
- [data-bs-theme="dark"] aside a { color: #8e9499; }
201
- [data-bs-theme="dark"] aside a:hover { color: #7ba8d0; }
202
-
203
- [data-bs-theme="dark"] .doc-card {
204
- background: #2C2F31;
205
- border-color: #495057;
206
- }
207
- [data-bs-theme="dark"] .doc-card:hover { border-color: #7ba8d0; }
208
- [data-bs-theme="dark"] .doc-card p { color: #8e9499; }