docrev 0.9.18 → 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 (134) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +173 -149
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +431 -406
  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 +8 -0
  11. package/dist/lib/build.d.ts.map +1 -1
  12. package/dist/lib/build.js +62 -6
  13. package/dist/lib/build.js.map +1 -1
  14. package/dist/lib/commands/context.d.ts +1 -1
  15. package/dist/lib/commands/context.d.ts.map +1 -1
  16. package/dist/lib/commands/context.js +1 -1
  17. package/dist/lib/commands/context.js.map +1 -1
  18. package/dist/lib/commands/sections.js +7 -7
  19. package/dist/lib/commands/sections.js.map +1 -1
  20. package/dist/lib/commands/sync.d.ts.map +1 -1
  21. package/dist/lib/commands/sync.js +15 -14
  22. package/dist/lib/commands/sync.js.map +1 -1
  23. package/dist/lib/commands/utilities.js +164 -164
  24. package/dist/lib/commands/verify-anchors.js +6 -6
  25. package/dist/lib/commands/verify-anchors.js.map +1 -1
  26. package/dist/lib/commands/word-tools.js +8 -8
  27. package/dist/lib/grammar.js +3 -3
  28. package/dist/lib/macro-filter.lua +201 -0
  29. package/dist/lib/macros.d.ts +102 -0
  30. package/dist/lib/macros.d.ts.map +1 -0
  31. package/dist/lib/macros.js +218 -0
  32. package/dist/lib/macros.js.map +1 -0
  33. package/dist/lib/pdf-comments.js +44 -44
  34. package/dist/lib/plugins.js +57 -57
  35. package/dist/lib/pptx-color-filter.lua +37 -0
  36. package/dist/lib/pptx-themes.js +115 -115
  37. package/dist/lib/schema.d.ts.map +1 -1
  38. package/dist/lib/schema.js +34 -0
  39. package/dist/lib/schema.js.map +1 -1
  40. package/dist/lib/sections.d.ts +35 -0
  41. package/dist/lib/sections.d.ts.map +1 -1
  42. package/dist/lib/sections.js +81 -0
  43. package/dist/lib/sections.js.map +1 -1
  44. package/dist/lib/spelling.js +2 -2
  45. package/dist/lib/templates.js +387 -387
  46. package/dist/lib/themes.js +51 -51
  47. package/eslint.config.js +27 -27
  48. package/lib/anchor-match.ts +276 -276
  49. package/lib/annotations.ts +644 -644
  50. package/lib/build.ts +1766 -1694
  51. package/lib/citations.ts +160 -160
  52. package/lib/commands/build.ts +855 -855
  53. package/lib/commands/citations.ts +515 -515
  54. package/lib/commands/comments.ts +1050 -1050
  55. package/lib/commands/context.ts +176 -174
  56. package/lib/commands/core.ts +309 -309
  57. package/lib/commands/doi.ts +435 -435
  58. package/lib/commands/file-ops.ts +372 -372
  59. package/lib/commands/history.ts +320 -320
  60. package/lib/commands/index.ts +87 -87
  61. package/lib/commands/init.ts +259 -259
  62. package/lib/commands/merge-resolve.ts +378 -378
  63. package/lib/commands/preview.ts +178 -178
  64. package/lib/commands/project-info.ts +244 -244
  65. package/lib/commands/quality.ts +517 -517
  66. package/lib/commands/response.ts +454 -454
  67. package/lib/commands/section-boundaries.ts +82 -82
  68. package/lib/commands/sections.ts +451 -451
  69. package/lib/commands/sync.ts +709 -706
  70. package/lib/commands/text-ops.ts +449 -449
  71. package/lib/commands/utilities.ts +448 -448
  72. package/lib/commands/verify-anchors.ts +272 -272
  73. package/lib/commands/word-tools.ts +340 -340
  74. package/lib/comment-realign.ts +517 -517
  75. package/lib/config.ts +84 -84
  76. package/lib/crossref.ts +781 -781
  77. package/lib/csl.ts +191 -191
  78. package/lib/dependencies.ts +98 -98
  79. package/lib/diff-engine.ts +465 -465
  80. package/lib/doi-cache.ts +115 -115
  81. package/lib/doi.ts +897 -897
  82. package/lib/equations.ts +506 -506
  83. package/lib/errors.ts +346 -346
  84. package/lib/format.ts +541 -541
  85. package/lib/git.ts +326 -326
  86. package/lib/grammar.ts +303 -303
  87. package/lib/image-registry.ts +180 -180
  88. package/lib/import.ts +911 -911
  89. package/lib/journals.ts +543 -543
  90. package/lib/macro-filter.lua +201 -0
  91. package/lib/macros.ts +273 -0
  92. package/lib/merge.ts +633 -633
  93. package/lib/orcid.ts +144 -144
  94. package/lib/pdf-comments.ts +263 -263
  95. package/lib/pdf-import.ts +524 -524
  96. package/lib/plugins.ts +362 -362
  97. package/lib/postprocess.ts +188 -188
  98. package/lib/pptx-color-filter.lua +37 -37
  99. package/lib/pptx-template.ts +469 -469
  100. package/lib/pptx-themes.ts +483 -483
  101. package/lib/protect-restore.ts +520 -520
  102. package/lib/rate-limiter.ts +94 -94
  103. package/lib/response.ts +197 -197
  104. package/lib/restore-references.ts +240 -240
  105. package/lib/review.ts +327 -327
  106. package/lib/schema.ts +488 -454
  107. package/lib/scientific-words.ts +73 -73
  108. package/lib/sections.ts +425 -335
  109. package/lib/slides.ts +756 -756
  110. package/lib/spelling.ts +334 -334
  111. package/lib/templates.ts +526 -526
  112. package/lib/themes.ts +742 -742
  113. package/lib/trackchanges.ts +247 -247
  114. package/lib/tui.ts +450 -450
  115. package/lib/types.ts +550 -550
  116. package/lib/undo.ts +250 -250
  117. package/lib/utils.ts +69 -69
  118. package/lib/variables.ts +179 -179
  119. package/lib/word-extraction.ts +806 -806
  120. package/lib/word.ts +643 -643
  121. package/lib/wordcomments.ts +840 -840
  122. package/package.json +137 -137
  123. package/scripts/postbuild.js +47 -28
  124. package/skill/REFERENCE.md +539 -539
  125. package/skill/SKILL.md +295 -295
  126. package/tsconfig.json +26 -26
  127. package/types/index.d.ts +525 -525
  128. package/issues.md +0 -180
  129. package/site/assets/extra.css +0 -208
  130. package/site/commands.html +0 -926
  131. package/site/configuration.html +0 -469
  132. package/site/index.html +0 -288
  133. package/site/troubleshooting.html +0 -461
  134. package/site/workflow.html +0 -518
