docrev 0.8.0 → 0.8.5
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.
- package/.claude/settings.local.json +9 -0
- package/PLAN-tables-and-postprocess.md +850 -0
- package/README.md +42 -0
- package/bin/rev.js +12 -131
- package/bin/rev.ts +145 -0
- package/dist/bin/rev.d.ts +9 -0
- package/dist/bin/rev.d.ts.map +1 -0
- package/dist/bin/rev.js +118 -0
- package/dist/bin/rev.js.map +1 -0
- package/dist/lib/annotations.d.ts +91 -0
- package/dist/lib/annotations.d.ts.map +1 -0
- package/dist/lib/annotations.js +554 -0
- package/dist/lib/annotations.js.map +1 -0
- package/dist/lib/build.d.ts +171 -0
- package/dist/lib/build.d.ts.map +1 -0
- package/dist/lib/build.js +755 -0
- package/dist/lib/build.js.map +1 -0
- package/dist/lib/citations.d.ts +34 -0
- package/dist/lib/citations.d.ts.map +1 -0
- package/dist/lib/citations.js +140 -0
- package/dist/lib/citations.js.map +1 -0
- package/dist/lib/commands/build.d.ts +13 -0
- package/dist/lib/commands/build.d.ts.map +1 -0
- package/dist/lib/commands/build.js +678 -0
- package/dist/lib/commands/build.js.map +1 -0
- package/dist/lib/commands/citations.d.ts +11 -0
- package/dist/lib/commands/citations.d.ts.map +1 -0
- package/dist/lib/commands/citations.js +428 -0
- package/dist/lib/commands/citations.js.map +1 -0
- package/dist/lib/commands/comments.d.ts +11 -0
- package/dist/lib/commands/comments.d.ts.map +1 -0
- package/dist/lib/commands/comments.js +883 -0
- package/dist/lib/commands/comments.js.map +1 -0
- package/dist/lib/commands/context.d.ts +35 -0
- package/dist/lib/commands/context.d.ts.map +1 -0
- package/dist/lib/commands/context.js +59 -0
- package/dist/lib/commands/context.js.map +1 -0
- package/dist/lib/commands/core.d.ts +11 -0
- package/dist/lib/commands/core.d.ts.map +1 -0
- package/dist/lib/commands/core.js +246 -0
- package/dist/lib/commands/core.js.map +1 -0
- package/dist/lib/commands/doi.d.ts +11 -0
- package/dist/lib/commands/doi.d.ts.map +1 -0
- package/dist/lib/commands/doi.js +373 -0
- package/dist/lib/commands/doi.js.map +1 -0
- package/dist/lib/commands/history.d.ts +11 -0
- package/dist/lib/commands/history.d.ts.map +1 -0
- package/dist/lib/commands/history.js +245 -0
- package/dist/lib/commands/history.js.map +1 -0
- package/dist/lib/commands/index.d.ts +28 -0
- package/dist/lib/commands/index.d.ts.map +1 -0
- package/dist/lib/commands/index.js +35 -0
- package/dist/lib/commands/index.js.map +1 -0
- package/dist/lib/commands/init.d.ts +11 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +209 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/response.d.ts +11 -0
- package/dist/lib/commands/response.d.ts.map +1 -0
- package/dist/lib/commands/response.js +317 -0
- package/dist/lib/commands/response.js.map +1 -0
- package/dist/lib/commands/sections.d.ts +11 -0
- package/dist/lib/commands/sections.d.ts.map +1 -0
- package/dist/lib/commands/sections.js +1071 -0
- package/dist/lib/commands/sections.js.map +1 -0
- package/dist/lib/commands/utilities.d.ts +19 -0
- package/dist/lib/commands/utilities.d.ts.map +1 -0
- package/dist/lib/commands/utilities.js +2009 -0
- package/dist/lib/commands/utilities.js.map +1 -0
- package/dist/lib/comment-realign.d.ts +50 -0
- package/dist/lib/comment-realign.d.ts.map +1 -0
- package/dist/lib/comment-realign.js +372 -0
- package/dist/lib/comment-realign.js.map +1 -0
- package/dist/lib/config.d.ts +41 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +76 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/crossref.d.ts +108 -0
- package/dist/lib/crossref.d.ts.map +1 -0
- package/dist/lib/crossref.js +597 -0
- package/dist/lib/crossref.js.map +1 -0
- package/dist/lib/dependencies.d.ts +30 -0
- package/dist/lib/dependencies.d.ts.map +1 -0
- package/dist/lib/dependencies.js +95 -0
- package/dist/lib/dependencies.js.map +1 -0
- package/dist/lib/doi-cache.d.ts +29 -0
- package/dist/lib/doi-cache.d.ts.map +1 -0
- package/dist/lib/doi-cache.js +104 -0
- package/dist/lib/doi-cache.js.map +1 -0
- package/dist/lib/doi.d.ts +65 -0
- package/dist/lib/doi.d.ts.map +1 -0
- package/dist/lib/doi.js +710 -0
- package/dist/lib/doi.js.map +1 -0
- package/dist/lib/equations.d.ts +61 -0
- package/dist/lib/equations.d.ts.map +1 -0
- package/dist/lib/equations.js +445 -0
- package/dist/lib/equations.js.map +1 -0
- package/dist/lib/errors.d.ts +60 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +303 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/format.d.ts +104 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +416 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/git.d.ts +88 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +304 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/grammar.d.ts +62 -0
- package/dist/lib/grammar.d.ts.map +1 -0
- package/dist/lib/grammar.js +244 -0
- package/dist/lib/grammar.js.map +1 -0
- package/dist/lib/image-registry.d.ts +68 -0
- package/dist/lib/image-registry.d.ts.map +1 -0
- package/dist/lib/image-registry.js +112 -0
- package/dist/lib/image-registry.js.map +1 -0
- package/dist/lib/import.d.ts +184 -0
- package/dist/lib/import.d.ts.map +1 -0
- package/dist/lib/import.js +1581 -0
- package/dist/lib/import.js.map +1 -0
- package/dist/lib/journals.d.ts +55 -0
- package/dist/lib/journals.d.ts.map +1 -0
- package/dist/lib/journals.js +417 -0
- package/dist/lib/journals.js.map +1 -0
- package/dist/lib/merge.d.ts +138 -0
- package/dist/lib/merge.d.ts.map +1 -0
- package/dist/lib/merge.js +603 -0
- package/dist/lib/merge.js.map +1 -0
- package/dist/lib/orcid.d.ts +36 -0
- package/dist/lib/orcid.d.ts.map +1 -0
- package/dist/lib/orcid.js +117 -0
- package/dist/lib/orcid.js.map +1 -0
- package/dist/lib/pdf-comments.d.ts +95 -0
- package/dist/lib/pdf-comments.d.ts.map +1 -0
- package/dist/lib/pdf-comments.js +192 -0
- package/dist/lib/pdf-comments.js.map +1 -0
- package/dist/lib/pdf-import.d.ts +118 -0
- package/dist/lib/pdf-import.d.ts.map +1 -0
- package/dist/lib/pdf-import.js +397 -0
- package/dist/lib/pdf-import.js.map +1 -0
- package/dist/lib/plugins.d.ts +76 -0
- package/dist/lib/plugins.d.ts.map +1 -0
- package/dist/lib/plugins.js +235 -0
- package/dist/lib/plugins.js.map +1 -0
- package/dist/lib/postprocess.d.ts +42 -0
- package/dist/lib/postprocess.d.ts.map +1 -0
- package/dist/lib/postprocess.js +138 -0
- package/dist/lib/postprocess.js.map +1 -0
- package/dist/lib/pptx-template.d.ts +59 -0
- package/dist/lib/pptx-template.d.ts.map +1 -0
- package/dist/lib/pptx-template.js +613 -0
- package/dist/lib/pptx-template.js.map +1 -0
- package/dist/lib/pptx-themes.d.ts +80 -0
- package/dist/lib/pptx-themes.d.ts.map +1 -0
- package/dist/lib/pptx-themes.js +818 -0
- package/dist/lib/pptx-themes.js.map +1 -0
- package/dist/lib/protect-restore.d.ts +137 -0
- package/dist/lib/protect-restore.d.ts.map +1 -0
- package/dist/lib/protect-restore.js +394 -0
- package/dist/lib/protect-restore.js.map +1 -0
- package/dist/lib/rate-limiter.d.ts +27 -0
- package/dist/lib/rate-limiter.d.ts.map +1 -0
- package/dist/lib/rate-limiter.js +79 -0
- package/dist/lib/rate-limiter.js.map +1 -0
- package/dist/lib/response.d.ts +41 -0
- package/dist/lib/response.d.ts.map +1 -0
- package/dist/lib/response.js +150 -0
- package/dist/lib/response.js.map +1 -0
- package/dist/lib/review.d.ts +35 -0
- package/dist/lib/review.d.ts.map +1 -0
- package/dist/lib/review.js +263 -0
- package/dist/lib/review.js.map +1 -0
- package/dist/lib/schema.d.ts +66 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/schema.js +339 -0
- package/dist/lib/schema.js.map +1 -0
- package/dist/lib/scientific-words.d.ts +6 -0
- package/dist/lib/scientific-words.d.ts.map +1 -0
- package/dist/lib/scientific-words.js +66 -0
- package/dist/lib/scientific-words.js.map +1 -0
- package/dist/lib/sections.d.ts +40 -0
- package/dist/lib/sections.d.ts.map +1 -0
- package/dist/lib/sections.js +288 -0
- package/dist/lib/sections.js.map +1 -0
- package/dist/lib/slides.d.ts +86 -0
- package/dist/lib/slides.d.ts.map +1 -0
- package/dist/lib/slides.js +676 -0
- package/dist/lib/slides.js.map +1 -0
- package/dist/lib/spelling.d.ts +76 -0
- package/dist/lib/spelling.d.ts.map +1 -0
- package/dist/lib/spelling.js +272 -0
- package/dist/lib/spelling.js.map +1 -0
- package/dist/lib/templates.d.ts +30 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +504 -0
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/themes.d.ts +85 -0
- package/dist/lib/themes.d.ts.map +1 -0
- package/dist/lib/themes.js +652 -0
- package/dist/lib/themes.js.map +1 -0
- package/dist/lib/trackchanges.d.ts +51 -0
- package/dist/lib/trackchanges.d.ts.map +1 -0
- package/dist/lib/trackchanges.js +202 -0
- package/dist/lib/trackchanges.js.map +1 -0
- package/dist/lib/tui.d.ts +76 -0
- package/dist/lib/tui.d.ts.map +1 -0
- package/dist/lib/tui.js +377 -0
- package/dist/lib/tui.js.map +1 -0
- package/dist/lib/types.d.ts +447 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +6 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/undo.d.ts +57 -0
- package/dist/lib/undo.d.ts.map +1 -0
- package/dist/lib/undo.js +185 -0
- package/dist/lib/undo.js.map +1 -0
- package/dist/lib/utils.d.ts +16 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +40 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/variables.d.ts +42 -0
- package/dist/lib/variables.d.ts.map +1 -0
- package/dist/lib/variables.js +141 -0
- package/dist/lib/variables.js.map +1 -0
- package/dist/lib/word.d.ts +80 -0
- package/dist/lib/word.d.ts.map +1 -0
- package/dist/lib/word.js +360 -0
- package/dist/lib/word.js.map +1 -0
- package/dist/lib/wordcomments.d.ts +51 -0
- package/dist/lib/wordcomments.d.ts.map +1 -0
- package/dist/lib/wordcomments.js +587 -0
- package/dist/lib/wordcomments.js.map +1 -0
- package/eslint.config.js +27 -0
- package/lib/annotations.ts +622 -0
- package/lib/apply-buildup-colors.py +88 -0
- package/lib/build.ts +1013 -0
- package/lib/{citations.js → citations.ts} +38 -27
- package/lib/commands/{build.js → build.ts} +80 -27
- package/lib/commands/{citations.js → citations.ts} +36 -18
- package/lib/commands/{comments.js → comments.ts} +187 -54
- package/lib/commands/{context.js → context.ts} +18 -8
- package/lib/commands/{core.js → core.ts} +34 -20
- package/lib/commands/{doi.js → doi.ts} +32 -16
- package/lib/commands/{history.js → history.ts} +25 -12
- package/lib/commands/{index.js → index.ts} +9 -5
- package/lib/commands/{init.js → init.ts} +20 -8
- package/lib/commands/{response.js → response.ts} +47 -20
- package/lib/commands/{sections.js → sections.ts} +273 -68
- package/lib/commands/{utilities.js → utilities.ts} +338 -158
- package/lib/{comment-realign.js → comment-realign.ts} +117 -45
- package/lib/config.ts +84 -0
- package/lib/{crossref.js → crossref.ts} +213 -138
- package/lib/dependencies.ts +106 -0
- package/lib/doi-cache.ts +115 -0
- package/lib/{doi.js → doi.ts} +115 -281
- package/lib/{equations.js → equations.ts} +60 -64
- package/lib/{errors.js → errors.ts} +56 -48
- package/lib/{format.js → format.ts} +137 -63
- package/lib/{git.js → git.ts} +66 -63
- package/lib/{grammar.js → grammar.ts} +45 -32
- package/lib/image-registry.ts +180 -0
- package/lib/import.ts +2060 -0
- package/lib/journals.ts +505 -0
- package/lib/{merge.js → merge.ts} +185 -135
- package/lib/{orcid.js → orcid.ts} +17 -22
- package/lib/{pdf-comments.js → pdf-comments.ts} +76 -18
- package/lib/{pdf-import.js → pdf-import.ts} +148 -70
- package/lib/{plugins.js → plugins.ts} +82 -39
- package/lib/postprocess.ts +188 -0
- package/lib/pptx-color-filter.lua +37 -0
- package/lib/pptx-template.ts +625 -0
- package/lib/pptx-themes/academic.pptx +0 -0
- package/lib/pptx-themes/corporate.pptx +0 -0
- package/lib/pptx-themes/dark.pptx +0 -0
- package/lib/pptx-themes/default.pptx +0 -0
- package/lib/pptx-themes/minimal.pptx +0 -0
- package/lib/pptx-themes/plant.pptx +0 -0
- package/lib/pptx-themes.ts +896 -0
- package/lib/protect-restore.ts +516 -0
- package/lib/rate-limiter.ts +94 -0
- package/lib/{response.js → response.ts} +36 -21
- package/lib/{review.js → review.ts} +53 -43
- package/lib/{schema.js → schema.ts} +70 -25
- package/lib/{sections.js → sections.ts} +71 -76
- package/lib/slides.ts +793 -0
- package/lib/{spelling.js → spelling.ts} +43 -59
- package/lib/{templates.js → templates.ts} +20 -17
- package/lib/themes.ts +742 -0
- package/lib/{trackchanges.js → trackchanges.ts} +52 -23
- package/lib/types.ts +509 -0
- package/lib/{undo.js → undo.ts} +75 -52
- package/lib/utils.ts +41 -0
- package/lib/{variables.js → variables.ts} +60 -54
- package/lib/word.ts +428 -0
- package/lib/{wordcomments.js → wordcomments.ts} +94 -40
- package/package.json +15 -5
- package/skill/REFERENCE.md +67 -0
- package/tsconfig.json +26 -0
- package/lib/annotations.js +0 -414
- package/lib/build.js +0 -639
- package/lib/config.js +0 -79
- package/lib/import.js +0 -1145
- package/lib/journals.js +0 -629
- package/lib/word.js +0 -225
- /package/lib/{scientific-words.js → scientific-words.ts} +0 -0
package/README.md
CHANGED
|
@@ -117,6 +117,14 @@ rev sync annotated.pdf # extract PDF comments
|
|
|
117
117
|
rev pdf-comments annotated.pdf --append methods.md
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
Multiple reviewers sending back separate files? Merge them:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
rev merge reviewer_A.docx reviewer_B.docx # three-way merge
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The merge command uses the original document (auto-saved in `.rev/base.docx` on build) to detect what each reviewer changed, identifies conflicts when reviewers edit the same text differently, and lets you resolve them interactively.
|
|
127
|
+
|
|
120
128
|
Your entire revision cycle stays in the terminal. `final_v3_REAL_final.docx` is over.
|
|
121
129
|
|
|
122
130
|
## Getting Started
|
|
@@ -207,6 +215,39 @@ Configure your name for comment replies:
|
|
|
207
215
|
rev config user "Your Name"
|
|
208
216
|
```
|
|
209
217
|
|
|
218
|
+
### Table Formatting
|
|
219
|
+
|
|
220
|
+
For PDF output, configure columns that should not wrap:
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
tables:
|
|
224
|
+
nowrap:
|
|
225
|
+
- Prior # column headers to keep on one line
|
|
226
|
+
- "$\\widehat{R}$"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Distribution notation in nowrap columns is auto-converted to LaTeX math:
|
|
230
|
+
`Normal(0, 0.5)` → `$\mathcal{N}(0, 0.5)$`
|
|
231
|
+
|
|
232
|
+
### Postprocess Scripts
|
|
233
|
+
|
|
234
|
+
Run custom scripts after output generation:
|
|
235
|
+
|
|
236
|
+
```yaml
|
|
237
|
+
postprocess:
|
|
238
|
+
pdf: ./scripts/fix-tables.py # runs after PDF
|
|
239
|
+
docx: ./scripts/add-meta.js # runs after DOCX
|
|
240
|
+
all: ./scripts/notify.sh # runs after any format
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Scripts receive environment variables: `OUTPUT_FILE`, `OUTPUT_FORMAT`, `PROJECT_DIR`, `CONFIG_PATH`.
|
|
244
|
+
|
|
245
|
+
Use `--verbose` to see script output:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
rev build pdf --verbose
|
|
249
|
+
```
|
|
250
|
+
|
|
210
251
|
## Annotation Syntax
|
|
211
252
|
|
|
212
253
|
Track changes from Word appear as [CriticMarkup](http://criticmarkup.com/):
|
|
@@ -271,6 +312,7 @@ Cross-references: `@fig:label`, `@tbl:label`, `@eq:label` → "Figure 1", "Table
|
|
|
271
312
|
| Resolve comment | `rev resolve file.md -n 1` |
|
|
272
313
|
| Show contributors | `rev contributors` |
|
|
273
314
|
| Lookup ORCID | `rev orcid 0000-0002-1825-0097` |
|
|
315
|
+
| Merge reviewer feedback | `rev merge reviewer_A.docx reviewer_B.docx` |
|
|
274
316
|
| Archive reviewer files | `rev archive` |
|
|
275
317
|
| Check DOIs | `rev doi check references.bib` |
|
|
276
318
|
| Find missing DOIs | `rev doi lookup references.bib` |
|
package/bin/rev.js
CHANGED
|
@@ -1,138 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* Handles track changes and comments when collaborating on academic papers.
|
|
7
|
-
* Preserves reviewer feedback through the Markdown editing workflow.
|
|
8
|
-
*/
|
|
3
|
+
// Wrapper to run the TypeScript entry point via tsx
|
|
4
|
+
// This allows `rev` command to work after npm link / npm install
|
|
9
5
|
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
6
|
+
import { spawnSync } from 'child_process';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { dirname, join } from 'path';
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
registerAllCommands,
|
|
17
|
-
setQuietMode,
|
|
18
|
-
setJsonMode,
|
|
19
|
-
} from '../lib/commands/index.js';
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const tsEntry = join(__dirname, 'rev.ts');
|
|
20
12
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Levenshtein distance for command suggestions
|
|
26
|
-
function levenshtein(a, b) {
|
|
27
|
-
const matrix = Array(b.length + 1).fill(null).map(() => Array(a.length + 1).fill(null));
|
|
28
|
-
for (let i = 0; i <= a.length; i++) matrix[0][i] = i;
|
|
29
|
-
for (let j = 0; j <= b.length; j++) matrix[j][0] = j;
|
|
30
|
-
for (let j = 1; j <= b.length; j++) {
|
|
31
|
-
for (let i = 1; i <= a.length; i++) {
|
|
32
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
33
|
-
matrix[j][i] = Math.min(
|
|
34
|
-
matrix[j][i - 1] + 1,
|
|
35
|
-
matrix[j - 1][i] + 1,
|
|
36
|
-
matrix[j - 1][i - 1] + cost
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return matrix[b.length][a.length];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Find similar commands for typo suggestions
|
|
44
|
-
function suggestCommand(input, commands) {
|
|
45
|
-
const suggestions = commands
|
|
46
|
-
.map(cmd => ({ cmd, dist: levenshtein(input.toLowerCase(), cmd.toLowerCase()) }))
|
|
47
|
-
.filter(({ dist }) => dist <= 3)
|
|
48
|
-
.sort((a, b) => a.dist - b.dist)
|
|
49
|
-
.slice(0, 3)
|
|
50
|
-
.map(({ cmd }) => cmd);
|
|
51
|
-
return suggestions;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Read version from package.json
|
|
55
|
-
const pkgPath = new URL('../package.json', import.meta.url);
|
|
56
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
57
|
-
|
|
58
|
-
program
|
|
59
|
-
.name('rev')
|
|
60
|
-
.description('Revision workflow for Word ↔ Markdown round-trips')
|
|
61
|
-
.version(`${pkg.version}\nNode ${process.version} | ${process.platform} ${process.arch}`, '-V, --version', 'Output version information')
|
|
62
|
-
.configureOutput({
|
|
63
|
-
outputError: (str, write) => write(chalk.red(str)),
|
|
64
|
-
})
|
|
65
|
-
.showHelpAfterError(chalk.dim('(use --help for usage information)'))
|
|
66
|
-
.option('--no-color', 'Disable colored output')
|
|
67
|
-
.option('-q, --quiet', 'Suppress non-essential output')
|
|
68
|
-
.option('--json', 'Output in JSON format (for scripting)')
|
|
69
|
-
.hook('preAction', (thisCommand) => {
|
|
70
|
-
const opts = thisCommand.opts();
|
|
71
|
-
if (opts.color === false) {
|
|
72
|
-
chalk.level = 0;
|
|
73
|
-
}
|
|
74
|
-
if (opts.quiet) {
|
|
75
|
-
quietMode = true;
|
|
76
|
-
setQuietMode(true);
|
|
77
|
-
}
|
|
78
|
-
if (opts.json) {
|
|
79
|
-
jsonMode = true;
|
|
80
|
-
setJsonMode(true);
|
|
81
|
-
chalk.level = 0; // Disable colors in JSON mode
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Register all command modules
|
|
86
|
-
// Commands organized by module:
|
|
87
|
-
// core.js: review, strip, status
|
|
88
|
-
// comments.js: comments, resolve, next, prev, first, last, todo, accept, reject, reply
|
|
89
|
-
// init.js: init, new, config
|
|
90
|
-
// sections.js: import, extract, split, sync, merge
|
|
91
|
-
// build.js: refs, migrate, install, doctor, build
|
|
92
|
-
// response.js: response, validate, profiles, anonymize
|
|
93
|
-
// citations.js: citations, figures, equations, pdf-comments
|
|
94
|
-
// doi.js: doi, orcid
|
|
95
|
-
// history.js: diff, history, contributors
|
|
96
|
-
// utilities.js: help, completions, word-count, stats, search, backup, archive,
|
|
97
|
-
// export, preview, watch, lint, grammar, annotate, apply, comment,
|
|
98
|
-
// clean, check, open, spelling, upgrade, batch, install-cli-skill
|
|
99
|
-
registerAllCommands(program, pkg);
|
|
100
|
-
|
|
101
|
-
// Get all command names for typo suggestions
|
|
102
|
-
const allCommands = program.commands.map(cmd => cmd.name());
|
|
103
|
-
const allAliases = program.commands.flatMap(cmd => cmd.aliases());
|
|
104
|
-
const allCommandNames = [...allCommands, ...allAliases];
|
|
105
|
-
|
|
106
|
-
// Handle unknown commands with suggestions
|
|
107
|
-
program.on('command:*', (operands) => {
|
|
108
|
-
const unknown = operands[0];
|
|
109
|
-
console.error(chalk.red(`Unknown command: ${unknown}`));
|
|
110
|
-
|
|
111
|
-
const suggestions = suggestCommand(unknown, allCommandNames);
|
|
112
|
-
if (suggestions.length > 0) {
|
|
113
|
-
console.error();
|
|
114
|
-
console.error(chalk.yellow('Did you mean?'));
|
|
115
|
-
for (const s of suggestions) {
|
|
116
|
-
console.error(chalk.cyan(` rev ${s}`));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
console.error();
|
|
120
|
-
console.error(chalk.dim('Run "rev help" for available commands.'));
|
|
121
|
-
process.exit(1);
|
|
13
|
+
// Run tsx with the TypeScript entry point
|
|
14
|
+
const result = spawnSync('npx', ['tsx', tsEntry, ...process.argv.slice(2)], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: true
|
|
122
17
|
});
|
|
123
18
|
|
|
124
|
-
|
|
125
|
-
const args = process.argv.slice(2);
|
|
126
|
-
const globalOpts = ['--no-color', '-q', '--quiet', '--json', '-V', '--version', '-h', '--help'];
|
|
127
|
-
const hasOnlyGlobalOpts = args.every(arg => globalOpts.includes(arg) || arg.startsWith('--no-') || arg.startsWith('-'));
|
|
128
|
-
const hasCommand = args.some(arg => !arg.startsWith('-') && !globalOpts.includes(arg));
|
|
129
|
-
|
|
130
|
-
if (args.length === 0 || (hasOnlyGlobalOpts && !hasCommand && !args.includes('-h') && !args.includes('--help') && !args.includes('-V') && !args.includes('--version'))) {
|
|
131
|
-
// Insert 'status' after any global options
|
|
132
|
-
const insertPos = process.argv.findIndex((arg, i) => i >= 2 && !arg.startsWith('-'));
|
|
133
|
-
if (insertPos === -1) {
|
|
134
|
-
process.argv.push('status');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
program.parse();
|
|
19
|
+
process.exit(result.status ?? 0);
|
package/bin/rev.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* rev - Revision workflow for Word ↔ Markdown round-trips
|
|
5
|
+
*
|
|
6
|
+
* Handles track changes and comments when collaborating on academic papers.
|
|
7
|
+
* Preserves reviewer feedback through the Markdown editing workflow.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { program, Command } from 'commander';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
|
|
14
|
+
// Import refactored command modules
|
|
15
|
+
import {
|
|
16
|
+
registerAllCommands,
|
|
17
|
+
setQuietMode,
|
|
18
|
+
setJsonMode,
|
|
19
|
+
} from '../lib/commands/index.js';
|
|
20
|
+
|
|
21
|
+
// Global flags
|
|
22
|
+
let quietMode = false;
|
|
23
|
+
let jsonMode = false;
|
|
24
|
+
|
|
25
|
+
// Levenshtein distance for command suggestions
|
|
26
|
+
function levenshtein(a: string, b: string): number {
|
|
27
|
+
const matrix: number[][] = Array(b.length + 1).fill(null).map(() => Array(a.length + 1).fill(0));
|
|
28
|
+
for (let i = 0; i <= a.length; i++) matrix[0]![i] = i;
|
|
29
|
+
for (let j = 0; j <= b.length; j++) matrix[j]![0] = j;
|
|
30
|
+
for (let j = 1; j <= b.length; j++) {
|
|
31
|
+
for (let i = 1; i <= a.length; i++) {
|
|
32
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
33
|
+
matrix[j]![i] = Math.min(
|
|
34
|
+
matrix[j]![i - 1]! + 1,
|
|
35
|
+
matrix[j - 1]![i]! + 1,
|
|
36
|
+
matrix[j - 1]![i - 1]! + cost
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return matrix[b.length]![a.length]!;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Find similar commands for typo suggestions
|
|
44
|
+
function suggestCommand(input: string, commands: string[]): string[] {
|
|
45
|
+
const suggestions = commands
|
|
46
|
+
.map(cmd => ({ cmd, dist: levenshtein(input.toLowerCase(), cmd.toLowerCase()) }))
|
|
47
|
+
.filter(({ dist }) => dist <= 3)
|
|
48
|
+
.sort((a, b) => a.dist - b.dist)
|
|
49
|
+
.slice(0, 3)
|
|
50
|
+
.map(({ cmd }) => cmd);
|
|
51
|
+
return suggestions;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface PackageJson {
|
|
55
|
+
version: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Read version from package.json
|
|
62
|
+
const pkgPath = new URL('../package.json', import.meta.url);
|
|
63
|
+
const pkg: PackageJson = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
64
|
+
|
|
65
|
+
program
|
|
66
|
+
.name('rev')
|
|
67
|
+
.description('Revision workflow for Word ↔ Markdown round-trips')
|
|
68
|
+
.version(`${pkg.version}\nNode ${process.version} | ${process.platform} ${process.arch}`, '-V, --version', 'Output version information')
|
|
69
|
+
.configureOutput({
|
|
70
|
+
outputError: (str: string, write: (str: string) => void) => write(chalk.red(str)),
|
|
71
|
+
})
|
|
72
|
+
.showHelpAfterError(chalk.dim('(use --help for usage information)'))
|
|
73
|
+
.option('--no-color', 'Disable colored output')
|
|
74
|
+
.option('-q, --quiet', 'Suppress non-essential output')
|
|
75
|
+
.option('--json', 'Output in JSON format (for scripting)')
|
|
76
|
+
.hook('preAction', (thisCommand: Command) => {
|
|
77
|
+
const opts = thisCommand.opts<{ color?: boolean; quiet?: boolean; json?: boolean }>();
|
|
78
|
+
if (opts.color === false) {
|
|
79
|
+
chalk.level = 0;
|
|
80
|
+
}
|
|
81
|
+
if (opts.quiet) {
|
|
82
|
+
quietMode = true;
|
|
83
|
+
setQuietMode(true);
|
|
84
|
+
}
|
|
85
|
+
if (opts.json) {
|
|
86
|
+
jsonMode = true;
|
|
87
|
+
setJsonMode(true);
|
|
88
|
+
chalk.level = 0; // Disable colors in JSON mode
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Register all command modules
|
|
93
|
+
// Commands organized by module:
|
|
94
|
+
// core.js: review, strip, status
|
|
95
|
+
// comments.js: comments, resolve, next, prev, first, last, todo, accept, reject, reply
|
|
96
|
+
// init.js: init, new, config
|
|
97
|
+
// sections.js: import, extract, split, sync, merge
|
|
98
|
+
// build.js: refs, migrate, install, doctor, build
|
|
99
|
+
// response.js: response, validate, profiles, anonymize
|
|
100
|
+
// citations.js: citations, figures, equations, pdf-comments
|
|
101
|
+
// doi.js: doi, orcid
|
|
102
|
+
// history.js: diff, history, contributors
|
|
103
|
+
// utilities.js: help, completions, word-count, stats, search, backup, archive,
|
|
104
|
+
// export, preview, watch, lint, grammar, annotate, apply, comment,
|
|
105
|
+
// clean, check, open, spelling, upgrade, batch, install-cli-skill
|
|
106
|
+
registerAllCommands(program, pkg);
|
|
107
|
+
|
|
108
|
+
// Get all command names for typo suggestions
|
|
109
|
+
const allCommands = program.commands.map(cmd => cmd.name());
|
|
110
|
+
const allAliases = program.commands.flatMap(cmd => cmd.aliases());
|
|
111
|
+
const allCommandNames = [...allCommands, ...allAliases];
|
|
112
|
+
|
|
113
|
+
// Handle unknown commands with suggestions
|
|
114
|
+
program.on('command:*', (operands: string[]) => {
|
|
115
|
+
const unknown = operands[0];
|
|
116
|
+
console.error(chalk.red(`Unknown command: ${unknown}`));
|
|
117
|
+
|
|
118
|
+
const suggestions = suggestCommand(unknown!, allCommandNames);
|
|
119
|
+
if (suggestions.length > 0) {
|
|
120
|
+
console.error();
|
|
121
|
+
console.error(chalk.yellow('Did you mean?'));
|
|
122
|
+
for (const s of suggestions) {
|
|
123
|
+
console.error(chalk.cyan(` rev ${s}`));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
console.error();
|
|
127
|
+
console.error(chalk.dim('Run "rev help" for available commands.'));
|
|
128
|
+
process.exit(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Default to status when no command given
|
|
132
|
+
const args = process.argv.slice(2);
|
|
133
|
+
const globalOpts = ['--no-color', '-q', '--quiet', '--json', '-V', '--version', '-h', '--help'];
|
|
134
|
+
const hasOnlyGlobalOpts = args.every(arg => globalOpts.includes(arg) || arg.startsWith('--no-') || arg.startsWith('-'));
|
|
135
|
+
const hasCommand = args.some(arg => !arg.startsWith('-') && !globalOpts.includes(arg));
|
|
136
|
+
|
|
137
|
+
if (args.length === 0 || (hasOnlyGlobalOpts && !hasCommand && !args.includes('-h') && !args.includes('--help') && !args.includes('-V') && !args.includes('--version'))) {
|
|
138
|
+
// Insert 'status' after any global options
|
|
139
|
+
const insertPos = process.argv.findIndex((arg, i) => i >= 2 && !arg.startsWith('-'));
|
|
140
|
+
if (insertPos === -1) {
|
|
141
|
+
process.argv.push('status');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
program.parse();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* rev - Revision workflow for Word ↔ Markdown round-trips
|
|
4
|
+
*
|
|
5
|
+
* Handles track changes and comments when collaborating on academic papers.
|
|
6
|
+
* Preserves reviewer feedback through the Markdown editing workflow.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=rev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rev.d.ts","sourceRoot":"","sources":["../../bin/rev.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|
package/dist/bin/rev.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* rev - Revision workflow for Word ↔ Markdown round-trips
|
|
4
|
+
*
|
|
5
|
+
* Handles track changes and comments when collaborating on academic papers.
|
|
6
|
+
* Preserves reviewer feedback through the Markdown editing workflow.
|
|
7
|
+
*/
|
|
8
|
+
import { program } from 'commander';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
// Import refactored command modules
|
|
12
|
+
import { registerAllCommands, setQuietMode, setJsonMode, } from '../lib/commands/index.js';
|
|
13
|
+
// Global flags
|
|
14
|
+
let quietMode = false;
|
|
15
|
+
let jsonMode = false;
|
|
16
|
+
// Levenshtein distance for command suggestions
|
|
17
|
+
function levenshtein(a, b) {
|
|
18
|
+
const matrix = Array(b.length + 1).fill(null).map(() => Array(a.length + 1).fill(0));
|
|
19
|
+
for (let i = 0; i <= a.length; i++)
|
|
20
|
+
matrix[0][i] = i;
|
|
21
|
+
for (let j = 0; j <= b.length; j++)
|
|
22
|
+
matrix[j][0] = j;
|
|
23
|
+
for (let j = 1; j <= b.length; j++) {
|
|
24
|
+
for (let i = 1; i <= a.length; i++) {
|
|
25
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
26
|
+
matrix[j][i] = Math.min(matrix[j][i - 1] + 1, matrix[j - 1][i] + 1, matrix[j - 1][i - 1] + cost);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return matrix[b.length][a.length];
|
|
30
|
+
}
|
|
31
|
+
// Find similar commands for typo suggestions
|
|
32
|
+
function suggestCommand(input, commands) {
|
|
33
|
+
const suggestions = commands
|
|
34
|
+
.map(cmd => ({ cmd, dist: levenshtein(input.toLowerCase(), cmd.toLowerCase()) }))
|
|
35
|
+
.filter(({ dist }) => dist <= 3)
|
|
36
|
+
.sort((a, b) => a.dist - b.dist)
|
|
37
|
+
.slice(0, 3)
|
|
38
|
+
.map(({ cmd }) => cmd);
|
|
39
|
+
return suggestions;
|
|
40
|
+
}
|
|
41
|
+
// Read version from package.json
|
|
42
|
+
const pkgPath = new URL('../package.json', import.meta.url);
|
|
43
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
44
|
+
program
|
|
45
|
+
.name('rev')
|
|
46
|
+
.description('Revision workflow for Word ↔ Markdown round-trips')
|
|
47
|
+
.version(`${pkg.version}\nNode ${process.version} | ${process.platform} ${process.arch}`, '-V, --version', 'Output version information')
|
|
48
|
+
.configureOutput({
|
|
49
|
+
outputError: (str, write) => write(chalk.red(str)),
|
|
50
|
+
})
|
|
51
|
+
.showHelpAfterError(chalk.dim('(use --help for usage information)'))
|
|
52
|
+
.option('--no-color', 'Disable colored output')
|
|
53
|
+
.option('-q, --quiet', 'Suppress non-essential output')
|
|
54
|
+
.option('--json', 'Output in JSON format (for scripting)')
|
|
55
|
+
.hook('preAction', (thisCommand) => {
|
|
56
|
+
const opts = thisCommand.opts();
|
|
57
|
+
if (opts.color === false) {
|
|
58
|
+
chalk.level = 0;
|
|
59
|
+
}
|
|
60
|
+
if (opts.quiet) {
|
|
61
|
+
quietMode = true;
|
|
62
|
+
setQuietMode(true);
|
|
63
|
+
}
|
|
64
|
+
if (opts.json) {
|
|
65
|
+
jsonMode = true;
|
|
66
|
+
setJsonMode(true);
|
|
67
|
+
chalk.level = 0; // Disable colors in JSON mode
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
// Register all command modules
|
|
71
|
+
// Commands organized by module:
|
|
72
|
+
// core.js: review, strip, status
|
|
73
|
+
// comments.js: comments, resolve, next, prev, first, last, todo, accept, reject, reply
|
|
74
|
+
// init.js: init, new, config
|
|
75
|
+
// sections.js: import, extract, split, sync, merge
|
|
76
|
+
// build.js: refs, migrate, install, doctor, build
|
|
77
|
+
// response.js: response, validate, profiles, anonymize
|
|
78
|
+
// citations.js: citations, figures, equations, pdf-comments
|
|
79
|
+
// doi.js: doi, orcid
|
|
80
|
+
// history.js: diff, history, contributors
|
|
81
|
+
// utilities.js: help, completions, word-count, stats, search, backup, archive,
|
|
82
|
+
// export, preview, watch, lint, grammar, annotate, apply, comment,
|
|
83
|
+
// clean, check, open, spelling, upgrade, batch, install-cli-skill
|
|
84
|
+
registerAllCommands(program, pkg);
|
|
85
|
+
// Get all command names for typo suggestions
|
|
86
|
+
const allCommands = program.commands.map(cmd => cmd.name());
|
|
87
|
+
const allAliases = program.commands.flatMap(cmd => cmd.aliases());
|
|
88
|
+
const allCommandNames = [...allCommands, ...allAliases];
|
|
89
|
+
// Handle unknown commands with suggestions
|
|
90
|
+
program.on('command:*', (operands) => {
|
|
91
|
+
const unknown = operands[0];
|
|
92
|
+
console.error(chalk.red(`Unknown command: ${unknown}`));
|
|
93
|
+
const suggestions = suggestCommand(unknown, allCommandNames);
|
|
94
|
+
if (suggestions.length > 0) {
|
|
95
|
+
console.error();
|
|
96
|
+
console.error(chalk.yellow('Did you mean?'));
|
|
97
|
+
for (const s of suggestions) {
|
|
98
|
+
console.error(chalk.cyan(` rev ${s}`));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
console.error();
|
|
102
|
+
console.error(chalk.dim('Run "rev help" for available commands.'));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
// Default to status when no command given
|
|
106
|
+
const args = process.argv.slice(2);
|
|
107
|
+
const globalOpts = ['--no-color', '-q', '--quiet', '--json', '-V', '--version', '-h', '--help'];
|
|
108
|
+
const hasOnlyGlobalOpts = args.every(arg => globalOpts.includes(arg) || arg.startsWith('--no-') || arg.startsWith('-'));
|
|
109
|
+
const hasCommand = args.some(arg => !arg.startsWith('-') && !globalOpts.includes(arg));
|
|
110
|
+
if (args.length === 0 || (hasOnlyGlobalOpts && !hasCommand && !args.includes('-h') && !args.includes('--help') && !args.includes('-V') && !args.includes('--version'))) {
|
|
111
|
+
// Insert 'status' after any global options
|
|
112
|
+
const insertPos = process.argv.findIndex((arg, i) => i >= 2 && !arg.startsWith('-'));
|
|
113
|
+
if (insertPos === -1) {
|
|
114
|
+
process.argv.push('status');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
program.parse();
|
|
118
|
+
//# sourceMappingURL=rev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rev.js","sourceRoot":"","sources":["../../bin/rev.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK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AI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CriticMarkup annotation parsing and manipulation
|
|
3
|
+
*
|
|
4
|
+
* Syntax:
|
|
5
|
+
* {++inserted text++} - Insertions
|
|
6
|
+
* {--deleted text--} - Deletions
|
|
7
|
+
* {~~old~>new~~} - Substitutions
|
|
8
|
+
* {>>Author: comment<<} - Comments
|
|
9
|
+
* {==text==} - Highlights
|
|
10
|
+
*/
|
|
11
|
+
import type { Annotation, AnnotationCounts, StripOptions, CommentFilterOptions } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Parse all annotations from text
|
|
14
|
+
* @param text - Markdown text containing CriticMarkup annotations
|
|
15
|
+
* @returns Array of parsed annotations sorted by position
|
|
16
|
+
* @throws TypeError If text is not a string
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseAnnotations(text: string): Annotation[];
|
|
19
|
+
/**
|
|
20
|
+
* Strip annotations from text, applying changes
|
|
21
|
+
* Handles nested annotations by iterating until stable
|
|
22
|
+
* @param text - Markdown text with CriticMarkup annotations
|
|
23
|
+
* @param options - Strip options
|
|
24
|
+
* @returns Clean text with annotations applied/removed
|
|
25
|
+
* @throws TypeError If text is not a string
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripAnnotations(text: string, options?: StripOptions): string;
|
|
28
|
+
/**
|
|
29
|
+
* Collapse multiple spaces to single space, preserving table formatting
|
|
30
|
+
* Useful for cleaning up messy Word imports
|
|
31
|
+
* @param text - Text to normalize
|
|
32
|
+
* @returns Text with multiple spaces collapsed to single spaces
|
|
33
|
+
* @throws TypeError If text is not a string
|
|
34
|
+
*/
|
|
35
|
+
export declare function stripToSingleSpace(text: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if text contains any CriticMarkup annotations
|
|
38
|
+
* @param text - Text to check
|
|
39
|
+
* @returns True if text contains any annotations
|
|
40
|
+
* @throws TypeError If text is not a string
|
|
41
|
+
*/
|
|
42
|
+
export declare function hasAnnotations(text: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Apply a decision to a single annotation (accept or reject)
|
|
45
|
+
* @param text - Document text containing the annotation
|
|
46
|
+
* @param annotation - Annotation object from parseAnnotations()
|
|
47
|
+
* @param accept - True to accept the change, false to reject
|
|
48
|
+
* @returns Updated text with the decision applied
|
|
49
|
+
* @throws TypeError If text is not a string or annotation is invalid
|
|
50
|
+
*/
|
|
51
|
+
export declare function applyDecision(text: string, annotation: Annotation, accept: boolean): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get track changes only (no comments)
|
|
54
|
+
* @param text - Markdown text with CriticMarkup annotations
|
|
55
|
+
* @returns Array of insert/delete/substitute annotations
|
|
56
|
+
* @throws TypeError If text is not a string
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTrackChanges(text: string): Annotation[];
|
|
59
|
+
/**
|
|
60
|
+
* Get comments only
|
|
61
|
+
* @param text - Markdown text with CriticMarkup annotations
|
|
62
|
+
* @param options - Filter options
|
|
63
|
+
* @returns Array of comment annotations
|
|
64
|
+
* @throws TypeError If text is not a string
|
|
65
|
+
*/
|
|
66
|
+
export declare function getComments(text: string, options?: CommentFilterOptions): Annotation[];
|
|
67
|
+
/**
|
|
68
|
+
* Mark a comment as resolved or pending
|
|
69
|
+
* @param text - Document text containing the comment
|
|
70
|
+
* @param comment - Comment annotation object from getComments()
|
|
71
|
+
* @param resolved - True to mark resolved, false to mark pending
|
|
72
|
+
* @returns Updated text with status marker applied
|
|
73
|
+
* @throws TypeError If text is not a string or comment is invalid
|
|
74
|
+
*/
|
|
75
|
+
export declare function setCommentStatus(text: string, comment: Annotation, resolved: boolean): string;
|
|
76
|
+
/**
|
|
77
|
+
* Count annotations by type
|
|
78
|
+
* @param text - Markdown text with CriticMarkup annotations
|
|
79
|
+
* @returns Counts by annotation type
|
|
80
|
+
* @throws TypeError If text is not a string
|
|
81
|
+
*/
|
|
82
|
+
export declare function countAnnotations(text: string): AnnotationCounts;
|
|
83
|
+
/**
|
|
84
|
+
* Clean up orphaned/malformed CriticMarkup markers
|
|
85
|
+
* This can happen when track changes span across comment boundaries
|
|
86
|
+
* @param text - Document text with potentially malformed markers
|
|
87
|
+
* @returns Cleaned text with orphaned markers removed
|
|
88
|
+
* @throws TypeError If text is not a string
|
|
89
|
+
*/
|
|
90
|
+
export declare function cleanupOrphanedMarkers(text: string): string;
|
|
91
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../lib/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAmHnG;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CA6G3D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAuEjF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqDvD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUpD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAiD3F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAy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