docrev 0.10.0 → 0.10.1

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 (126) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +173 -164
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +431 -431
  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/anchor-match.d.ts +1 -1
  11. package/dist/lib/anchor-match.d.ts.map +1 -1
  12. package/dist/lib/anchor-match.js +17 -47
  13. package/dist/lib/anchor-match.js.map +1 -1
  14. package/dist/lib/build.js +4 -4
  15. package/dist/lib/commands/context.d.ts +1 -1
  16. package/dist/lib/commands/context.d.ts.map +1 -1
  17. package/dist/lib/commands/context.js +1 -1
  18. package/dist/lib/commands/context.js.map +1 -1
  19. package/dist/lib/commands/sections.js +7 -7
  20. package/dist/lib/commands/sections.js.map +1 -1
  21. package/dist/lib/commands/sync.d.ts.map +1 -1
  22. package/dist/lib/commands/sync.js +15 -14
  23. package/dist/lib/commands/sync.js.map +1 -1
  24. package/dist/lib/commands/utilities.js +164 -164
  25. package/dist/lib/commands/verify-anchors.js +6 -6
  26. package/dist/lib/commands/verify-anchors.js.map +1 -1
  27. package/dist/lib/commands/word-tools.js +8 -8
  28. package/dist/lib/grammar.js +3 -3
  29. package/dist/lib/macro-filter.lua +201 -201
  30. package/dist/lib/pdf-comments.js +44 -44
  31. package/dist/lib/plugins.js +57 -57
  32. package/dist/lib/pptx-color-filter.lua +37 -37
  33. package/dist/lib/pptx-themes.js +115 -115
  34. package/dist/lib/sections.d.ts +35 -0
  35. package/dist/lib/sections.d.ts.map +1 -1
  36. package/dist/lib/sections.js +81 -0
  37. package/dist/lib/sections.js.map +1 -1
  38. package/dist/lib/spelling.js +2 -2
  39. package/dist/lib/templates.js +387 -387
  40. package/dist/lib/themes.js +51 -51
  41. package/docs-src/build.py +113 -113
  42. package/docs-src/extra.css +208 -208
  43. package/docs-src/md-to-html.lua +6 -6
  44. package/docs-src/template.html +116 -116
  45. package/eslint.config.js +27 -27
  46. package/lib/anchor-match.ts +276 -308
  47. package/lib/annotations.ts +644 -644
  48. package/lib/build.ts +1766 -1766
  49. package/lib/citations.ts +160 -160
  50. package/lib/commands/build.ts +855 -855
  51. package/lib/commands/citations.ts +515 -515
  52. package/lib/commands/comments.ts +1050 -1050
  53. package/lib/commands/context.ts +176 -174
  54. package/lib/commands/core.ts +309 -309
  55. package/lib/commands/doi.ts +435 -435
  56. package/lib/commands/file-ops.ts +372 -372
  57. package/lib/commands/history.ts +320 -320
  58. package/lib/commands/index.ts +87 -87
  59. package/lib/commands/init.ts +259 -259
  60. package/lib/commands/merge-resolve.ts +378 -378
  61. package/lib/commands/preview.ts +178 -178
  62. package/lib/commands/project-info.ts +244 -244
  63. package/lib/commands/quality.ts +517 -517
  64. package/lib/commands/response.ts +454 -454
  65. package/lib/commands/section-boundaries.ts +82 -82
  66. package/lib/commands/sections.ts +451 -451
  67. package/lib/commands/sync.ts +709 -706
  68. package/lib/commands/text-ops.ts +449 -449
  69. package/lib/commands/utilities.ts +448 -448
  70. package/lib/commands/verify-anchors.ts +272 -272
  71. package/lib/commands/word-tools.ts +340 -340
  72. package/lib/comment-realign.ts +517 -517
  73. package/lib/config.ts +84 -84
  74. package/lib/crossref.ts +781 -781
  75. package/lib/csl.ts +191 -191
  76. package/lib/dependencies.ts +98 -98
  77. package/lib/diff-engine.ts +465 -465
  78. package/lib/doi-cache.ts +115 -115
  79. package/lib/doi.ts +897 -897
  80. package/lib/equations.ts +506 -506
  81. package/lib/errors.ts +346 -346
  82. package/lib/format.ts +541 -541
  83. package/lib/git.ts +326 -326
  84. package/lib/grammar.ts +303 -303
  85. package/lib/image-registry.ts +180 -180
  86. package/lib/import.ts +911 -911
  87. package/lib/journals.ts +543 -543
  88. package/lib/macro-filter.lua +201 -201
  89. package/lib/macros.ts +273 -273
  90. package/lib/merge.ts +633 -633
  91. package/lib/orcid.ts +144 -144
  92. package/lib/pdf-comments.ts +263 -263
  93. package/lib/pdf-import.ts +524 -524
  94. package/lib/plugins.ts +362 -362
  95. package/lib/postprocess.ts +188 -188
  96. package/lib/pptx-color-filter.lua +37 -37
  97. package/lib/pptx-template.ts +469 -469
  98. package/lib/pptx-themes.ts +483 -483
  99. package/lib/protect-restore.ts +520 -520
  100. package/lib/rate-limiter.ts +94 -94
  101. package/lib/response.ts +197 -197
  102. package/lib/restore-references.ts +240 -240
  103. package/lib/review.ts +327 -327
  104. package/lib/schema.ts +488 -488
  105. package/lib/scientific-words.ts +73 -73
  106. package/lib/sections.ts +425 -335
  107. package/lib/slides.ts +756 -756
  108. package/lib/spelling.ts +334 -334
  109. package/lib/templates.ts +526 -526
  110. package/lib/themes.ts +742 -742
  111. package/lib/trackchanges.ts +247 -247
  112. package/lib/tui.ts +450 -450
  113. package/lib/types.ts +550 -550
  114. package/lib/undo.ts +250 -250
  115. package/lib/utils.ts +69 -69
  116. package/lib/variables.ts +179 -179
  117. package/lib/word-extraction.ts +806 -806
  118. package/lib/word.ts +643 -643
  119. package/lib/wordcomments.ts +840 -840
  120. package/mkdocs.yml +64 -64
  121. package/package.json +137 -137
  122. package/scripts/postbuild.js +47 -47
  123. package/skill/REFERENCE.md +539 -539
  124. package/skill/SKILL.md +295 -295
  125. package/tsconfig.json +26 -26
  126. package/types/index.d.ts +525 -525
