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