docrev 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.gitattributes +1 -1
  2. package/CHANGELOG.md +173 -164
  3. package/PLAN-tables-and-postprocess.md +850 -850
  4. package/README.md +431 -431
  5. package/bin/rev.js +11 -11
  6. package/bin/rev.ts +145 -145
  7. package/completions/rev.bash +127 -127
  8. package/completions/rev.ps1 +210 -210
  9. package/completions/rev.zsh +207 -207
  10. package/dist/lib/anchor-match.d.ts +1 -1
  11. package/dist/lib/anchor-match.d.ts.map +1 -1
  12. package/dist/lib/anchor-match.js +17 -47
  13. package/dist/lib/anchor-match.js.map +1 -1
  14. package/dist/lib/build.js +4 -4
  15. package/dist/lib/commands/context.d.ts +1 -1
  16. package/dist/lib/commands/context.d.ts.map +1 -1
  17. package/dist/lib/commands/context.js +1 -1
  18. package/dist/lib/commands/context.js.map +1 -1
  19. package/dist/lib/commands/sections.js +7 -7
  20. package/dist/lib/commands/sections.js.map +1 -1
  21. package/dist/lib/commands/sync.d.ts.map +1 -1
  22. package/dist/lib/commands/sync.js +15 -14
  23. package/dist/lib/commands/sync.js.map +1 -1
  24. package/dist/lib/commands/utilities.js +164 -164
  25. package/dist/lib/commands/verify-anchors.js +6 -6
  26. package/dist/lib/commands/verify-anchors.js.map +1 -1
  27. package/dist/lib/commands/word-tools.js +8 -8
  28. package/dist/lib/grammar.js +3 -3
  29. package/dist/lib/macro-filter.lua +201 -201
  30. package/dist/lib/pdf-comments.js +44 -44
  31. package/dist/lib/plugins.js +57 -57
  32. package/dist/lib/pptx-color-filter.lua +37 -37
  33. package/dist/lib/pptx-themes.js +115 -115
  34. package/dist/lib/sections.d.ts +35 -0
  35. package/dist/lib/sections.d.ts.map +1 -1
  36. package/dist/lib/sections.js +81 -0
  37. package/dist/lib/sections.js.map +1 -1
  38. package/dist/lib/spelling.js +2 -2
  39. package/dist/lib/templates.js +387 -387
  40. package/dist/lib/themes.js +51 -51
  41. package/docs-src/build.py +113 -113
  42. package/docs-src/extra.css +208 -208
  43. package/docs-src/md-to-html.lua +6 -6
  44. package/docs-src/template.html +116 -116
  45. package/eslint.config.js +27 -27
  46. package/lib/anchor-match.ts +276 -308
  47. package/lib/annotations.ts +644 -644
  48. package/lib/build.ts +1766 -1766
  49. package/lib/citations.ts +160 -160
  50. package/lib/commands/build.ts +855 -855
  51. package/lib/commands/citations.ts +515 -515
  52. package/lib/commands/comments.ts +1050 -1050
  53. package/lib/commands/context.ts +176 -174
  54. package/lib/commands/core.ts +309 -309
  55. package/lib/commands/doi.ts +435 -435
  56. package/lib/commands/file-ops.ts +372 -372
  57. package/lib/commands/history.ts +320 -320
  58. package/lib/commands/index.ts +87 -87
  59. package/lib/commands/init.ts +259 -259
  60. package/lib/commands/merge-resolve.ts +378 -378
  61. package/lib/commands/preview.ts +178 -178
  62. package/lib/commands/project-info.ts +244 -244
  63. package/lib/commands/quality.ts +517 -517
  64. package/lib/commands/response.ts +454 -454
  65. package/lib/commands/section-boundaries.ts +82 -82
  66. package/lib/commands/sections.ts +451 -451
  67. package/lib/commands/sync.ts +709 -706
  68. package/lib/commands/text-ops.ts +449 -449
  69. package/lib/commands/utilities.ts +448 -448
  70. package/lib/commands/verify-anchors.ts +272 -272
  71. package/lib/commands/word-tools.ts +340 -340
  72. package/lib/comment-realign.ts +517 -517
  73. package/lib/config.ts +84 -84
  74. package/lib/crossref.ts +781 -781
  75. package/lib/csl.ts +191 -191
  76. package/lib/dependencies.ts +98 -98
  77. package/lib/diff-engine.ts +465 -465
  78. package/lib/doi-cache.ts +115 -115
  79. package/lib/doi.ts +897 -897
  80. package/lib/equations.ts +506 -506
  81. package/lib/errors.ts +346 -346
  82. package/lib/format.ts +541 -541
  83. package/lib/git.ts +326 -326
  84. package/lib/grammar.ts +303 -303
  85. package/lib/image-registry.ts +180 -180
  86. package/lib/import.ts +911 -911
  87. package/lib/journals.ts +543 -543
  88. package/lib/macro-filter.lua +201 -201
  89. package/lib/macros.ts +273 -273
  90. package/lib/merge.ts +633 -633
  91. package/lib/orcid.ts +144 -144
  92. package/lib/pdf-comments.ts +263 -263
  93. package/lib/pdf-import.ts +524 -524
  94. package/lib/plugins.ts +362 -362
  95. package/lib/postprocess.ts +188 -188
  96. package/lib/pptx-color-filter.lua +37 -37
  97. package/lib/pptx-template.ts +469 -469
  98. package/lib/pptx-themes.ts +483 -483
  99. package/lib/protect-restore.ts +520 -520
  100. package/lib/rate-limiter.ts +94 -94
  101. package/lib/response.ts +197 -197
  102. package/lib/restore-references.ts +240 -240
  103. package/lib/review.ts +327 -327
  104. package/lib/schema.ts +488 -488
  105. package/lib/scientific-words.ts +73 -73
  106. package/lib/sections.ts +425 -335
  107. package/lib/slides.ts +756 -756
  108. package/lib/spelling.ts +334 -334
  109. package/lib/templates.ts +526 -526
  110. package/lib/themes.ts +742 -742
  111. package/lib/trackchanges.ts +247 -247
  112. package/lib/tui.ts +450 -450
  113. package/lib/types.ts +550 -550
  114. package/lib/undo.ts +250 -250
  115. package/lib/utils.ts +69 -69
  116. package/lib/variables.ts +179 -179
  117. package/lib/word-extraction.ts +806 -806
  118. package/lib/word.ts +643 -643
  119. package/lib/wordcomments.ts +840 -840
  120. package/mkdocs.yml +64 -64
  121. package/package.json +137 -137
  122. package/scripts/postbuild.js +47 -47
  123. package/skill/REFERENCE.md +539 -539
  124. package/skill/SKILL.md +295 -295
  125. package/tsconfig.json +26 -26
  126. package/types/index.d.ts +525 -525
package/README.md CHANGED
@@ -1,431 +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
- ### 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
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