@@ -1,539 +1,539 @@
1
- # docrev Command Reference
2
-
3
- ## Project Creation
4
-
5
- ### rev new
6
- Create a new document project.
7
- ```bash
8
- rev new my-document # Creates my-document/ with section files
9
- rev new my-document --template apa
10
- ```
11
-
12
- ## Document Import/Export
13
-
14
- ### rev import
15
- Import a Word document with track changes and comments.
16
- ```bash
17
- rev import manuscript.docx
18
- rev import manuscript.docx --output ./project
19
- ```
20
-
21
- ### rev sync
22
- Sync feedback from a reviewed Word document into existing markdown sections.
23
- ```bash
24
- rev sync reviewed.docx # Updates markdown with track changes/comments
25
- rev sync # Auto-detect most recent .docx
26
- rev sync reviewed.docx methods # Sync only methods section
27
- rev sync reviewed.docx --comments-only # Insert comments only; never modify prose
28
- ```
29
-
30
- `--comments-only` skips the Word→Markdown diff entirely. Use it when the
31
- markdown has been revised between sending the docx out for review and
32
- receiving it back: applying track changes from a stale draft would clobber
33
- newer edits, but comments still need to land. Comments are placed at
34
- fuzzy-matched anchors against the current prose. Pair with
35
- `rev verify-anchors` to see which ones won't fit before you run sync.
36
-
37
- ### rev verify-anchors
38
- Report drift between Word comment anchors and the current markdown.
39
- ```bash
40
- rev verify-anchors reviewed.docx # Print per-comment match quality
41
- rev verify-anchors reviewed.docx --json # Machine-readable report
42
- ```
43
-
44
- Each comment is classified by how well its anchor still matches the current
45
- section prose:
46
-
47
- - `clean` – exact or whitespace-normalized hit
48
- - `drift` – anchor only matches via stripped-CriticMarkup or partial-prefix fallbacks
49
- - `context-only` – anchor text is gone, only surrounding context survives
50
- - `ambiguous` – multiple candidate positions; needs context to disambiguate
51
- - `unmatched` – nothing maps; user must place the comment manually
52
-
53
- Useful before `rev sync --comments-only` to plan which comments will land
54
- automatically and which need manual placement.
55
-
56
- ### rev build
57
- Build output documents from markdown sections.
58
- ```bash
59
- rev build # Build PDF and DOCX
60
- rev build pdf # PDF only
61
- rev build docx # DOCX only
62
- rev build --toc # Include table of contents
63
- rev build docx --dual # Clean + annotated versions
64
- rev build docx --show-changes # DOCX with visible track changes (audit)
65
- rev build docx --pandoc-arg=--lua-filter=tofill.lua # Pass extra args to pandoc
66
- rev build -o Final_Report # Override output filename (extension auto-added)
67
- rev build pdf --verbose # Echo the pandoc invocation (useful for filter debugging)
68
- ```
69
-
70
- By default, outputs land in `output/` next to `rev.yaml`. Override or
71
- disable via the `outputDir` field in rev.yaml (see below).
72
-
73
- #### Choosing output filenames
74
-
75
- By default, the output basename is derived from `title:` (slugified — e.g.
76
- "My Paper" → `my-paper.docx`). Long titles are truncated at word boundaries
77
- (at the last `-` at-or-before 80 chars), so `communities` stays whole instead
78
- of becoming `communitie`.
79
-
80
- To pick your own filename, set per-format names in `rev.yaml`:
81
-
82
- ```yaml
83
- output:
84
- docx: ADAPT_proposal_draft.docx
85
- pdf: ADAPT_proposal_draft.pdf
86
- ```
87
-
88
- Extensions are optional — `ADAPT_proposal_draft` is fine, the right extension
89
- is added per format. Relative paths resolve under `outputDir`; absolute paths
90
- bypass `outputDir`.
91
-
92
- Or override on the command line with `-o, --output <path>`:
93
-
94
- ```bash
95
- rev build docx -o Final_Report # → output/Final_Report.docx
96
- rev build pdf docx -o Final_Report # Applies to both formats
97
- rev build -o /tmp/draft.docx docx # Absolute path bypasses outputDir
98
- ```
99
-
100
- CLI `-o` wins over `output:` in `rev.yaml`. When `--dual` is on, the
101
- `_comments` variant piggybacks on the chosen name (e.g.
102
- `Final_Report_comments.docx`). When `--show-changes` is on, the audit DOCX
103
- uses the chosen name with a `-changes` suffix
104
- (e.g. `Final_Report-changes.docx`).
105
-
106
- #### Passing custom pandoc args
107
-
108
- For pandoc flags rev doesn't surface directly (Lua/JSON filters, custom
109
- templates, variables, etc.), use the repeatable `--pandoc-arg` flag or the
110
- `pandoc-args` field in `rev.yaml`:
111
-
112
- ```yaml
113
- # rev.yaml — applies to every format
114
- pandoc-args:
115
- - --lua-filter=tofill.lua
116
- - --shift-heading-level-by=1
117
-
118
- # Format-specific (concatenated after the top-level list)
119
- docx:
120
- pandoc-args:
121
- - --lua-filter=docx_only.lua
122
- pdf:
123
- pandoc-args:
124
- - --variable=papersize:a4
125
- ```
126
-
127
- ```bash
128
- # CLI overrides — appended last, so pandoc's last-wins rule lets CLI flags
129
- # beat repeated config flags
130
- rev build docx --pandoc-arg=--lua-filter=cli.lua --pandoc-arg=--metadata=draft:true
131
- ```
132
-
133
- Run with `--verbose` to print the full pandoc command line (one per format).
134
- Copy-paste it into a terminal to reproduce a build manually.
135
-
136
- The `--dual` flag produces:
137
- - `output/<title>.docx` — clean, for submission
138
- - `output/<title>_comments.docx` — includes comment threads as Word comments
139
-
140
- The `--show-changes` flag (DOCX only) produces a single audit document
141
- where every accepted/rejected revision and substitution is exported as a
142
- visible Word track change, attributed to the configured user. Useful when
143
- a co-author wants to see what changed since the last shared version.
144
-
145
- ### rev preview
146
- Build and open document in default app.
147
- ```bash
148
- rev preview pdf # Build and open PDF
149
- rev preview docx # Build and open Word
150
- ```
151
-
152
- ### rev export
153
- Export project as distributable zip.
154
- ```bash
155
- rev export # Creates project.zip (no node_modules)
156
- ```
157
-
158
- ### rev backup
159
- Create timestamped project backup.
160
- ```bash
161
- rev backup # Creates backup-2024-12-29.zip
162
- rev backup --name v1-draft # Creates v1-draft.zip
163
- ```
164
-
165
- ## Comments & Annotations
166
-
167
- ### rev comments
168
- List all comments with context.
169
- ```bash
170
- rev comments methods.md # Show comments
171
- rev comments methods.md --export out.csv # Export to CSV
172
- ```
173
-
174
- ### rev reply
175
- Reply to a specific comment (non-interactive).
176
- ```bash
177
- rev reply methods.md -n 1 -m "Added clarification"
178
- rev reply results.md -n 3 -m "Updated figure"
179
- ```
180
-
181
- ### rev resolve
182
- Mark a comment as resolved.
183
- ```bash
184
- rev resolve methods.md -n 1
185
- rev resolve methods.md -n 1,2,3 # Multiple comments
186
- ```
187
-
188
- ### rev status
189
- Show project overview or annotation counts for a file.
190
- ```bash
191
- rev status # Project overview (words, comments, changes)
192
- rev status methods.md # Specific file annotations
193
- ```
194
-
195
- ### rev next / rev prev
196
- Navigate pending comments.
197
- ```bash
198
- rev next # Show next pending comment
199
- rev next -n 3 # Show 3rd pending comment
200
- rev prev # Show last pending comment
201
- rev first methods # First comment in methods section
202
- rev last # Last comment overall
203
- ```
204
-
205
- ### rev todo
206
- List all pending comments as a checklist.
207
- ```bash
208
- rev todo # List all pending
209
- rev todo --by-author # Group by author
210
- ```
211
-
212
- ### rev accept / rev reject
213
- Accept or reject track changes.
214
- ```bash
215
- rev accept methods.md # List all changes
216
- rev accept methods.md -n 1 # Accept change #1
217
- rev accept methods.md -a # Accept all
218
- rev reject methods.md -n 2 # Reject change #2
219
- ```
220
-
221
- ### rev archive
222
- Archive reviewer .docx files.
223
- ```bash
224
- rev archive # Move all .docx to archive/
225
- rev archive --by Smith # Specify reviewer name
226
- rev archive --dry-run # Preview without moving
227
- ```
228
-
229
- ### rev strip
230
- Remove all annotations from markdown.
231
- ```bash
232
- rev strip methods.md --output clean.md
233
- rev strip methods.md --accept # Accept all changes
234
- rev strip methods.md --reject # Reject all changes
235
- ```
236
-
237
- ## Response Letter
238
-
239
- ### rev response
240
- Generate point-by-point response letter from comments.
241
- ```bash
242
- rev response # Generate response letter
243
- ```
244
-
245
- ## Validation & Checks
246
-
247
- ### rev check
248
- Run all pre-submission checks (lint + grammar + citations).
249
- ```bash
250
- rev check # Run all checks
251
- rev check --fix # Auto-fix where possible
252
- ```
253
-
254
- ### rev lint
255
- Check for common issues.
256
- ```bash
257
- rev lint # Run all checks
258
- rev lint --fix # Auto-fix where possible
259
- ```
260
- Checks: broken cross-references, missing citations, orphaned figures, unresolved comments.
261
-
262
- ### rev grammar
263
- Check grammar and style.
264
- ```bash
265
- rev grammar # Check all sections
266
- rev grammar --rules # List available rules
267
- rev grammar --learn word # Add to custom dictionary
268
- rev grammar --forget word # Remove from dictionary
269
- rev grammar --list # Show custom dictionary
270
- rev grammar -s warning # Filter by severity
271
- ```
272
-
273
- ### rev spelling
274
- Check spelling in all sections.
275
- ```bash
276
- rev spelling # Check all sections
277
- rev spelling --british # Use British English dictionary
278
- rev spelling --learn word # Add to global dictionary (~/.rev-dictionary)
279
- rev spelling --learn-project word # Add to project dictionary
280
- rev spelling --forget word # Remove from global dictionary
281
- rev spelling --list # Show global dictionary
282
- rev spelling --list-all # Show global + project dictionaries
283
- ```
284
- Built-in scientific vocabulary reduces false positives. Possible author names are shown separately for easy review.
285
-
286
- ### rev validate
287
- Check against journal requirements.
288
- ```bash
289
- rev validate --journal nature
290
- rev validate --list # List 22 available journals
291
- ```
292
-
293
- ### rev citations
294
- Validate citations against bibliography.
295
- ```bash
296
- rev citations
297
- ```
298
-
299
- ## DOI Management
300
-
301
- ### rev doi check
302
- Validate DOIs in bibliography.
303
- ```bash
304
- rev doi check references.bib
305
- rev doi check references.bib --strict # Fail if articles missing DOIs
306
- ```
307
-
308
- ### rev doi lookup
309
- Find missing DOIs by title/author/year.
310
- ```bash
311
- rev doi lookup references.bib
312
- rev doi lookup references.bib --confidence high
313
- ```
314
-
315
- ### rev doi fetch
316
- Get BibTeX from a DOI.
317
- ```bash
318
- rev doi fetch 10.1234/example
319
- ```
320
-
321
- ### rev doi add
322
- Add citation to .bib file from DOI.
323
- ```bash
324
- rev doi add 10.1234/example
325
- rev doi add 10.1234/example --file references.bib
326
- ```
327
-
328
- ## Content Analysis
329
-
330
- ### rev word-count
331
- Show word counts per section.
332
- ```bash
333
- rev word-count # Per-section counts
334
- rev word-count --limit 5000 # Warn if over limit
335
- rev word-count -j nature # Use journal word limit
336
- ```
337
-
338
- ### rev stats
339
- Project dashboard showing overview.
340
- ```bash
341
- rev stats # Words, figures, citations, comments
342
- ```
343
-
344
- ### rev search
345
- Search across all section files.
346
- ```bash
347
- rev search "climate change"
348
- rev search -i "method" # Case-insensitive
349
- ```
350
-
351
- ### rev figures
352
- List figures with reference counts.
353
- ```bash
354
- rev figures methods.md
355
- ```
356
-
357
- ### rev equations
358
- Work with LaTeX equations.
359
- ```bash
360
- rev equations list # List all equations
361
- rev equations from-word manuscript.docx # Extract from Word
362
- ```
363
-
364
- ## Direct DOCX Editing (Layout Workflow)
365
-
366
- ### rev annotate
367
- Add comments directly to Word document.
368
- ```bash
369
- rev annotate paper.docx -m "Comment" -s "text to find"
370
- ```
371
-
372
- ### rev apply
373
- Apply MD annotations as Word track changes.
374
- ```bash
375
- rev apply paper.md output.docx
376
- ```
377
-
378
- ### rev comment
379
- Interactive comment mode for Word documents.
380
- ```bash
381
- rev comment paper.docx
382
- ```
383
-
384
- ## Project Management
385
-
386
- ### rev clean
387
- Remove generated files.
388
- ```bash
389
- rev clean # Remove paper.md, PDFs, DOCXs
390
- rev clean --dry-run # Show what would be deleted
391
- rev clean --all # Also remove backups and exports
392
- ```
393
-
394
- ### rev open
395
- Open project folder or file.
396
- ```bash
397
- rev open # Open project folder
398
- rev open paper.pdf # Open specific file
399
- ```
400
-
401
- ### rev watch
402
- Auto-rebuild on file changes.
403
- ```bash
404
- rev watch # Watch and rebuild
405
- rev watch pdf # Only rebuild PDF
406
- rev watch --no-open # Don't open after build
407
- ```
408
-
409
- ## Configuration
410
-
411
- ### rev config
412
- Configure user settings.
413
- ```bash
414
- rev config user "Your Name" # Set author name for replies
415
- rev config # Show current config
416
- ```
417
-
418
- ## rev.yaml Settings
419
-
420
- ### Output Directory
421
-
422
- By default, built artefacts land in `output/` next to `rev.yaml`. Both the
423
- clean output and `--dual` companion (`*_comments.docx` / `*_comments.pdf`)
424
- follow the configured location. Override or disable:
425
-
426
- ```yaml
427
- outputDir: output # default — outputs land in ./output/
428
- outputDir: dist # custom subdirectory
429
- outputDir: null # legacy layout — outputs alongside paper.md
430
- ```
431
-
432
- Explicit caller-supplied output paths (e.g. internal temp files in the
433
- dual flow) bypass `outputDir`.
434
-
435
- ### PDF Engine and Fonts
436
-
437
- The default PDF engine is `pdflatex`. Switch to xelatex/lualatex when the
438
- manuscript needs native UTF-8 rendering of Latin-Extended diacritics
439
- (Czech/Polish/Croatian/Spanish author names, species epithets):
440
-
441
- ```yaml
442
- pdf:
443
- engine: xelatex # or lualatex, tectonic, etc.
444
- mainfont: "TeX Gyre Termes" # serif (xelatex/lualatex only — uses fontspec)
445
- sansfont: "TeX Gyre Heros" # sans (optional)
446
- monofont: "TeX Gyre Cursor" # monospace (optional)
447
- ```
448
-
449
- `mainfont`/`sansfont`/`monofont` are forwarded as pandoc `-V` flags and
450
- require an engine that loads `fontspec` (xelatex or lualatex). They are
451
- ignored under `pdflatex`.
452
-
453
- ### Tables
454
-
455
- Configure table formatting for PDF output:
456
-
457
- ```yaml
458
- tables:
459
- nowrap:
460
- - Prior # Column headers to keep on one line
461
- - "$\\widehat{R}$"
462
- ```
463
-
464
- In `nowrap` columns, distribution notation is auto-converted to LaTeX math:
465
- - `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
466
- - `Student-t(3, 0, 1)` → `$t_3(0, 1)$`
467
- - `Gamma(2, 0.5)` → `$\text{Gamma}(2, 0.5)$`
468
- - `Half-Normal(0, 1)` → `$\text{Half-Normal}(0, 1)$`
469
- - `Exponential(1)` → `$\text{Exp}(1)$`
470
-
471
- **Tip:** For complex tables, use simple tables (space-aligned with dashes) instead of pipe tables to avoid column width issues:
472
-
473
- ```markdown
474
- Parameter Prior Description
475
- ---------- ------------------------- ------------------
476
- alpha $\mathcal{N}(0, 0.5)$ Intercept prior
477
- beta $t_3(0, 2.5)$ Slope prior
478
- ```
479
-
480
- ### Postprocess Scripts
481
-
482
- Run custom scripts after output generation:
483
-
484
- ```yaml
485
- postprocess:
486
- pdf: ./scripts/fix-pdf.py # Runs after PDF
487
- docx: ./scripts/add-meta.js # Runs after DOCX
488
- tex: ./scripts/tweak-latex.sh # Runs after TEX
489
- pptx: ./scripts/fix-slides.ps1 # Runs after PPTX
490
- all: ./scripts/notify.js # Runs after ANY format
491
- ```
492
-
493
- **Environment variables** available to scripts:
494
-
495
- | Variable | Description |
496
- |----------|-------------|
497
- | `OUTPUT_FILE` | Full path to generated file |
498
- | `OUTPUT_FORMAT` | Format: `pdf`, `docx`, `tex`, `pptx`, `beamer` |
499
- | `PROJECT_DIR` | Directory containing rev.yaml |
500
- | `CONFIG_PATH` | Full path to rev.yaml |
501
-
502
- **Supported script types:** `.js`, `.mjs` (Node), `.py` (Python), `.ps1` (PowerShell), `.sh` (Bash)
503
-
504
- **Example Python script** (add DOCX metadata):
505
- ```python
506
- import os
507
- from docx import Document
508
- doc = Document(os.environ['OUTPUT_FILE'])
509
- doc.core_properties.author = "Research Team"
510
- doc.save(os.environ['OUTPUT_FILE'])
511
- ```
512
-
513
- Use `--verbose` flag to see script output:
514
- ```bash
515
- rev build pdf --verbose
516
- ```
517
-
518
- ## Shell Completions
519
-
520
- ### rev completions
521
- Output shell completions.
522
- ```bash
523
- eval "$(rev completions bash)" # Bash
524
- eval "$(rev completions zsh)" # Zsh
525
- ```
526
-
527
- ## AI Skill Installation
528
-
529
- ### rev install-cli-skill
530
- Install the docrev skill for AI coding assistants.
531
- ```bash
532
- rev install-cli-skill # Install to ~/.claude/skills/docrev
533
- ```
534
-
535
- ### rev uninstall-cli-skill
536
- Remove the installed skill.
537
- ```bash
538
- rev uninstall-cli-skill
539
- ```
1
+ # docrev Command Reference
2
+
3
+ ## Project Creation
4
+
5
+ ### rev new
6
+ Create a new document project.
7
+ ```bash
8
+ rev new my-document # Creates my-document/ with section files
9
+ rev new my-document --template apa
10
+ ```
11
+
12
+ ## Document Import/Export
13
+
14
+ ### rev import
15
+ Import a Word document with track changes and comments.
16
+ ```bash
17
+ rev import manuscript.docx
18
+ rev import manuscript.docx --output ./project
19
+ ```
20
+
21
+ ### rev sync
22
+ Sync feedback from a reviewed Word document into existing markdown sections.
23
+ ```bash
24
+ rev sync reviewed.docx # Updates markdown with track changes/comments
25
+ rev sync # Auto-detect most recent .docx
26
+ rev sync reviewed.docx methods # Sync only methods section
27
+ rev sync reviewed.docx --comments-only # Insert comments only; never modify prose
28
+ ```
29
+
30
+ `--comments-only` skips the Word→Markdown diff entirely. Use it when the
31
+ markdown has been revised between sending the docx out for review and
32
+ receiving it back: applying track changes from a stale draft would clobber
33
+ newer edits, but comments still need to land. Comments are placed at
34
+ fuzzy-matched anchors against the current prose. Pair with
35
+ `rev verify-anchors` to see which ones won't fit before you run sync.
36
+
37
+ ### rev verify-anchors
38
+ Report drift between Word comment anchors and the current markdown.
39
+ ```bash
40
+ rev verify-anchors reviewed.docx # Print per-comment match quality
41
+ rev verify-anchors reviewed.docx --json # Machine-readable report
42
+ ```
43
+
44
+ Each comment is classified by how well its anchor still matches the current
45
+ section prose:
46
+
47
+ - `clean` – exact or whitespace-normalized hit
48
+ - `drift` – anchor only matches via stripped-CriticMarkup or partial-prefix fallbacks
49
+ - `context-only` – anchor text is gone, only surrounding context survives
50
+ - `ambiguous` – multiple candidate positions; needs context to disambiguate
51
+ - `unmatched` – nothing maps; user must place the comment manually
52
+
53
+ Useful before `rev sync --comments-only` to plan which comments will land
54
+ automatically and which need manual placement.
55
+
56
+ ### rev build
57
+ Build output documents from markdown sections.
58
+ ```bash
59
+ rev build # Build PDF and DOCX
60
+ rev build pdf # PDF only
61
+ rev build docx # DOCX only
62
+ rev build --toc # Include table of contents
63
+ rev build docx --dual # Clean + annotated versions
64
+ rev build docx --show-changes # DOCX with visible track changes (audit)
65
+ rev build docx --pandoc-arg=--lua-filter=tofill.lua # Pass extra args to pandoc
66
+ rev build -o Final_Report # Override output filename (extension auto-added)
67
+ rev build pdf --verbose # Echo the pandoc invocation (useful for filter debugging)
68
+ ```
69
+
70
+ By default, outputs land in `output/` next to `rev.yaml`. Override or
71
+ disable via the `outputDir` field in rev.yaml (see below).
72
+
73
+ #### Choosing output filenames
74
+
75
+ By default, the output basename is derived from `title:` (slugified — e.g.
76
+ "My Paper" → `my-paper.docx`). Long titles are truncated at word boundaries
77
+ (at the last `-` at-or-before 80 chars), so `communities` stays whole instead
78
+ of becoming `communitie`.
79
+
80
+ To pick your own filename, set per-format names in `rev.yaml`:
81
+
82
+ ```yaml
83
+ output:
84
+ docx: ADAPT_proposal_draft.docx
85
+ pdf: ADAPT_proposal_draft.pdf
86
+ ```
87
+
88
+ Extensions are optional — `ADAPT_proposal_draft` is fine, the right extension
89
+ is added per format. Relative paths resolve under `outputDir`; absolute paths
90
+ bypass `outputDir`.
91
+
92
+ Or override on the command line with `-o, --output <path>`:
93
+
94
+ ```bash
95
+ rev build docx -o Final_Report # → output/Final_Report.docx
96
+ rev build pdf docx -o Final_Report # Applies to both formats
97
+ rev build -o /tmp/draft.docx docx # Absolute path bypasses outputDir
98
+ ```
99
+
100
+ CLI `-o` wins over `output:` in `rev.yaml`. When `--dual` is on, the
101
+ `_comments` variant piggybacks on the chosen name (e.g.
102
+ `Final_Report_comments.docx`). When `--show-changes` is on, the audit DOCX
103
+ uses the chosen name with a `-changes` suffix
104
+ (e.g. `Final_Report-changes.docx`).
105
+
106
+ #### Passing custom pandoc args
107
+
108
+ For pandoc flags rev doesn't surface directly (Lua/JSON filters, custom
109
+ templates, variables, etc.), use the repeatable `--pandoc-arg` flag or the
110
+ `pandoc-args` field in `rev.yaml`:
111
+
112
+ ```yaml
113
+ # rev.yaml — applies to every format
114
+ pandoc-args:
115
+ - --lua-filter=tofill.lua
116
+ - --shift-heading-level-by=1
117
+
118
+ # Format-specific (concatenated after the top-level list)
119
+ docx:
120
+ pandoc-args:
121
+ - --lua-filter=docx_only.lua
122
+ pdf:
123
+ pandoc-args:
124
+ - --variable=papersize:a4
125
+ ```
126
+
127
+ ```bash
128
+ # CLI overrides — appended last, so pandoc's last-wins rule lets CLI flags
129
+ # beat repeated config flags
130
+ rev build docx --pandoc-arg=--lua-filter=cli.lua --pandoc-arg=--metadata=draft:true
131
+ ```
132
+
133
+ Run with `--verbose` to print the full pandoc command line (one per format).
134
+ Copy-paste it into a terminal to reproduce a build manually.
135
+
136
+ The `--dual` flag produces:
137
+ - `output/<title>.docx` — clean, for submission
138
+ - `output/<title>_comments.docx` — includes comment threads as Word comments
139
+
140
+ The `--show-changes` flag (DOCX only) produces a single audit document
141
+ where every accepted/rejected revision and substitution is exported as a
142
+ visible Word track change, attributed to the configured user. Useful when
143
+ a co-author wants to see what changed since the last shared version.
144
+
145
+ ### rev preview
146
+ Build and open document in default app.
147
+ ```bash
148
+ rev preview pdf # Build and open PDF
149
+ rev preview docx # Build and open Word
150
+ ```
151
+
152
+ ### rev export
153
+ Export project as distributable zip.
154
+ ```bash
155
+ rev export # Creates project.zip (no node_modules)
156
+ ```
157
+
158
+ ### rev backup
159
+ Create timestamped project backup.
160
+ ```bash
161
+ rev backup # Creates backup-2024-12-29.zip
162
+ rev backup --name v1-draft # Creates v1-draft.zip
163
+ ```
164
+
165
+ ## Comments & Annotations
166
+
167
+ ### rev comments
168
+ List all comments with context.
169
+ ```bash
170
+ rev comments methods.md # Show comments
171
+ rev comments methods.md --export out.csv # Export to CSV
172
+ ```
173
+
174
+ ### rev reply
175
+ Reply to a specific comment (non-interactive).
176
+ ```bash
177
+ rev reply methods.md -n 1 -m "Added clarification"
178
+ rev reply results.md -n 3 -m "Updated figure"
179
+ ```
180
+
181
+ ### rev resolve
182
+ Mark a comment as resolved.
183
+ ```bash
184
+ rev resolve methods.md -n 1
185
+ rev resolve methods.md -n 1,2,3 # Multiple comments
186
+ ```
187
+
188
+ ### rev status
189
+ Show project overview or annotation counts for a file.
190
+ ```bash
191
+ rev status # Project overview (words, comments, changes)
192
+ rev status methods.md # Specific file annotations
193
+ ```
194
+
195
+ ### rev next / rev prev
196
+ Navigate pending comments.
197
+ ```bash
198
+ rev next # Show next pending comment
199
+ rev next -n 3 # Show 3rd pending comment
200
+ rev prev # Show last pending comment
201
+ rev first methods # First comment in methods section
202
+ rev last # Last comment overall
203
+ ```
204
+
205
+ ### rev todo
206
+ List all pending comments as a checklist.
207
+ ```bash
208
+ rev todo # List all pending
209
+ rev todo --by-author # Group by author
210
+ ```
211
+
212
+ ### rev accept / rev reject
213
+ Accept or reject track changes.
214
+ ```bash
215
+ rev accept methods.md # List all changes
216
+ rev accept methods.md -n 1 # Accept change #1
217
+ rev accept methods.md -a # Accept all
218
+ rev reject methods.md -n 2 # Reject change #2
219
+ ```
220
+
221
+ ### rev archive
222
+ Archive reviewer .docx files.
223
+ ```bash
224
+ rev archive # Move all .docx to archive/
225
+ rev archive --by Smith # Specify reviewer name
226
+ rev archive --dry-run # Preview without moving
227
+ ```
228
+
229
+ ### rev strip
230
+ Remove all annotations from markdown.
231
+ ```bash
232
+ rev strip methods.md --output clean.md
233
+ rev strip methods.md --accept # Accept all changes
234
+ rev strip methods.md --reject # Reject all changes
235
+ ```
236
+
237
+ ## Response Letter
238
+
239
+ ### rev response
240
+ Generate point-by-point response letter from comments.
241
+ ```bash
242
+ rev response # Generate response letter
243
+ ```
244
+
245
+ ## Validation & Checks
246
+
247
+ ### rev check
248
+ Run all pre-submission checks (lint + grammar + citations).
249
+ ```bash
250
+ rev check # Run all checks
251
+ rev check --fix # Auto-fix where possible
252
+ ```
253
+
254
+ ### rev lint
255
+ Check for common issues.
256
+ ```bash
257
+ rev lint # Run all checks
258
+ rev lint --fix # Auto-fix where possible
259
+ ```
260
+ Checks: broken cross-references, missing citations, orphaned figures, unresolved comments.
261
+
262
+ ### rev grammar
263
+ Check grammar and style.
264
+ ```bash
265
+ rev grammar # Check all sections
266
+ rev grammar --rules # List available rules
267
+ rev grammar --learn word # Add to custom dictionary
268
+ rev grammar --forget word # Remove from dictionary
269
+ rev grammar --list # Show custom dictionary
270
+ rev grammar -s warning # Filter by severity
271
+ ```
272
+
273
+ ### rev spelling
274
+ Check spelling in all sections.
275
+ ```bash
276
+ rev spelling # Check all sections
277
+ rev spelling --british # Use British English dictionary
278
+ rev spelling --learn word # Add to global dictionary (~/.rev-dictionary)
279
+ rev spelling --learn-project word # Add to project dictionary
280
+ rev spelling --forget word # Remove from global dictionary
281
+ rev spelling --list # Show global dictionary
282
+ rev spelling --list-all # Show global + project dictionaries
283
+ ```
284
+ Built-in scientific vocabulary reduces false positives. Possible author names are shown separately for easy review.
285
+
286
+ ### rev validate
287
+ Check against journal requirements.
288
+ ```bash
289
+ rev validate --journal nature
290
+ rev validate --list # List 22 available journals
291
+ ```
292
+
293
+ ### rev citations
294
+ Validate citations against bibliography.
295
+ ```bash
296
+ rev citations
297
+ ```
298
+
299
+ ## DOI Management
300
+
301
+ ### rev doi check
302
+ Validate DOIs in bibliography.
303
+ ```bash
304
+ rev doi check references.bib
305
+ rev doi check references.bib --strict # Fail if articles missing DOIs
306
+ ```
307
+
308
+ ### rev doi lookup
309
+ Find missing DOIs by title/author/year.
310
+ ```bash
311
+ rev doi lookup references.bib
312
+ rev doi lookup references.bib --confidence high
313
+ ```
314
+
315
+ ### rev doi fetch
316
+ Get BibTeX from a DOI.
317
+ ```bash
318
+ rev doi fetch 10.1234/example
319
+ ```
320
+
321
+ ### rev doi add
322
+ Add citation to .bib file from DOI.
323
+ ```bash
324
+ rev doi add 10.1234/example
325
+ rev doi add 10.1234/example --file references.bib
326
+ ```
327
+
328
+ ## Content Analysis
329
+
330
+ ### rev word-count
331
+ Show word counts per section.
332
+ ```bash
333
+ rev word-count # Per-section counts
334
+ rev word-count --limit 5000 # Warn if over limit
335
+ rev word-count -j nature # Use journal word limit
336
+ ```
337
+
338
+ ### rev stats
339
+ Project dashboard showing overview.
340
+ ```bash
341
+ rev stats # Words, figures, citations, comments
342
+ ```
343
+
344
+ ### rev search
345
+ Search across all section files.
346
+ ```bash
347
+ rev search "climate change"
348
+ rev search -i "method" # Case-insensitive
349
+ ```
350
+
351
+ ### rev figures
352
+ List figures with reference counts.
353
+ ```bash
354
+ rev figures methods.md
355
+ ```
356
+
357
+ ### rev equations
358
+ Work with LaTeX equations.
359
+ ```bash
360
+ rev equations list # List all equations
361
+ rev equations from-word manuscript.docx # Extract from Word
362
+ ```
363
+
364
+ ## Direct DOCX Editing (Layout Workflow)
365
+
366
+ ### rev annotate
367
+ Add comments directly to Word document.
368
+ ```bash
369
+ rev annotate paper.docx -m "Comment" -s "text to find"
370
+ ```
371
+
372
+ ### rev apply
373
+ Apply MD annotations as Word track changes.
374
+ ```bash
375
+ rev apply paper.md output.docx
376
+ ```
377
+
378
+ ### rev comment
379
+ Interactive comment mode for Word documents.
380
+ ```bash
381
+ rev comment paper.docx
382
+ ```
383
+
384
+ ## Project Management
385
+
386
+ ### rev clean
387
+ Remove generated files.
388
+ ```bash
389
+ rev clean # Remove paper.md, PDFs, DOCXs
390
+ rev clean --dry-run # Show what would be deleted
391
+ rev clean --all # Also remove backups and exports
392
+ ```
393
+
394
+ ### rev open
395
+ Open project folder or file.
396
+ ```bash
397
+ rev open # Open project folder
398
+ rev open paper.pdf # Open specific file
399
+ ```
400
+
401
+ ### rev watch
402
+ Auto-rebuild on file changes.
403
+ ```bash
404
+ rev watch # Watch and rebuild
405
+ rev watch pdf # Only rebuild PDF
406
+ rev watch --no-open # Don't open after build
407
+ ```
408
+
409
+ ## Configuration
410
+
411
+ ### rev config
412
+ Configure user settings.
413
+ ```bash
414
+ rev config user "Your Name" # Set author name for replies
415
+ rev config # Show current config
416
+ ```
417
+
418
+ ## rev.yaml Settings
419
+
420
+ ### Output Directory
421
+
422
+ By default, built artefacts land in `output/` next to `rev.yaml`. Both the
423
+ clean output and `--dual` companion (`*_comments.docx` / `*_comments.pdf`)
424
+ follow the configured location. Override or disable:
425
+
426
+ ```yaml
427
+ outputDir: output # default — outputs land in ./output/
428
+ outputDir: dist # custom subdirectory
429
+ outputDir: null # legacy layout — outputs alongside paper.md
430
+ ```
431
+
432
+ Explicit caller-supplied output paths (e.g. internal temp files in the
433
+ dual flow) bypass `outputDir`.
434
+
435
+ ### PDF Engine and Fonts
436
+
437
+ The default PDF engine is `pdflatex`. Switch to xelatex/lualatex when the
438
+ manuscript needs native UTF-8 rendering of Latin-Extended diacritics
439
+ (Czech/Polish/Croatian/Spanish author names, species epithets):
440
+
441
+ ```yaml
442
+ pdf:
443
+ engine: xelatex # or lualatex, tectonic, etc.
444
+ mainfont: "TeX Gyre Termes" # serif (xelatex/lualatex only — uses fontspec)
445
+ sansfont: "TeX Gyre Heros" # sans (optional)
446
+ monofont: "TeX Gyre Cursor" # monospace (optional)
447
+ ```
448
+
449
+ `mainfont`/`sansfont`/`monofont` are forwarded as pandoc `-V` flags and
450
+ require an engine that loads `fontspec` (xelatex or lualatex). They are
451
+ ignored under `pdflatex`.
452
+
453
+ ### Tables
454
+
455
+ Configure table formatting for PDF output:
456
+
457
+ ```yaml
458
+ tables:
459
+ nowrap:
460
+ - Prior # Column headers to keep on one line
461
+ - "$\\widehat{R}$"
462
+ ```
463
+
464
+ In `nowrap` columns, distribution notation is auto-converted to LaTeX math:
465
+ - `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
466
+ - `Student-t(3, 0, 1)` → `$t_3(0, 1)$`
467
+ - `Gamma(2, 0.5)` → `$\text{Gamma}(2, 0.5)$`
468
+ - `Half-Normal(0, 1)` → `$\text{Half-Normal}(0, 1)$`
469
+ - `Exponential(1)` → `$\text{Exp}(1)$`
470
+
471
+ **Tip:** For complex tables, use simple tables (space-aligned with dashes) instead of pipe tables to avoid column width issues:
472
+
473
+ ```markdown
474
+ Parameter Prior Description
475
+ ---------- ------------------------- ------------------
476
+ alpha $\mathcal{N}(0, 0.5)$ Intercept prior
477
+ beta $t_3(0, 2.5)$ Slope prior
478
+ ```
479
+
480
+ ### Postprocess Scripts
481
+
482
+ Run custom scripts after output generation:
483
+
484
+ ```yaml
485
+ postprocess:
486
+ pdf: ./scripts/fix-pdf.py # Runs after PDF
487
+ docx: ./scripts/add-meta.js # Runs after DOCX
488
+ tex: ./scripts/tweak-latex.sh # Runs after TEX
489
+ pptx: ./scripts/fix-slides.ps1 # Runs after PPTX
490
+ all: ./scripts/notify.js # Runs after ANY format
491
+ ```
492
+
493
+ **Environment variables** available to scripts:
494
+
495
+ | Variable | Description |
496
+ |----------|-------------|
497
+ | `OUTPUT_FILE` | Full path to generated file |
498
+ | `OUTPUT_FORMAT` | Format: `pdf`, `docx`, `tex`, `pptx`, `beamer` |
499
+ | `PROJECT_DIR` | Directory containing rev.yaml |
500
+ | `CONFIG_PATH` | Full path to rev.yaml |
501
+
502
+ **Supported script types:** `.js`, `.mjs` (Node), `.py` (Python), `.ps1` (PowerShell), `.sh` (Bash)
503
+
504
+ **Example Python script** (add DOCX metadata):
505
+ ```python
506
+ import os
507
+ from docx import Document
508
+ doc = Document(os.environ['OUTPUT_FILE'])
509
+ doc.core_properties.author = "Research Team"
510
+ doc.save(os.environ['OUTPUT_FILE'])
511
+ ```
512
+
513
+ Use `--verbose` flag to see script output:
514
+ ```bash
515
+ rev build pdf --verbose
516
+ ```
517
+
518
+ ## Shell Completions
519
+
520
+ ### rev completions
521
+ Output shell completions.
522
+ ```bash
523
+ eval "$(rev completions bash)" # Bash
524
+ eval "$(rev completions zsh)" # Zsh
525
+ ```
526
+
527
+ ## AI Skill Installation
528
+
529
+ ### rev install-cli-skill
530
+ Install the docrev skill for AI coding assistants.
531
+ ```bash
532
+ rev install-cli-skill # Install to ~/.claude/skills/docrev
533
+ ```
534
+
535
+ ### rev uninstall-cli-skill
536
+ Remove the installed skill.
537
+ ```bash
538
+ rev uninstall-cli-skill
539
+ ```