docrev 0.11.1 → 0.11.3

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 (144) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +207 -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/annotations.d.ts.map +1 -1
  11. package/dist/lib/annotations.js +28 -0
  12. package/dist/lib/annotations.js.map +1 -1
  13. package/dist/lib/build.d.ts +28 -0
  14. package/dist/lib/build.d.ts.map +1 -1
  15. package/dist/lib/build.js +81 -4
  16. package/dist/lib/build.js.map +1 -1
  17. package/dist/lib/commands/comments.d.ts.map +1 -1
  18. package/dist/lib/commands/comments.js +58 -28
  19. package/dist/lib/commands/comments.js.map +1 -1
  20. package/dist/lib/commands/context.d.ts +1 -0
  21. package/dist/lib/commands/context.d.ts.map +1 -1
  22. package/dist/lib/commands/context.js +1 -0
  23. package/dist/lib/commands/context.js.map +1 -1
  24. package/dist/lib/commands/core.d.ts.map +1 -1
  25. package/dist/lib/commands/core.js +25 -8
  26. package/dist/lib/commands/core.js.map +1 -1
  27. package/dist/lib/commands/response.js +1 -1
  28. package/dist/lib/commands/response.js.map +1 -1
  29. package/dist/lib/commands/utilities.js +164 -164
  30. package/dist/lib/commands/word-tools.js +8 -8
  31. package/dist/lib/grammar.js +3 -3
  32. package/dist/lib/import.d.ts +14 -0
  33. package/dist/lib/import.d.ts.map +1 -1
  34. package/dist/lib/import.js +23 -0
  35. package/dist/lib/import.js.map +1 -1
  36. package/dist/lib/input.d.ts +67 -0
  37. package/dist/lib/input.d.ts.map +1 -0
  38. package/dist/lib/input.js +164 -0
  39. package/dist/lib/input.js.map +1 -0
  40. package/dist/lib/macro-filter.lua +201 -201
  41. package/dist/lib/pdf-comments.js +44 -44
  42. package/dist/lib/plugins.js +57 -57
  43. package/dist/lib/pptx-color-filter.lua +37 -37
  44. package/dist/lib/pptx-themes.js +115 -115
  45. package/dist/lib/response.d.ts +1 -1
  46. package/dist/lib/response.d.ts.map +1 -1
  47. package/dist/lib/response.js +5 -2
  48. package/dist/lib/response.js.map +1 -1
  49. package/dist/lib/schema.d.ts.map +1 -1
  50. package/dist/lib/schema.js +8 -2
  51. package/dist/lib/schema.js.map +1 -1
  52. package/dist/lib/spelling.js +2 -2
  53. package/dist/lib/templates.js +387 -387
  54. package/dist/lib/themes.js +51 -51
  55. package/eslint.config.js +27 -27
  56. package/lib/anchor-match.ts +307 -307
  57. package/lib/annotations.ts +695 -664
  58. package/lib/build.ts +2047 -1956
  59. package/lib/citations.ts +160 -160
  60. package/lib/commands/build.ts +885 -885
  61. package/lib/commands/citations.ts +515 -515
  62. package/lib/commands/comments.ts +1077 -1050
  63. package/lib/commands/context.ts +185 -176
  64. package/lib/commands/core.ts +328 -309
  65. package/lib/commands/doi.ts +451 -451
  66. package/lib/commands/file-ops.ts +372 -372
  67. package/lib/commands/history.ts +320 -320
  68. package/lib/commands/index.ts +87 -87
  69. package/lib/commands/init.ts +259 -259
  70. package/lib/commands/merge-resolve.ts +378 -378
  71. package/lib/commands/preview.ts +178 -178
  72. package/lib/commands/project-info.ts +244 -244
  73. package/lib/commands/quality.ts +517 -517
  74. package/lib/commands/response.ts +454 -454
  75. package/lib/commands/section-boundaries.ts +82 -82
  76. package/lib/commands/sections.ts +451 -451
  77. package/lib/commands/sync.ts +689 -689
  78. package/lib/commands/text-ops.ts +449 -449
  79. package/lib/commands/utilities.ts +448 -448
  80. package/lib/commands/verify-anchors.ts +272 -272
  81. package/lib/commands/word-tools.ts +340 -340
  82. package/lib/comment-realign.ts +99 -99
  83. package/lib/config.ts +84 -84
  84. package/lib/crossref.ts +781 -781
  85. package/lib/csl.ts +191 -191
  86. package/lib/dependencies.ts +132 -132
  87. package/lib/diff-engine.ts +465 -465
  88. package/lib/doi-cache.ts +115 -115
  89. package/lib/doi.ts +879 -879
  90. package/lib/equations.ts +506 -506
  91. package/lib/errors.ts +350 -350
  92. package/lib/format.ts +541 -541
  93. package/lib/git.ts +326 -326
  94. package/lib/grammar.ts +303 -303
  95. package/lib/image-registry.ts +180 -180
  96. package/lib/import.ts +932 -906
  97. package/lib/input.ts +174 -0
  98. package/lib/journals.ts +543 -543
  99. package/lib/macro-filter.lua +201 -201
  100. package/lib/macros.ts +273 -273
  101. package/lib/merge.ts +633 -633
  102. package/lib/ooxml.ts +768 -768
  103. package/lib/orcid.ts +144 -144
  104. package/lib/pdf-comments.ts +263 -263
  105. package/lib/pdf-import.ts +524 -524
  106. package/lib/plugins.ts +362 -362
  107. package/lib/postprocess.ts +188 -188
  108. package/lib/pptx-color-filter.lua +37 -37
  109. package/lib/pptx-template.ts +469 -469
  110. package/lib/pptx-themes.ts +483 -483
  111. package/lib/protect-restore.ts +520 -520
  112. package/lib/rate-limiter.ts +127 -127
  113. package/lib/response.ts +200 -197
  114. package/lib/restore-references.ts +240 -240
  115. package/lib/review.ts +327 -327
  116. package/lib/schema.ts +494 -488
  117. package/lib/scientific-words.ts +73 -73
  118. package/lib/sections.ts +428 -428
  119. package/lib/slides.ts +756 -756
  120. package/lib/spelling.ts +334 -334
  121. package/lib/templates.ts +526 -526
  122. package/lib/themes.ts +742 -742
  123. package/lib/trackchanges.ts +166 -166
  124. package/lib/tui.ts +450 -450
  125. package/lib/types.ts +546 -546
  126. package/lib/undo.ts +250 -250
  127. package/lib/utils.ts +69 -69
  128. package/lib/variables.ts +179 -179
  129. package/lib/word-extraction.ts +525 -525
  130. package/lib/word.ts +526 -526
  131. package/lib/wordcomments.ts +789 -789
  132. package/package.json +1 -1
  133. package/scripts/postbuild.js +47 -47
  134. package/skill/REFERENCE.md +550 -550
  135. package/skill/SKILL.md +302 -302
  136. package/tsconfig.json +26 -26
  137. package/types/index.d.ts +531 -531
  138. package/issues.md +0 -180
  139. package/site/assets/extra.css +0 -208
  140. package/site/commands.html +0 -926
  141. package/site/configuration.html +0 -469
  142. package/site/index.html +0 -288
  143. package/site/troubleshooting.html +0 -461
  144. package/site/workflow.html +0 -518