package/README.md CHANGED
@@ -1,406 +1,431 @@
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
- ```
137
-
138
- PDF annotations work the same way:
139
-
140
- ```bash
141
- rev sync annotated.pdf
142
- rev pdf-comments annotated.pdf --append methods.md
143
- ```
144
-
145
- When several reviewers return separate files, `rev merge` reconciles them:
146
-
147
- ```bash
148
- rev merge reviewer_A.docx reviewer_B.docx
149
- ```
150
-
151
- 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.
152
-
153
- ## Getting Started
154
-
155
- ### Starting a New Document
156
-
157
- Create a new project:
158
-
159
- ```bash
160
- rev new my-report
161
- cd my-report
162
- ```
163
-
164
- You'll be prompted to enter your section names, or press Enter to use the default structure. You can also specify sections directly:
165
-
166
- ```bash
167
- rev new my-report -s intro,methods,results,discussion
168
- ```
169
-
170
- Or set your preferred default sections once:
171
-
172
- ```bash
173
- rev config sections "intro,methods,results,discussion"
174
- ```
175
-
176
- This creates the project folder with your section files — edit them, then build:
177
-
178
- ```bash
179
- rev build docx pdf
180
- ```
181
-
182
- 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).
183
-
184
- ### Starting from an Existing Word Document
185
-
186
- If you have a Word document to convert:
187
-
188
- ```bash
189
- rev import manuscript.docx
190
- ```
191
-
192
- 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.
193
-
194
- ### Configuration
195
-
196
- Layout is controlled in `rev.yaml`:
197
-
198
- ```yaml
199
- title: "My Document"
200
- authors: []
201
- sections:
202
- - intro.md
203
- - methods.md
204
- - results.md
205
- - discussion.md
206
-
207
- # Where built artefacts land (default: output/). Set to null for the
208
- # legacy "outputs alongside paper.md" layout.
209
- outputDir: output
210
-
211
- docx:
212
- reference: template.docx # your Word template
213
-
214
- pdf:
215
- documentclass: article
216
- fontsize: 12pt
217
- engine: pdflatex # or xelatex/lualatex for Latin-Extended
218
- # Fonts apply only under xelatex/lualatex (fontspec):
219
- # mainfont: "TeX Gyre Termes"
220
- # sansfont: "TeX Gyre Heros"
221
- # monofont: "TeX Gyre Cursor"
222
- ```
223
-
224
- 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.
225
-
226
- Configure your name for comment replies:
227
-
228
- ```bash
229
- rev config user "Your Name"
230
- ```
231
-
232
- ### Table Formatting
233
-
234
- For PDF output, configure columns that should not wrap:
235
-
236
- ```yaml
237
- tables:
238
- nowrap:
239
- - Prior # column headers to keep on one line
240
- - "$\\widehat{R}$"
241
- ```
242
-
243
- Distribution notation in nowrap columns is auto-converted to LaTeX math:
244
- `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
245
-
246
- ### Postprocess Scripts
247
-
248
- Run custom scripts after output generation:
249
-
250
- ```yaml
251
- postprocess:
252
- pdf: ./scripts/fix-tables.py # runs after PDF
253
- docx: ./scripts/add-meta.js # runs after DOCX
254
- all: ./scripts/notify.sh # runs after any format
255
- ```
256
-
257
- Scripts receive environment variables: `OUTPUT_FILE`, `OUTPUT_FORMAT`, `PROJECT_DIR`, `CONFIG_PATH`.
258
-
259
- Use `--verbose` to see script output:
260
-
261
- ```bash
262
- rev build pdf --verbose
263
- ```
264
-
265
- ### Journal Profiles
266
-
267
- Journal profiles provide both validation rules and build formatting defaults. Set in `rev.yaml`:
268
-
269
- ```yaml
270
- journal: nature
271
- ```
272
-
273
- Or pass on the command line:
274
-
275
- ```bash
276
- rev build pdf -j nature # applies Nature's CSL style + PDF settings
277
- ```
278
-
279
- 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.
280
-
281
- 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).
282
-
283
- ```bash
284
- rev validate --list # see all profiles ([formatting] tag = build support)
285
- rev profiles --fetch-csl apa # download a CSL style to cache
286
- rev profiles --list-csl # list cached CSL styles
287
- ```
288
-
289
- ## Annotation Syntax
290
-
291
- Track changes from Word appear as [CriticMarkup](http://criticmarkup.com/):
292
-
293
- ```markdown
294
- The sample size was {--100--}{++150++} participants. # deletion + insertion
295
- Data was collected {~~monthly~>weekly~~}. # substitution
296
- {>>Reviewer 2: Please clarify.<<} # comment
297
- ```
298
-
299
- ## Writing Tips
300
-
301
- Track word count changes between versions:
302
-
303
- ```bash
304
- rev diff # compare against last commit
305
- # methods.md +142 words -38 words
306
- # results.md +89 words -12 words
307
- ```
308
-
309
- Add references to `references.bib` (BibTeX format):
310
-
311
- ```bibtex
312
- @article{Smith2020,
313
- author = {Smith, Jane},
314
- title = {Paper Title},
315
- journal = {Nature},
316
- year = {2020},
317
- doi = {10.1038/example}
318
- }
319
- ```
320
-
321
- Cite with `[@Smith2020]` or `[@Smith2020; @Jones2021]` for multiple sources.
322
-
323
- Equations use LaTeX: inline `$E = mc^2$` or display `$$\sum_{i=1}^{n} x_i$$`.
324
-
325
- Cross-references: `@fig:label`, `@tbl:label`, `@eq:label` → "Figure 1", "Table 2", "Equation 3".
326
-
327
- ## Command Reference
328
-
329
- | Task | Command |
330
- |------|---------|
331
- | Create project | `rev new my-project` |
332
- | Create LaTeX project | `rev new my-project --template latex` |
333
- | Import Word document | `rev import manuscript.docx` |
334
- | Extract Word equations | `rev equations from-word doc.docx` |
335
- | Build DOCX | `rev build docx` |
336
- | Build PDF | `rev build pdf` |
337
- | Build clean + annotated | `rev build docx --dual` |
338
- | Build with visible track changes | `rev build docx --show-changes` |
339
- | Sync Word feedback | `rev sync reviewed.docx` |
340
- | Sync PDF comments | `rev sync annotated.pdf` |
341
- | Extract PDF comments | `rev pdf-comments annotated.pdf` |
342
- | Extract with highlighted text | `rev pdf-comments file.pdf --with-text` |
343
- | Project status | `rev status` |
344
- | Next pending comment | `rev next` |
345
- | List pending comments | `rev todo` |
346
- | Filter by author | `rev comments file.md --author "Reviewer 2"` |
347
- | Accept all changes | `rev accept file.md -a` |
348
- | Reject change | `rev reject file.md -n 1` |
349
- | Reply to comment | `rev reply file.md -n 1 -m "response"` |
350
- | Reply to all pending | `rev reply file.md --all -m "Addressed"` |
351
- | Resolve comment | `rev resolve file.md -n 1` |
352
- | Show contributors | `rev contributors` |
353
- | Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
354
- | Merge reviewer feedback | `rev merge reviewer_A.docx reviewer_B.docx` |
355
- | Archive reviewer files | `rev archive` |
356
- | Check DOIs | `rev doi check references.bib` |
357
- | Find missing DOIs | `rev doi lookup references.bib` |
358
- | Add citation from DOI | `rev doi add 10.1038/example` |
359
- | Word count | `rev wc` |
360
- | Pre-submission check | `rev check` |
361
- | Check for updates | `rev upgrade --check` |
362
-
363
- Run `rev help` to see all commands, or `rev help <command>` for details on a specific command.
364
-
365
- Full command reference: [docs/commands.md](docs/commands.md)
366
-
367
- ## Claude Code Skill
368
-
369
- Install the docrev skill for [Claude Code](https://claude.ai/code):
370
-
371
- ```bash
372
- rev install-cli-skill # install to ~/.claude/skills/docrev
373
- rev uninstall-cli-skill # remove
374
- ```
375
-
376
- Once installed, Claude understands docrev commands and can help navigate comments, draft replies, and manage your revision cycle.
377
-
378
- ## Installing Dependencies
379
-
380
- ### Pandoc
381
-
382
- [Pandoc](https://pandoc.org) handles document conversion.
383
-
384
- | Platform | Command |
385
- |----------|---------|
386
- | macOS | `brew install pandoc` |
387
- | Windows | `winget install JohnMacFarlane.Pandoc` |
388
- | Debian/Ubuntu | `sudo apt install pandoc` |
389
- | Fedora | `sudo dnf install pandoc` |
390
-
391
- Other platforms: [pandoc.org/installing](https://pandoc.org/installing.html)
392
-
393
- ### LaTeX (for complex PDF builds)
394
-
395
- | Platform | Command |
396
- |----------|---------|
397
- | macOS | `brew install --cask mactex` |
398
- | Windows | `winget install MiKTeX.MiKTeX` |
399
- | Debian/Ubuntu | `sudo apt install texlive-full` |
400
- | Fedora | `sudo dnf install texlive-scheme-full` |
401
-
402
- Alternatively, [TinyTeX](https://yihui.org/tinytex/) provides a minimal distribution that downloads packages on demand.
403
-
404
- ## License
405
-
406
- 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
+ ```
137
+
138
+ PDF annotations work the same way:
139
+
140
+ ```bash
141
+ rev sync annotated.pdf
142
+ rev pdf-comments annotated.pdf --append methods.md
143
+ ```
144
+
145
+ When several reviewers return separate files, `rev merge` reconciles them:
146
+
147
+ ```bash
148
+ rev merge reviewer_A.docx reviewer_B.docx
149
+ ```
150
+
151
+ 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.
152
+
153
+ ## Getting Started
154
+
155
+ ### Starting a New Document
156
+
157
+ Create a new project:
158
+
159
+ ```bash
160
+ rev new my-report
161
+ cd my-report
162
+ ```
163
+
164
+ You'll be prompted to enter your section names, or press Enter to use the default structure. You can also specify sections directly:
165
+
166
+ ```bash
167
+ rev new my-report -s intro,methods,results,discussion
168
+ ```
169
+
170
+ Or set your preferred default sections once:
171
+
172
+ ```bash
173
+ rev config sections "intro,methods,results,discussion"
174
+ ```
175
+
176
+ This creates the project folder with your section files — edit them, then build:
177
+
178
+ ```bash
179
+ rev build docx pdf
180
+ ```
181
+
182
+ 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).
183
+
184
+ ### Starting from an Existing Word Document
185
+
186
+ If you have a Word document to convert:
187
+
188
+ ```bash
189
+ rev import manuscript.docx
190
+ ```
191
+
192
+ 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.
193
+
194
+ ### Configuration
195
+
196
+ Layout is controlled in `rev.yaml`:
197
+
198
+ ```yaml
199
+ title: "My Document"
200
+ authors: []
201
+ sections:
202
+ - intro.md
203
+ - methods.md
204
+ - results.md
205
+ - discussion.md
206
+
207
+ # Where built artefacts land (default: output/). Set to null for the
208
+ # legacy "outputs alongside paper.md" layout.
209
+ outputDir: output
210
+
211
+ docx:
212
+ reference: template.docx # your Word template
213
+
214
+ pdf:
215
+ documentclass: article
216
+ fontsize: 12pt
217
+ engine: pdflatex # or xelatex/lualatex for Latin-Extended
218
+ # Fonts apply only under xelatex/lualatex (fontspec):
219
+ # mainfont: "TeX Gyre Termes"
220
+ # sansfont: "TeX Gyre Heros"
221
+ # monofont: "TeX Gyre Cursor"
222
+ ```
223
+
224
+ 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.
225
+
226
+ Configure your name for comment replies:
227
+
228
+ ```bash
229
+ rev config user "Your Name"
230
+ ```
231
+
232
+ ### Table Formatting
233
+
234
+ For PDF output, configure columns that should not wrap:
235
+
236
+ ```yaml
237
+ tables:
238
+ nowrap:
239
+ - Prior # column headers to keep on one line
240
+ - "$\\widehat{R}$"
241
+ ```
242
+
243
+ Distribution notation in nowrap columns is auto-converted to LaTeX math:
244
+ `Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
245
+
246
+ ### Placeholder Macros
247
+
248
+ Mark unfinished spots in a draft with `\tofill{X}` and they highlight as bold
249
+ orange `[X]` in every output format:
250
+
251
+ ```markdown
252
+ We collected data from \tofill{N sites} between \tofill{date range}.
253
+ ```
254
+
255
+ The macro works in DOCX, PDF, TeX, Beamer, and HTML without any per-project
256
+ filter setup. Add custom macros (e.g. `\note`, `\citeNeeded`) under `macros:`
257
+ in `rev.yaml`:
258
+
259
+ ```yaml
260
+ macros:
261
+ - name: note
262
+ default:
263
+ color: "1E40AF" # 6-digit hex, no '#'
264
+ bold: true
265
+ prefix: "NOTE: "
266
+ ```
267
+
268
+ See [docs/configuration.md](docs/configuration.md) for the full schema and
269
+ per-format overrides.
270
+
271
+ ### Postprocess Scripts
272
+
273
+ Run custom scripts after output generation:
274
+
275
+ ```yaml
276
+ postprocess:
277
+ pdf: ./scripts/fix-tables.py # runs after PDF
278
+ docx: ./scripts/add-meta.js # runs after DOCX
279
+ all: ./scripts/notify.sh # runs after any format
280
+ ```
281
+
282
+ Scripts receive environment variables: `OUTPUT_FILE`, `OUTPUT_FORMAT`, `PROJECT_DIR`, `CONFIG_PATH`.
283
+
284
+ Use `--verbose` to see script output:
285
+
286
+ ```bash
287
+ rev build pdf --verbose
288
+ ```
289
+
290
+ ### Journal Profiles
291
+
292
+ Journal profiles provide both validation rules and build formatting defaults. Set in `rev.yaml`:
293
+
294
+ ```yaml
295
+ journal: nature
296
+ ```
297
+
298
+ Or pass on the command line:
299
+
300
+ ```bash
301
+ rev build pdf -j nature # applies Nature's CSL style + PDF settings
302
+ ```
303
+
304
+ 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.
305
+
306
+ 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).
307
+
308
+ ```bash
309
+ rev validate --list # see all profiles ([formatting] tag = build support)
310
+ rev profiles --fetch-csl apa # download a CSL style to cache
311
+ rev profiles --list-csl # list cached CSL styles
312
+ ```
313
+
314
+ ## Annotation Syntax
315
+
316
+ Track changes from Word appear as [CriticMarkup](http://criticmarkup.com/):
317
+
318
+ ```markdown
319
+ The sample size was {--100--}{++150++} participants. # deletion + insertion
320
+ Data was collected {~~monthly~>weekly~~}. # substitution
321
+ {>>Reviewer 2: Please clarify.<<} # comment
322
+ ```
323
+
324
+ ## Writing Tips
325
+
326
+ Track word count changes between versions:
327
+
328
+ ```bash
329
+ rev diff # compare against last commit
330
+ # methods.md +142 words -38 words
331
+ # results.md +89 words -12 words
332
+ ```
333
+
334
+ Add references to `references.bib` (BibTeX format):
335
+
336
+ ```bibtex
337
+ @article{Smith2020,
338
+ author = {Smith, Jane},
339
+ title = {Paper Title},
340
+ journal = {Nature},
341
+ year = {2020},
342
+ doi = {10.1038/example}
343
+ }
344
+ ```
345
+
346
+ Cite with `[@Smith2020]` or `[@Smith2020; @Jones2021]` for multiple sources.
347
+
348
+ Equations use LaTeX: inline `$E = mc^2$` or display `$$\sum_{i=1}^{n} x_i$$`.
349
+
350
+ Cross-references: `@fig:label`, `@tbl:label`, `@eq:label` "Figure 1", "Table 2", "Equation 3".
351
+
352
+ ## Command Reference
353
+
354
+ | Task | Command |
355
+ |------|---------|
356
+ | Create project | `rev new my-project` |
357
+ | Create LaTeX project | `rev new my-project --template latex` |
358
+ | Import Word document | `rev import manuscript.docx` |
359
+ | Extract Word equations | `rev equations from-word doc.docx` |
360
+ | Build DOCX | `rev build docx` |
361
+ | Build PDF | `rev build pdf` |
362
+ | Build clean + annotated | `rev build docx --dual` |
363
+ | Build with visible track changes | `rev build docx --show-changes` |
364
+ | Sync Word feedback | `rev sync reviewed.docx` |
365
+ | Sync PDF comments | `rev sync annotated.pdf` |
366
+ | Extract PDF comments | `rev pdf-comments annotated.pdf` |
367
+ | Extract with highlighted text | `rev pdf-comments file.pdf --with-text` |
368
+ | Project status | `rev status` |
369
+ | Next pending comment | `rev next` |
370
+ | List pending comments | `rev todo` |
371
+ | Filter by author | `rev comments file.md --author "Reviewer 2"` |
372
+ | Accept all changes | `rev accept file.md -a` |
373
+ | Reject change | `rev reject file.md -n 1` |
374
+ | Reply to comment | `rev reply file.md -n 1 -m "response"` |
375
+ | Reply to all pending | `rev reply file.md --all -m "Addressed"` |
376
+ | Resolve comment | `rev resolve file.md -n 1` |
377
+ | Show contributors | `rev contributors` |
378
+ | Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
379
+ | Merge reviewer feedback | `rev merge reviewer_A.docx reviewer_B.docx` |
380
+ | Archive reviewer files | `rev archive` |
381
+ | Check DOIs | `rev doi check references.bib` |
382
+ | Find missing DOIs | `rev doi lookup references.bib` |
383
+ | Add citation from DOI | `rev doi add 10.1038/example` |
384
+ | Word count | `rev wc` |
385
+ | Pre-submission check | `rev check` |
386
+ | Check for updates | `rev upgrade --check` |
387
+
388
+ Run `rev help` to see all commands, or `rev help <command>` for details on a specific command.
389
+
390
+ Full command reference: [docs/commands.md](docs/commands.md)
391
+
392
+ ## Claude Code Skill
393
+
394
+ Install the docrev skill for [Claude Code](https://claude.ai/code):
395
+
396
+ ```bash
397
+ rev install-cli-skill # install to ~/.claude/skills/docrev
398
+ rev uninstall-cli-skill # remove
399
+ ```
400
+
401
+ Once installed, Claude understands docrev commands and can help navigate comments, draft replies, and manage your revision cycle.
402
+
403
+ ## Installing Dependencies
404
+
405
+ ### Pandoc
406
+
407
+ [Pandoc](https://pandoc.org) handles document conversion.
408
+
409
+ | Platform | Command |
410
+ |----------|---------|
411
+ | macOS | `brew install pandoc` |
412
+ | Windows | `winget install JohnMacFarlane.Pandoc` |
413
+ | Debian/Ubuntu | `sudo apt install pandoc` |
414
+ | Fedora | `sudo dnf install pandoc` |
415
+
416
+ Other platforms: [pandoc.org/installing](https://pandoc.org/installing.html)
417
+
418
+ ### LaTeX (for complex PDF builds)
419
+
420
+ | Platform | Command |
421
+ |----------|---------|
422
+ | macOS | `brew install --cask mactex` |
423
+ | Windows | `winget install MiKTeX.MiKTeX` |
424
+ | Debian/Ubuntu | `sudo apt install texlive-full` |
425
+ | Fedora | `sudo dnf install texlive-scheme-full` |
426
+
427
+ Alternatively, [TinyTeX](https://yihui.org/tinytex/) provides a minimal distribution that downloads packages on demand.
428
+
429
+ ## License
430
+
431
+ MIT