package/README.md CHANGED
@@ -1,433 +1,433 @@
1
- # docrev
2
-
3
- [![npm](https://img.shields.io/npm/v/docrev)](https://www.npmjs.com/package/docrev)
4
- [![npm downloads](https://img.shields.io/npm/dm/docrev)](https://www.npmjs.com/package/docrev)
5
- [![node](https://img.shields.io/node/v/docrev)](https://nodejs.org)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
- [![CI](https://github.com/gcol33/docrev/actions/workflows/ci.yml/badge.svg)](https://github.com/gcol33/docrev/actions/workflows/ci.yml)
8
-
9
- A CLI for writing documents in Markdown while collaborating with Word users.
10
-
11
- Write in `.md` files under version control; build Word or PDF when you need to share. When reviewers return their annotated copy, `rev sync` pulls the feedback into your markdown sections, where you reply to comments, accept or reject changes, and rebuild. Equations, figures, citations, and cross-references survive both directions.
12
-
13
- ## The Problem
14
-
15
- After a few rounds of feedback, the project directory looks like this:
16
-
17
- ```
18
- manuscript_v1.docx
19
- manuscript_v2_john_comments.docx
20
- manuscript_v2_jane_comments.docx
21
- manuscript_v3_merged_final.docx
22
- manuscript_v3_merged_final_REAL.docx
23
- manuscript_v3_merged_final_REAL_submitted.docx
24
- ```
25
-
26
- By the third filename, the document has split. One file has Jane's comments, another has John's track changes, a third has your reconciliation, and which one is current depends on what you remember. Reconciliation takes an afternoon and goes wrong every time the Word formatting drifts.
27
-
28
- docrev keeps the markdown as the canonical version, under git. The DOCX is rebuilt each time you share; reviewer comments and track changes come back into your section files when you sync, where you reply to or accept them in the terminal.
29
-
30
- ## Highlights
31
-
32
- - **Markdown → Word/PDF** with citations, figures, equations, cross-references
33
- - **Round-trip sync**: import Word track changes and comments back to Markdown
34
- - **CLI review workflow**: reply to comments, accept/reject changes from terminal
35
- - **DOI tools**: validate, lookup, and auto-add references from DOIs
36
- - **21 journal styles**: Nature, Science, PNAS, and more
37
- - **Version control friendly**: plain text source, full git history
38
-
39
- ## Install
40
-
41
- ```bash
42
- npm install -g docrev
43
- ```
44
-
45
- Requires [Node.js](https://nodejs.org) 18+. Building DOCX or PDF needs [Pandoc](https://pandoc.org). For complex PDFs (math, cross-references, journal styles), [LaTeX](#installing-dependencies) is also needed; simpler documents can build through pandoc alone with a non-LaTeX engine (e.g. `pdf.engine: typst` in `rev.yaml`).
46
-
47
- ## Quick Example
48
-
49
- Write in Markdown with citations and cross-references:
50
-
51
- ```markdown
52
- Climate change poses significant challenges [@IPCC2021]. As shown in
53
- @fig:temperature, global temperatures have risen steadily.
54
-
55
- ![Temperature anomalies](figures/temperature.png){#fig:temperature}
56
-
57
- The relationship follows $\Delta T = \lambda \cdot \Delta F$ (@eq:forcing).
58
- ```
59
-
60
- Build and share:
61
-
62
- ```bash
63
- rev build docx # → output/paper.docx
64
- rev build pdf # → output/paper.pdf
65
- ```
66
-
67
- When collaborators return the Word doc with track changes:
68
-
69
- ```bash
70
- rev sync reviewed.docx # their comments → your markdown
71
- ```
72
-
73
- ## How It Works
74
-
75
- ```
76
- ┌─────────────┐ rev build docx ┌─────────────┐
77
- │ │ ───────────────────────→│ │
78
- │ Markdown │ │ Word │ → collaborators
79
- │ (you) │ rev build pdf │ / PDF │ → journals
80
- │ │ ───────────────────────→│ │
81
- └─────────────┘ └─────────────┘
82
- ↑ │
83
- │ rev sync │
84
- └───────────────────────────────────────┘
85
- their feedback → your files
86
- ```
87
-
88
- ## What's in a Project
89
-
90
- `rev new my-paper` creates the project. It prompts for the section names (default: `introduction, methods, results, discussion`) or accepts them up front via `-s intro,methods,results,discussion`. Each name becomes its own `.md` file. (`rev import some.docx` is the other entry point — it splits an existing Word document into one section per top-level heading.)
91
-
92
- ```
93
- my-paper/
94
- ├── rev.yaml ← config: title, authors, section order, journal profile
95
- ├── intro.md ← section files; named at creation, one per section
96
- ├── methods.md
97
- ├── results.md
98
- ├── discussion.md
99
- ├── references.bib ← BibTeX bibliography
100
- ├── figures/ ← images referenced from sections
101
- ├── paper.md ← auto-combined source, regenerated each build
102
- └── output/ ← built artefacts (docx, pdf, tex)
103
- ├── my-paper.docx
104
- └── my-paper.pdf
105
- ```
106
-
107
- You edit the section files and the config; everything else is generated. `paper.md` is rebuilt from the section files in the order set by `rev.yaml`, and `output/` holds whatever the last build produced. After `rev sync`, comments and track changes from the reviewer's Word file appear inline in the section files as CriticMarkup annotations. Set `outputDir: null` in `rev.yaml` if you'd rather have outputs land alongside `paper.md`.
108
-
109
- To set your own per-user default sections so future `rev new` calls skip the prompt:
110
-
111
- ```bash
112
- rev config sections "intro,methods,results,discussion"
113
- ```
114
-
115
- ## The CLI Review Cycle
116
-
117
- When reviewers send back a Word document with track changes and comments:
118
-
119
- ```bash
120
- rev sync reviewed.docx # import feedback into markdown
121
- ```
122
-
123
- Track changes appear inline - accept or reject by editing:
124
-
125
- ```markdown
126
- The sample size was {--100--}{++150++} participants.
127
- ```
128
-
129
- Handle comments without opening Word:
130
-
131
- ```bash
132
- rev comments # list all comments
133
- rev reply methods.md -n 1 -m "Added clarification"
134
- rev resolve methods.md -n 1 # mark as resolved
135
- rev build docx --dual # clean + annotated versions
136
- rev build docx --dual --show-changes # one file: tracked changes + threaded comments
137
- ```
138
-
139
- PDF annotations work the same way:
140
-
141
- ```bash
142
- rev sync annotated.pdf
143
- rev pdf-comments annotated.pdf --append methods.md
144
- ```
145
-
146
- When several reviewers return separate files, `rev merge` reconciles them:
147
-
148
- ```bash
149
- rev merge reviewer_A.docx reviewer_B.docx
150
- ```
151
-
152
- Each reviewer's file is compared against `.rev/base.docx` (auto-saved on every build) to isolate that reviewer's changes; conflicts on the same passage are flagged for interactive resolution.
153
-
154
- ## Getting Started
155
-
156
- ### Starting a New Document
157
-
158
- Create a new project:
159
-
160
- ```bash
161
- rev new my-report
162
- cd my-report
163
- ```
164
-
165
- You'll be prompted to enter your section names, or press Enter to use the default structure. You can also specify sections directly:
166
-
167
- ```bash
168
- rev new my-report -s intro,methods,results,discussion
169
- ```
170
-
171
- Or set your preferred default sections once:
172
-
173
- ```bash
174
- rev config sections "intro,methods,results,discussion"
175
- ```
176
-
177
- This creates the project folder with your section files — edit them, then build:
178
-
179
- ```bash
180
- rev build docx pdf
181
- ```
182
-
183
- The output filename comes from `title` in `rev.yaml`. Citations are resolved, equations rendered, and cross-references numbered. The directory layout is described above in [What's in a Project](#whats-in-a-project).
184
-
185
- ### Starting from an Existing Word Document
186
-
187
- If you have a Word document to convert:
188
-
189
- ```bash
190
- rev import manuscript.docx
191
- ```
192
-
193
- This creates a project folder and splits the document into section files. Images are extracted to `figures/`, equations are converted to LaTeX, and track changes/comments are preserved as markdown annotations.
194
-
195
- ### Configuration
196
-
197
- Layout is controlled in `rev.yaml`:
198
-
199
- ```yaml
200
- title: "My Document"
201
- authors: []
202
- sections:
203
- - intro.md
204
- - methods.md
205
- - results.md
206
- - discussion.md
207
-
208
- # Where built artefacts land (default: output/). Set to null for the
209
- # legacy "outputs alongside paper.md" layout.
210
- outputDir: output
211
-
212
- docx:
213
- reference: template.docx # your Word template
214
-
215
- pdf:
216
- documentclass: article
217
- fontsize: 12pt
218
- engine: pdflatex # or xelatex/lualatex for Latin-Extended
219
- # Fonts apply only under xelatex/lualatex (fontspec):
220
- # mainfont: "TeX Gyre Termes"
221
- # sansfont: "TeX Gyre Heros"
222
- # monofont: "TeX Gyre Cursor"
223
- ```
224
-
225
- Switch to `engine: xelatex` (or `lualatex`) when the manuscript has Czech/Polish/Croatian/Spanish names or species epithets that `pdflatex` mangles. Under those engines, `mainfont`/`sansfont`/`monofont` are forwarded to pandoc.
226
-
227
- Configure your name for comment replies:
228
-
229
- ```bash
230
- rev config user "Your Name"
231
- ```
232
-
233
- ### Table Formatting
234
-
235
- For PDF output, configure columns that should not wrap:
236
-
237
- ```yaml
238
- tables:
239
- nowrap:
240
- - Prior # column headers to keep on one line
241
- - "$\\widehat{R}$"
242
- ```
243
-
244
- Distribution notation in nowrap columns is auto-converted to LaTeX math:
245
- `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
246
-
247
- ### Placeholder Macros
248
-
249
- Mark unfinished spots in a draft with `\tofill{X}` and they highlight as bold
250
- orange `[X]` in every output format:
251
-
252
- ```markdown
253
- We collected data from \tofill{N sites} between \tofill{date range}.
254
- ```
255
-
256
- The macro works in DOCX, PDF, TeX, Beamer, and HTML without any per-project
257
- filter setup. Add custom macros (e.g. `\note`, `\citeNeeded`) under `macros:`
258
- in `rev.yaml`:
259
-
260
- ```yaml
261
- macros:
262
- - name: note
263
- default:
264
- color: "1E40AF" # 6-digit hex, no '#'
265
- bold: true
266
- prefix: "NOTE: "
267
- ```
268
-
269
- See [docs/configuration.md](docs/configuration.md) for the full schema and
270
- per-format overrides.
271
-
272
- ### Postprocess Scripts
273
-
274
- Run custom scripts after output generation:
275
-
276
- ```yaml
277
- postprocess:
278
- pdf: ./scripts/fix-tables.py # runs after PDF
279
- docx: ./scripts/add-meta.js # runs after DOCX
280
- all: ./scripts/notify.sh # runs after any format
281
- ```
282
-
283
- Scripts receive environment variables: `OUTPUT_FILE`, `OUTPUT_FORMAT`, `PROJECT_DIR`, `CONFIG_PATH`.
284
-
285
- Use `--verbose` to see script output:
286
-
287
- ```bash
288
- rev build pdf --verbose
289
- ```
290
-
291
- ### Journal Profiles
292
-
293
- Journal profiles provide both validation rules and build formatting defaults. Set in `rev.yaml`:
294
-
295
- ```yaml
296
- journal: nature
297
- ```
298
-
299
- Or pass on the command line:
300
-
301
- ```bash
302
- rev build pdf -j nature # applies Nature's CSL style + PDF settings
303
- ```
304
-
305
- When a journal is set, its formatting defaults (CSL citation style, font size, margins, line spacing) are applied automatically. Your explicit `rev.yaml` settings always take priority.
306
-
307
- Six profiles include formatting: `nature`, `science`, `cell`, `pnas`, `plos-one`, `elife`. All 21 profiles support validation. Custom profiles can include formatting too — see [docs/configuration.md](docs/configuration.md).
308
-
309
- ```bash
310
- rev validate --list # see all profiles ([formatting] tag = build support)
311
- rev profiles --fetch-csl apa # download a CSL style to cache
312
- rev profiles --list-csl # list cached CSL styles
313
- ```
314
-
315
- ## Annotation Syntax
316
-
317
- Track changes from Word appear as [CriticMarkup](http://criticmarkup.com/):
318
-
319
- ```markdown
320
- The sample size was {--100--}{++150++} participants. # deletion + insertion
321
- Data was collected {~~monthly~>weekly~~}. # substitution
322
- {>>Reviewer 2: Please clarify.<<} # comment
323
- ```
324
-
325
- ## Writing Tips
326
-
327
- Track word count changes between versions:
328
-
329
- ```bash
330
- rev diff # compare against last commit
331
- # methods.md +142 words -38 words
332
- # results.md +89 words -12 words
333
- ```
334
-
335
- Add references to `references.bib` (BibTeX format):
336
-
337
- ```bibtex
338
- @article{Smith2020,
339
- author = {Smith, Jane},
340
- title = {Paper Title},
341
- journal = {Nature},
342
- year = {2020},
343
- doi = {10.1038/example}
344
- }
345
- ```
346
-
347
- Cite with `[@Smith2020]` or `[@Smith2020; @Jones2021]` for multiple sources.
348
-
349
- Equations use LaTeX: inline `$E = mc^2$` or display `$$\sum_{i=1}^{n} x_i$$`.
350
-
351
- Cross-references: `@fig:label`, `@tbl:label`, `@eq:label` → "Figure 1", "Table 2", "Equation 3".
352
-
353
- ## Command Reference
354
-
355
- | Task | Command |
356
- |------|---------|
357
- | Create project | `rev new my-project` |
358
- | Create LaTeX project | `rev new my-project --template latex` |
359
- | Import Word document | `rev import manuscript.docx` |
360
- | Extract Word equations | `rev equations from-word doc.docx` |
361
- | Build DOCX | `rev build docx` |
362
- | Build PDF | `rev build pdf` |
363
- | Build clean + annotated | `rev build docx --dual` |
364
- | Build with visible track changes | `rev build docx --show-changes` |
365
- | Build tracked changes + comments in one file | `rev build docx --dual --show-changes` |
366
- | Sync Word feedback | `rev sync reviewed.docx` |
367
- | Sync PDF comments | `rev sync annotated.pdf` |
368
- | Extract PDF comments | `rev pdf-comments annotated.pdf` |
369
- | Extract with highlighted text | `rev pdf-comments file.pdf --with-text` |
370
- | Project status | `rev status` |
371
- | Next pending comment | `rev next` |
372
- | List pending comments | `rev todo` |
373
- | Filter by author | `rev comments file.md --author "Reviewer 2"` |
374
- | Accept all changes | `rev accept file.md -a` |
375
- | Reject change | `rev reject file.md -n 1` |
376
- | Reply to comment | `rev reply file.md -n 1 -m "response"` |
377
- | Reply to all pending | `rev reply file.md --all -m "Addressed"` |
378
- | Resolve comment | `rev resolve file.md -n 1` |
379
- | Show contributors | `rev contributors` |
380
- | Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
381
- | Merge reviewer feedback | `rev merge reviewer_A.docx reviewer_B.docx` |
382
- | Archive reviewer files | `rev archive` |
383
- | Check DOIs | `rev doi check references.bib` |
384
- | Find missing DOIs | `rev doi lookup references.bib` |
385
- | Add citation from DOI | `rev doi add 10.1038/example` |
386
- | Word count | `rev wc` |
387
- | Pre-submission check | `rev check` |
388
- | Check for updates | `rev upgrade --check` |
389
-
390
- Run `rev help` to see all commands, or `rev help <command>` for details on a specific command.
391
-
392
- Full command reference: [docs/commands.md](docs/commands.md)
393
-
394
- ## Claude Code Skill
395
-
396
- Install the docrev skill for [Claude Code](https://claude.ai/code):
397
-
398
- ```bash
399
- rev install-cli-skill # install to ~/.claude/skills/docrev
400
- rev uninstall-cli-skill # remove
401
- ```
402
-
403
- Once installed, Claude understands docrev commands and can help navigate comments, draft replies, and manage your revision cycle.
404
-
405
- ## Installing Dependencies
406
-
407
- ### Pandoc
408
-
409
- [Pandoc](https://pandoc.org) handles document conversion.
410
-
411
- | Platform | Command |
412
- |----------|---------|
413
- | macOS | `brew install pandoc` |
414
- | Windows | `winget install JohnMacFarlane.Pandoc` |
415
- | Debian/Ubuntu | `sudo apt install pandoc` |
416
- | Fedora | `sudo dnf install pandoc` |
417
-
418
- Other platforms: [pandoc.org/installing](https://pandoc.org/installing.html)
419
-
420
- ### LaTeX (for complex PDF builds)
421
-
422
- | Platform | Command |
423
- |----------|---------|
424
- | macOS | `brew install --cask mactex` |
425
- | Windows | `winget install MiKTeX.MiKTeX` |
426
- | Debian/Ubuntu | `sudo apt install texlive-full` |
427
- | Fedora | `sudo dnf install texlive-scheme-full` |
428
-
429
- Alternatively, [TinyTeX](https://yihui.org/tinytex/) provides a minimal distribution that downloads packages on demand.
430
-
431
- ## License
432
-
433
- MIT
1
+ # docrev
2
+
3
+ [![npm](https://img.shields.io/npm/v/docrev)](https://www.npmjs.com/package/docrev)
4
+ [![npm downloads](https://img.shields.io/npm/dm/docrev)](https://www.npmjs.com/package/docrev)
5
+ [![node](https://img.shields.io/node/v/docrev)](https://nodejs.org)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+ [![CI](https://github.com/gcol33/docrev/actions/workflows/ci.yml/badge.svg)](https://github.com/gcol33/docrev/actions/workflows/ci.yml)
8
+
9
+ A CLI for writing documents in Markdown while collaborating with Word users.
10
+
11
+ Write in `.md` files under version control; build Word or PDF when you need to share. When reviewers return their annotated copy, `rev sync` pulls the feedback into your markdown sections, where you reply to comments, accept or reject changes, and rebuild. Equations, figures, citations, and cross-references survive both directions.
12
+
13
+ ## The Problem
14
+
15
+ After a few rounds of feedback, the project directory looks like this:
16
+
17
+ ```
18
+ manuscript_v1.docx
19
+ manuscript_v2_john_comments.docx
20
+ manuscript_v2_jane_comments.docx
21
+ manuscript_v3_merged_final.docx
22
+ manuscript_v3_merged_final_REAL.docx
23
+ manuscript_v3_merged_final_REAL_submitted.docx
24
+ ```
25
+
26
+ By the third filename, the document has split. One file has Jane's comments, another has John's track changes, a third has your reconciliation, and which one is current depends on what you remember. Reconciliation takes an afternoon and goes wrong every time the Word formatting drifts.
27
+
28
+ docrev keeps the markdown as the canonical version, under git. The DOCX is rebuilt each time you share; reviewer comments and track changes come back into your section files when you sync, where you reply to or accept them in the terminal.
29
+
30
+ ## Highlights
31
+
32
+ - **Markdown → Word/PDF** with citations, figures, equations, cross-references
33
+ - **Round-trip sync**: import Word track changes and comments back to Markdown
34
+ - **CLI review workflow**: reply to comments, accept/reject changes from terminal
35
+ - **DOI tools**: validate, lookup, and auto-add references from DOIs
36
+ - **21 journal styles**: Nature, Science, PNAS, and more
37
+ - **Version control friendly**: plain text source, full git history
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install -g docrev
43
+ ```
44
+
45
+ Requires [Node.js](https://nodejs.org) 18+. Building DOCX or PDF needs [Pandoc](https://pandoc.org). For complex PDFs (math, cross-references, journal styles), [LaTeX](#installing-dependencies) is also needed; simpler documents can build through pandoc alone with a non-LaTeX engine (e.g. `pdf.engine: typst` in `rev.yaml`).
46
+
47
+ ## Quick Example
48
+
49
+ Write in Markdown with citations and cross-references:
50
+
51
+ ```markdown
52
+ Climate change poses significant challenges [@IPCC2021]. As shown in
53
+ @fig:temperature, global temperatures have risen steadily.
54
+
55
+ ![Temperature anomalies](figures/temperature.png){#fig:temperature}
56
+
57
+ The relationship follows $\Delta T = \lambda \cdot \Delta F$ (@eq:forcing).
58
+ ```
59
+
60
+ Build and share:
61
+
62
+ ```bash
63
+ rev build docx # → output/paper.docx
64
+ rev build pdf # → output/paper.pdf
65
+ ```
66
+
67
+ When collaborators return the Word doc with track changes:
68
+
69
+ ```bash
70
+ rev sync reviewed.docx # their comments → your markdown
71
+ ```
72
+
73
+ ## How It Works
74
+
75
+ ```
76
+ ┌─────────────┐ rev build docx ┌─────────────┐
77
+ │ │ ───────────────────────→│ │
78
+ │ Markdown │ │ Word │ → collaborators
79
+ │ (you) │ rev build pdf │ / PDF │ → journals
80
+ │ │ ───────────────────────→│ │
81
+ └─────────────┘ └─────────────┘
82
+ ↑ │
83
+ │ rev sync │
84
+ └───────────────────────────────────────┘
85
+ their feedback → your files
86
+ ```
87
+
88
+ ## What's in a Project
89
+
90
+ `rev new my-paper` creates the project. It prompts for the section names (default: `introduction, methods, results, discussion`) or accepts them up front via `-s intro,methods,results,discussion`. Each name becomes its own `.md` file. (`rev import some.docx` is the other entry point — it splits an existing Word document into one section per top-level heading.)
91
+
92
+ ```
93
+ my-paper/
94
+ ├── rev.yaml ← config: title, authors, section order, journal profile
95
+ ├── intro.md ← section files; named at creation, one per section
96
+ ├── methods.md
97
+ ├── results.md
98
+ ├── discussion.md
99
+ ├── references.bib ← BibTeX bibliography
100
+ ├── figures/ ← images referenced from sections
101
+ ├── paper.md ← auto-combined source, regenerated each build
102
+ └── output/ ← built artefacts (docx, pdf, tex)
103
+ ├── my-paper.docx
104
+ └── my-paper.pdf
105
+ ```
106
+
107
+ You edit the section files and the config; everything else is generated. `paper.md` is rebuilt from the section files in the order set by `rev.yaml`, and `output/` holds whatever the last build produced. After `rev sync`, comments and track changes from the reviewer's Word file appear inline in the section files as CriticMarkup annotations. Set `outputDir: null` in `rev.yaml` if you'd rather have outputs land alongside `paper.md`.
108
+
109
+ To set your own per-user default sections so future `rev new` calls skip the prompt:
110
+
111
+ ```bash
112
+ rev config sections "intro,methods,results,discussion"
113
+ ```
114
+
115
+ ## The CLI Review Cycle
116
+
117
+ When reviewers send back a Word document with track changes and comments:
118
+
119
+ ```bash
120
+ rev sync reviewed.docx # import feedback into markdown
121
+ ```
122
+
123
+ Track changes appear inline - accept or reject by editing:
124
+
125
+ ```markdown
126
+ The sample size was {--100--}{++150++} participants.
127
+ ```
128
+
129
+ Handle comments without opening Word:
130
+
131
+ ```bash
132
+ rev comments # list all comments
133
+ rev reply methods.md -n 1 -m "Added clarification"
134
+ rev resolve methods.md -n 1 # mark as resolved
135
+ rev build docx --dual # clean + annotated versions
136
+ rev build docx --dual --show-changes # one file: tracked changes + threaded comments
137
+ ```
138
+
139
+ PDF annotations work the same way:
140
+
141
+ ```bash
142
+ rev sync annotated.pdf
143
+ rev pdf-comments annotated.pdf --append methods.md
144
+ ```
145
+
146
+ When several reviewers return separate files, `rev merge` reconciles them:
147
+
148
+ ```bash
149
+ rev merge reviewer_A.docx reviewer_B.docx
150
+ ```
151
+
152
+ Each reviewer's file is compared against `.rev/base.docx` (auto-saved on every build) to isolate that reviewer's changes; conflicts on the same passage are flagged for interactive resolution.
153
+
154
+ ## Getting Started
155
+
156
+ ### Starting a New Document
157
+
158
+ Create a new project:
159
+
160
+ ```bash
161
+ rev new my-report
162
+ cd my-report
163
+ ```
164
+
165
+ You'll be prompted to enter your section names, or press Enter to use the default structure. You can also specify sections directly:
166
+
167
+ ```bash
168
+ rev new my-report -s intro,methods,results,discussion
169
+ ```
170
+
171
+ Or set your preferred default sections once:
172
+
173
+ ```bash
174
+ rev config sections "intro,methods,results,discussion"
175
+ ```
176
+
177
+ This creates the project folder with your section files — edit them, then build:
178
+
179
+ ```bash
180
+ rev build docx pdf
181
+ ```
182
+
183
+ The output filename comes from `title` in `rev.yaml`. Citations are resolved, equations rendered, and cross-references numbered. The directory layout is described above in [What's in a Project](#whats-in-a-project).
184
+
185
+ ### Starting from an Existing Word Document
186
+
187
+ If you have a Word document to convert:
188
+
189
+ ```bash
190
+ rev import manuscript.docx
191
+ ```
192
+
193
+ This creates a project folder and splits the document into section files. Images are extracted to `figures/`, equations are converted to LaTeX, and track changes/comments are preserved as markdown annotations.
194
+
195
+ ### Configuration
196
+
197
+ Layout is controlled in `rev.yaml`:
198
+
199
+ ```yaml
200
+ title: "My Document"
201
+ authors: []
202
+ sections:
203
+ - intro.md
204
+ - methods.md
205
+ - results.md
206
+ - discussion.md
207
+
208
+ # Where built artefacts land (default: output/). Set to null for the
209
+ # legacy "outputs alongside paper.md" layout.
210
+ outputDir: output
211
+
212
+ docx:
213
+ reference: template.docx # your Word template
214
+
215
+ pdf:
216
+ documentclass: article
217
+ fontsize: 12pt
218
+ engine: pdflatex # or xelatex/lualatex for Latin-Extended
219
+ # Fonts apply only under xelatex/lualatex (fontspec):
220
+ # mainfont: "TeX Gyre Termes"
221
+ # sansfont: "TeX Gyre Heros"
222
+ # monofont: "TeX Gyre Cursor"
223
+ ```
224
+
225
+ Switch to `engine: xelatex` (or `lualatex`) when the manuscript has Czech/Polish/Croatian/Spanish names or species epithets that `pdflatex` mangles. Under those engines, `mainfont`/`sansfont`/`monofont` are forwarded to pandoc.
226
+
227
+ Configure your name for comment replies:
228
+
229
+ ```bash
230
+ rev config user "Your Name"
231
+ ```
232
+
233
+ ### Table Formatting
234
+
235
+ For PDF output, configure columns that should not wrap:
236
+
237
+ ```yaml
238
+ tables:
239
+ nowrap:
240
+ - Prior # column headers to keep on one line
241
+ - "$\\widehat{R}$"
242
+ ```
243
+
244
+ Distribution notation in nowrap columns is auto-converted to LaTeX math:
245
+ `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
246
+
247
+ ### Placeholder Macros
248
+
249
+ Mark unfinished spots in a draft with `\tofill{X}` and they highlight as bold
250
+ orange `[X]` in every output format:
251
+
252
+ ```markdown
253
+ We collected data from \tofill{N sites} between \tofill{date range}.
254
+ ```
255
+
256
+ The macro works in DOCX, PDF, TeX, Beamer, and HTML without any per-project
257
+ filter setup. Add custom macros (e.g. `\note`, `\citeNeeded`) under `macros:`
258
+ in `rev.yaml`:
259
+
260
+ ```yaml
261
+ macros:
262
+ - name: note
263
+ default:
264
+ color: "1E40AF" # 6-digit hex, no '#'
265
+ bold: true
266
+ prefix: "NOTE: "
267
+ ```
268
+
269
+ See [docs/configuration.md](docs/configuration.md) for the full schema and
270
+ per-format overrides.
271
+
272
+ ### Postprocess Scripts
273
+
274
+ Run custom scripts after output generation:
275
+
276
+ ```yaml
277
+ postprocess:
278
+ pdf: ./scripts/fix-tables.py # runs after PDF
279
+ docx: ./scripts/add-meta.js # runs after DOCX
280
+ all: ./scripts/notify.sh # runs after any format
281
+ ```
282
+
283
+ Scripts receive environment variables: `OUTPUT_FILE`, `OUTPUT_FORMAT`, `PROJECT_DIR`, `CONFIG_PATH`.
284
+
285
+ Use `--verbose` to see script output:
286
+
287
+ ```bash
288
+ rev build pdf --verbose
289
+ ```
290
+
291
+ ### Journal Profiles
292
+
293
+ Journal profiles provide both validation rules and build formatting defaults. Set in `rev.yaml`:
294
+
295
+ ```yaml
296
+ journal: nature
297
+ ```
298
+
299
+ Or pass on the command line:
300
+
301
+ ```bash
302
+ rev build pdf -j nature # applies Nature's CSL style + PDF settings
303
+ ```
304
+
305
+ When a journal is set, its formatting defaults (CSL citation style, font size, margins, line spacing) are applied automatically. Your explicit `rev.yaml` settings always take priority.
306
+
307
+ Six profiles include formatting: `nature`, `science`, `cell`, `pnas`, `plos-one`, `elife`. All 21 profiles support validation. Custom profiles can include formatting too — see [docs/configuration.md](docs/configuration.md).
308
+
309
+ ```bash
310
+ rev validate --list # see all profiles ([formatting] tag = build support)
311
+ rev profiles --fetch-csl apa # download a CSL style to cache
312
+ rev profiles --list-csl # list cached CSL styles
313
+ ```
314
+
315
+ ## Annotation Syntax
316
+
317
+ Track changes from Word appear as [CriticMarkup](http://criticmarkup.com/):
318
+
319
+ ```markdown
320
+ The sample size was {--100--}{++150++} participants. # deletion + insertion
321
+ Data was collected {~~monthly~>weekly~~}. # substitution
322
+ {>>Reviewer 2: Please clarify.<<} # comment
323
+ ```
324
+
325
+ ## Writing Tips
326
+
327
+ Track word count changes between versions:
328
+
329
+ ```bash
330
+ rev diff # compare against last commit
331
+ # methods.md +142 words -38 words
332
+ # results.md +89 words -12 words
333
+ ```
334
+
335
+ Add references to `references.bib` (BibTeX format):
336
+
337
+ ```bibtex
338
+ @article{Smith2020,
339
+ author = {Smith, Jane},
340
+ title = {Paper Title},
341
+ journal = {Nature},
342
+ year = {2020},
343
+ doi = {10.1038/example}
344
+ }
345
+ ```
346
+
347
+ Cite with `[@Smith2020]` or `[@Smith2020; @Jones2021]` for multiple sources.
348
+
349
+ Equations use LaTeX: inline `$E = mc^2$` or display `$$\sum_{i=1}^{n} x_i$$`.
350
+
351
+ Cross-references: `@fig:label`, `@tbl:label`, `@eq:label` → "Figure 1", "Table 2", "Equation 3".
352
+
353
+ ## Command Reference
354
+
355
+ | Task | Command |
356
+ |------|---------|
357
+ | Create project | `rev new my-project` |
358
+ | Create LaTeX project | `rev new my-project --template latex` |
359
+ | Import Word document | `rev import manuscript.docx` |
360
+ | Extract Word equations | `rev equations from-word doc.docx` |
361
+ | Build DOCX | `rev build docx` |
362
+ | Build PDF | `rev build pdf` |
363
+ | Build clean + annotated | `rev build docx --dual` |
364
+ | Build with visible track changes | `rev build docx --show-changes` |
365
+ | Build tracked changes + comments in one file | `rev build docx --dual --show-changes` |
366
+ | Sync Word feedback | `rev sync reviewed.docx` |
367
+ | Sync PDF comments | `rev sync annotated.pdf` |
368
+ | Extract PDF comments | `rev pdf-comments annotated.pdf` |
369
+ | Extract with highlighted text | `rev pdf-comments file.pdf --with-text` |
370
+ | Project status | `rev status` |
371
+ | Next pending comment | `rev next` |
372
+ | List pending comments | `rev todo` |
373
+ | Filter by author | `rev comments file.md --author "Reviewer 2"` |
374
+ | Accept all changes | `rev accept file.md -a` |
375
+ | Reject change | `rev reject file.md -n 1` |
376
+ | Reply to comment | `rev reply file.md -n 1 -m "response"` |
377
+ | Reply to all pending | `rev reply file.md --all -m "Addressed"` |
378
+ | Resolve comment | `rev resolve file.md -n 1` |
379
+ | Show contributors | `rev contributors` |
380
+ | Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
381
+ | Merge reviewer feedback | `rev merge reviewer_A.docx reviewer_B.docx` |
382
+ | Archive reviewer files | `rev archive` |
383
+ | Check DOIs | `rev doi check references.bib` |
384
+ | Find missing DOIs | `rev doi lookup references.bib` |
385
+ | Add citation from DOI | `rev doi add 10.1038/example` |
386
+ | Word count | `rev wc` |
387
+ | Pre-submission check | `rev check` |
388
+ | Check for updates | `rev upgrade --check` |
389
+
390
+ Run `rev help` to see all commands, or `rev help <command>` for details on a specific command.
391
+
392
+ Full command reference: [docs/commands.md](docs/commands.md)
393
+
394
+ ## Claude Code Skill
395
+
396
+ Install the docrev skill for [Claude Code](https://claude.ai/code):
397
+
398
+ ```bash
399
+ rev install-cli-skill # install to ~/.claude/skills/docrev
400
+ rev uninstall-cli-skill # remove
401
+ ```
402
+
403
+ Once installed, Claude understands docrev commands and can help navigate comments, draft replies, and manage your revision cycle.
404
+
405
+ ## Installing Dependencies
406
+
407
+ ### Pandoc
408
+
409
+ [Pandoc](https://pandoc.org) handles document conversion.
410
+
411
+ | Platform | Command |
412
+ |----------|---------|
413
+ | macOS | `brew install pandoc` |
414
+ | Windows | `winget install JohnMacFarlane.Pandoc` |
415
+ | Debian/Ubuntu | `sudo apt install pandoc` |
416
+ | Fedora | `sudo dnf install pandoc` |
417
+
418
+ Other platforms: [pandoc.org/installing](https://pandoc.org/installing.html)
419
+
420
+ ### LaTeX (for complex PDF builds)
421
+
422
+ | Platform | Command |
423
+ |----------|---------|
424
+ | macOS | `brew install --cask mactex` |
425
+ | Windows | `winget install MiKTeX.MiKTeX` |
426
+ | Debian/Ubuntu | `sudo apt install texlive-full` |
427
+ | Fedora | `sudo dnf install texlive-scheme-full` |
428
+
429
+ Alternatively, [TinyTeX](https://yihui.org/tinytex/) provides a minimal distribution that downloads packages on demand.
430
+
431
+ ## License
432
+
433
+ MIT