docrev 0.10.2 → 0.11.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.
- package/CHANGELOG.md +13 -0
- package/README.md +2 -0
- package/dist/lib/anchor-match.d.ts +3 -1
- package/dist/lib/anchor-match.d.ts.map +1 -1
- package/dist/lib/anchor-match.js +5 -7
- package/dist/lib/anchor-match.js.map +1 -1
- package/dist/lib/annotations.d.ts +0 -6
- package/dist/lib/annotations.d.ts.map +1 -1
- package/dist/lib/annotations.js +26 -8
- package/dist/lib/annotations.js.map +1 -1
- package/dist/lib/build.d.ts +52 -0
- package/dist/lib/build.d.ts.map +1 -1
- package/dist/lib/build.js +135 -6
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/commands/build.d.ts.map +1 -1
- package/dist/lib/commands/build.js +39 -12
- package/dist/lib/commands/build.js.map +1 -1
- package/dist/lib/commands/doi.d.ts.map +1 -1
- package/dist/lib/commands/doi.js +14 -2
- package/dist/lib/commands/doi.js.map +1 -1
- package/dist/lib/commands/sync.d.ts.map +1 -1
- package/dist/lib/commands/sync.js +24 -11
- package/dist/lib/commands/sync.js.map +1 -1
- package/dist/lib/comment-realign.d.ts +12 -21
- package/dist/lib/comment-realign.d.ts.map +1 -1
- package/dist/lib/comment-realign.js +40 -348
- package/dist/lib/comment-realign.js.map +1 -1
- package/dist/lib/dependencies.d.ts +10 -0
- package/dist/lib/dependencies.d.ts.map +1 -1
- package/dist/lib/dependencies.js +41 -9
- package/dist/lib/dependencies.js.map +1 -1
- package/dist/lib/doi.d.ts.map +1 -1
- package/dist/lib/doi.js +68 -80
- package/dist/lib/doi.js.map +1 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +3 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/import.d.ts +7 -4
- package/dist/lib/import.d.ts.map +1 -1
- package/dist/lib/import.js +58 -62
- package/dist/lib/import.js.map +1 -1
- package/dist/lib/ooxml.d.ts +207 -0
- package/dist/lib/ooxml.d.ts.map +1 -0
- package/dist/lib/ooxml.js +634 -0
- package/dist/lib/ooxml.js.map +1 -0
- package/dist/lib/rate-limiter.d.ts +8 -0
- package/dist/lib/rate-limiter.d.ts.map +1 -1
- package/dist/lib/rate-limiter.js +41 -4
- package/dist/lib/rate-limiter.js.map +1 -1
- package/dist/lib/trackchanges.d.ts +41 -25
- package/dist/lib/trackchanges.d.ts.map +1 -1
- package/dist/lib/trackchanges.js +90 -151
- package/dist/lib/trackchanges.js.map +1 -1
- package/dist/lib/types.d.ts +9 -8
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/word-extraction.d.ts.map +1 -1
- package/dist/lib/word-extraction.js +48 -307
- package/dist/lib/word-extraction.js.map +1 -1
- package/dist/lib/word.d.ts.map +1 -1
- package/dist/lib/word.js +80 -175
- package/dist/lib/word.js.map +1 -1
- package/dist/lib/wordcomments.d.ts.map +1 -1
- package/dist/lib/wordcomments.js +53 -92
- package/dist/lib/wordcomments.js.map +1 -1
- package/lib/anchor-match.ts +6 -7
- package/lib/annotations.ts +28 -8
- package/lib/build.ts +196 -6
- package/lib/commands/build.ts +42 -12
- package/lib/commands/doi.ts +17 -1
- package/lib/commands/sync.ts +26 -13
- package/lib/comment-realign.ts +46 -464
- package/lib/dependencies.ts +43 -9
- package/lib/doi.ts +76 -94
- package/lib/errors.ts +5 -1
- package/lib/import.ts +65 -70
- package/lib/ooxml.ts +768 -0
- package/lib/rate-limiter.ts +37 -4
- package/lib/trackchanges.ts +102 -183
- package/lib/types.ts +9 -13
- package/lib/word-extraction.ts +49 -330
- package/lib/word.ts +86 -203
- package/lib/wordcomments.ts +53 -104
- package/package.json +137 -137
- package/skill/REFERENCE.md +14 -3
- package/skill/SKILL.md +12 -5
- package/types/index.d.ts +16 -10
|
@@ -6,12 +6,20 @@ export interface RateLimiterOptions {
|
|
|
6
6
|
maxDelay?: number;
|
|
7
7
|
maxRetries?: number;
|
|
8
8
|
backoffFactor?: number;
|
|
9
|
+
/** Per-request timeout in ms; a stalled connection aborts instead of hanging. */
|
|
10
|
+
requestTimeout?: number;
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Parse an HTTP `Retry-After` header, which may be a delay in seconds or an
|
|
14
|
+
* HTTP-date. Returns the delay in milliseconds, or null when unparseable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseRetryAfter(value: string | null, now?: number): number | null;
|
|
10
17
|
export declare class RateLimiter {
|
|
11
18
|
private minDelay;
|
|
12
19
|
private maxDelay;
|
|
13
20
|
private maxRetries;
|
|
14
21
|
private backoffFactor;
|
|
22
|
+
private requestTimeout;
|
|
15
23
|
private lastRequestTime;
|
|
16
24
|
private currentDelay;
|
|
17
25
|
private consecutiveErrors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../../lib/rate-limiter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../../lib/rate-limiter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,GAAG,IAAI,CAO7F;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,OAAO,GAAE,kBAAuB;IAWtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,SAAS,IAAI,IAAI;IAMjB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAS9B,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAkDhF;AAGD,eAAO,MAAM,eAAe,aAAsD,CAAC;AACnF,eAAO,MAAM,eAAe,aAAsD,CAAC;AACnF,eAAO,MAAM,aAAa,aAAsD,CAAC"}
|
package/dist/lib/rate-limiter.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rate Limiter - Prevents API abuse with exponential backoff
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse an HTTP `Retry-After` header, which may be a delay in seconds or an
|
|
6
|
+
* HTTP-date. Returns the delay in milliseconds, or null when unparseable.
|
|
7
|
+
*/
|
|
8
|
+
export function parseRetryAfter(value, now = Date.now()) {
|
|
9
|
+
if (!value)
|
|
10
|
+
return null;
|
|
11
|
+
const seconds = Number(value);
|
|
12
|
+
if (Number.isFinite(seconds))
|
|
13
|
+
return Math.max(0, seconds * 1000);
|
|
14
|
+
const date = Date.parse(value);
|
|
15
|
+
if (!Number.isNaN(date))
|
|
16
|
+
return Math.max(0, date - now);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
4
19
|
export class RateLimiter {
|
|
5
20
|
minDelay;
|
|
6
21
|
maxDelay;
|
|
7
22
|
maxRetries;
|
|
8
23
|
backoffFactor;
|
|
24
|
+
requestTimeout;
|
|
9
25
|
lastRequestTime;
|
|
10
26
|
currentDelay;
|
|
11
27
|
consecutiveErrors;
|
|
@@ -14,6 +30,7 @@ export class RateLimiter {
|
|
|
14
30
|
this.maxDelay = options.maxDelay || 30000; // Max delay after backoff (ms)
|
|
15
31
|
this.maxRetries = options.maxRetries || 3; // Max retry attempts
|
|
16
32
|
this.backoffFactor = options.backoffFactor || 2;
|
|
33
|
+
this.requestTimeout = options.requestTimeout || 15000; // Abort a stalled request
|
|
17
34
|
this.lastRequestTime = 0;
|
|
18
35
|
this.currentDelay = this.minDelay;
|
|
19
36
|
this.consecutiveErrors = 0;
|
|
@@ -41,14 +58,25 @@ export class RateLimiter {
|
|
|
41
58
|
}
|
|
42
59
|
async fetchWithRetry(url, options = {}) {
|
|
43
60
|
let lastError;
|
|
61
|
+
const callerSignal = options.signal ?? undefined;
|
|
44
62
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
45
63
|
await this.wait();
|
|
64
|
+
// Bound each attempt so a half-open connection cannot hang the run
|
|
65
|
+
// forever; merge the caller's signal so an external cancel still works.
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timer = setTimeout(() => controller.abort(new Error('Request timed out')), this.requestTimeout);
|
|
68
|
+
const onCallerAbort = () => controller.abort(callerSignal.reason);
|
|
69
|
+
if (callerSignal) {
|
|
70
|
+
if (callerSignal.aborted)
|
|
71
|
+
controller.abort(callerSignal.reason);
|
|
72
|
+
else
|
|
73
|
+
callerSignal.addEventListener('abort', onCallerAbort, { once: true });
|
|
74
|
+
}
|
|
46
75
|
try {
|
|
47
|
-
const response = await fetch(url, options);
|
|
76
|
+
const response = await fetch(url, { ...options, signal: controller.signal });
|
|
48
77
|
if (response.status === 429) {
|
|
49
|
-
// Rate limited - back off
|
|
50
|
-
const
|
|
51
|
-
const delay = retryAfter ? parseInt(retryAfter, 10) * 1000 : this.currentDelay * 2;
|
|
78
|
+
// Rate limited - back off. Retry-After may be seconds or an HTTP-date.
|
|
79
|
+
const delay = parseRetryAfter(response.headers.get('Retry-After')) ?? this.currentDelay * 2;
|
|
52
80
|
this.currentDelay = Math.min(this.maxDelay, delay);
|
|
53
81
|
if (!this.onError(429))
|
|
54
82
|
break;
|
|
@@ -64,10 +92,19 @@ export class RateLimiter {
|
|
|
64
92
|
return response;
|
|
65
93
|
}
|
|
66
94
|
catch (err) {
|
|
95
|
+
// A caller-initiated abort is intentional cancellation, not a failure
|
|
96
|
+
// to retry around.
|
|
97
|
+
if (callerSignal?.aborted)
|
|
98
|
+
throw err;
|
|
67
99
|
lastError = err;
|
|
68
100
|
if (!this.onError(0))
|
|
69
101
|
break;
|
|
70
102
|
}
|
|
103
|
+
finally {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
if (callerSignal)
|
|
106
|
+
callerSignal.removeEventListener('abort', onCallerAbort);
|
|
107
|
+
}
|
|
71
108
|
}
|
|
72
109
|
throw lastError || new Error('Max retries exceeded');
|
|
73
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../lib/rate-limiter.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../lib/rate-limiter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAoB,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IAC5E,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK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,MAAM,GAAG,CAAC;gBACrC,SAAS,GAAG,GAAY,CAAC;gBACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;oBAAE,MAAM;YAC9B,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,IAAI,YAAY;oBAAE,YAAY,CAAC,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACvD,CAAC;CACF;AAED,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACnF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -1,51 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Track changes module - Apply markdown annotations as Word track changes
|
|
3
3
|
*
|
|
4
|
-
* Converts CriticMarkup
|
|
4
|
+
* Converts CriticMarkup insertions/deletions/substitutions to pandoc-native
|
|
5
|
+
* track-change spans (`[text]{.insertion}` / `[text]{.deletion}`). Pandoc's
|
|
6
|
+
* docx writer emits well-formed `w:ins`/`w:del` run-level revisions from these
|
|
7
|
+
* spans in a single pass, so the output is valid OOXML that Word accepts and
|
|
8
|
+
* that composes with comment injection (see lib/wordcomments.ts).
|
|
5
9
|
*/
|
|
6
|
-
|
|
7
|
-
interface PrepareOptions {
|
|
10
|
+
interface NativeTrackChangeOptions {
|
|
8
11
|
author?: string;
|
|
12
|
+
/** ISO-8601 timestamp for the revisions. Defaults to now (no milliseconds). */
|
|
13
|
+
date?: string;
|
|
9
14
|
}
|
|
10
|
-
interface
|
|
15
|
+
export interface NativeTrackChangeStats {
|
|
16
|
+
insertions: number;
|
|
17
|
+
deletions: number;
|
|
18
|
+
substitutions: number;
|
|
19
|
+
}
|
|
20
|
+
interface ConvertResult {
|
|
11
21
|
text: string;
|
|
12
|
-
|
|
22
|
+
stats: NativeTrackChangeStats;
|
|
13
23
|
}
|
|
14
24
|
interface ApplyResult {
|
|
15
25
|
success: boolean;
|
|
16
26
|
message: string;
|
|
17
|
-
stats?:
|
|
18
|
-
insertions: number;
|
|
19
|
-
deletions: number;
|
|
20
|
-
substitutions: number;
|
|
21
|
-
};
|
|
27
|
+
stats?: NativeTrackChangeStats;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
30
|
+
* Convert CriticMarkup insertions/deletions/substitutions to pandoc-native
|
|
31
|
+
* track-change spans. Comments (`{>>...<<}`) and highlights (`{==...==}`) are
|
|
32
|
+
* left untouched — the caller decides how to handle those (strip, or thread
|
|
33
|
+
* them via wordcomments.ts).
|
|
34
|
+
*
|
|
35
|
+
* A single pandoc pass over the result emits valid `w:ins`/`w:del` revisions,
|
|
36
|
+
* so this composes with the full rev filter chain (crossref, citeproc,
|
|
37
|
+
* reference-doc, macros) instead of post-processing document.xml by hand.
|
|
26
38
|
*
|
|
27
|
-
* @param text -
|
|
28
|
-
* @param options -
|
|
29
|
-
* @returns
|
|
39
|
+
* @param text - Markdown with CriticMarkup annotations
|
|
40
|
+
* @param options - Author/date for the revisions
|
|
41
|
+
* @returns Converted markdown plus per-type counts
|
|
30
42
|
*/
|
|
31
|
-
export declare function
|
|
43
|
+
export declare function criticToNativeTrackChanges(text: string, options?: NativeTrackChangeOptions): ConvertResult;
|
|
32
44
|
/**
|
|
33
|
-
*
|
|
45
|
+
* Enable tracked-revision display in a docx's settings.xml (in place).
|
|
34
46
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @returns Result with success status and message
|
|
47
|
+
* The `w:ins`/`w:del` elements already render as tracked changes without this,
|
|
48
|
+
* but `w:trackRevisions` tells Word to keep tracking the author's further
|
|
49
|
+
* edits — the expected state for a "return to author" review document.
|
|
39
50
|
*/
|
|
40
|
-
export declare function
|
|
51
|
+
export declare function enableTrackRevisions(docxPath: string): void;
|
|
41
52
|
/**
|
|
42
|
-
* Build a Word document with track changes from annotated markdown
|
|
53
|
+
* Build a standalone Word document with track changes from annotated markdown.
|
|
54
|
+
*
|
|
55
|
+
* Used by `rev apply <md> <docx>` for a single markdown file outside a rev
|
|
56
|
+
* project (no crossref/citeproc/reference-doc). Comments are dropped — use the
|
|
57
|
+
* project build (`rev build docx --show-changes`) for the full filter chain and
|
|
58
|
+
* threaded comments.
|
|
43
59
|
*
|
|
44
60
|
* @param mdPath - Path to markdown file with CriticMarkup
|
|
45
61
|
* @param docxPath - Output path for Word document
|
|
46
|
-
* @param options -
|
|
62
|
+
* @param options - Author name for the revisions
|
|
47
63
|
* @returns Result with success status and message
|
|
48
64
|
*/
|
|
49
|
-
export declare function buildWithTrackChanges(mdPath: string, docxPath: string, options?:
|
|
65
|
+
export declare function buildWithTrackChanges(mdPath: string, docxPath: string, options?: NativeTrackChangeOptions): Promise<ApplyResult>;
|
|
50
66
|
export {};
|
|
51
67
|
//# sourceMappingURL=trackchanges.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackchanges.d.ts","sourceRoot":"","sources":["../../lib/trackchanges.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trackchanges.d.ts","sourceRoot":"","sources":["../../lib/trackchanges.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,UAAU,wBAAwB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,sBAAsB,CAAC;CAC/B;AAED,UAAU,WAAW;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,wBAA6B,GACrC,aAAa,CA8Bf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAe3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,WAAW,CAAC,CAuBtB"}
|
package/dist/lib/trackchanges.js
CHANGED
|
@@ -1,192 +1,131 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Track changes module - Apply markdown annotations as Word track changes
|
|
3
3
|
*
|
|
4
|
-
* Converts CriticMarkup
|
|
4
|
+
* Converts CriticMarkup insertions/deletions/substitutions to pandoc-native
|
|
5
|
+
* track-change spans (`[text]{.insertion}` / `[text]{.deletion}`). Pandoc's
|
|
6
|
+
* docx writer emits well-formed `w:ins`/`w:del` run-level revisions from these
|
|
7
|
+
* spans in a single pass, so the output is valid OOXML that Word accepts and
|
|
8
|
+
* that composes with comment injection (see lib/wordcomments.ts).
|
|
5
9
|
*/
|
|
6
10
|
import * as fs from 'fs';
|
|
7
11
|
import * as path from 'path';
|
|
8
12
|
import { execSync } from 'child_process';
|
|
9
13
|
import AdmZip from 'adm-zip';
|
|
10
|
-
|
|
14
|
+
/** Word/pandoc want revision dates without milliseconds: 2026-07-05T08:33:00Z */
|
|
15
|
+
function isoDateNoMillis() {
|
|
16
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Escape a value for use inside a pandoc span attribute (`author="..."`).
|
|
20
|
+
* Pandoc attribute values are double-quoted; a literal `"` or `\` would break
|
|
21
|
+
* the attribute, so both are backslash-escaped.
|
|
22
|
+
*/
|
|
23
|
+
function escapeSpanAttr(value) {
|
|
24
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
25
|
+
}
|
|
11
26
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
27
|
+
* Convert CriticMarkup insertions/deletions/substitutions to pandoc-native
|
|
28
|
+
* track-change spans. Comments (`{>>...<<}`) and highlights (`{==...==}`) are
|
|
29
|
+
* left untouched — the caller decides how to handle those (strip, or thread
|
|
30
|
+
* them via wordcomments.ts).
|
|
14
31
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
32
|
+
* A single pandoc pass over the result emits valid `w:ins`/`w:del` revisions,
|
|
33
|
+
* so this composes with the full rev filter chain (crossref, citeproc,
|
|
34
|
+
* reference-doc, macros) instead of post-processing document.xml by hand.
|
|
35
|
+
*
|
|
36
|
+
* @param text - Markdown with CriticMarkup annotations
|
|
37
|
+
* @param options - Author/date for the revisions
|
|
38
|
+
* @returns Converted markdown plus per-type counts
|
|
18
39
|
*/
|
|
19
|
-
export function
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
40
|
+
export function criticToNativeTrackChanges(text, options = {}) {
|
|
41
|
+
const author = escapeSpanAttr(options.author ?? 'Author');
|
|
42
|
+
const date = escapeSpanAttr(options.date ?? isoDateNoMillis());
|
|
43
|
+
const insAttr = `{.insertion author="${author}" date="${date}"}`;
|
|
44
|
+
const delAttr = `{.deletion author="${author}" date="${date}"}`;
|
|
45
|
+
const stats = { insertions: 0, deletions: 0, substitutions: 0 };
|
|
23
46
|
let result = text;
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
content,
|
|
31
|
-
author,
|
|
32
|
-
});
|
|
33
|
-
return `{{TC_${id}}}`;
|
|
34
|
-
});
|
|
35
|
-
// Process deletions: {--text--}
|
|
36
|
-
result = result.replace(/\{--(.+?)--\}/gs, (match, content) => {
|
|
37
|
-
const id = markerId++;
|
|
38
|
-
markers.push({
|
|
39
|
-
id,
|
|
40
|
-
type: 'delete',
|
|
41
|
-
content,
|
|
42
|
-
author,
|
|
43
|
-
});
|
|
44
|
-
return `{{TC_${id}}}`;
|
|
47
|
+
// Substitutions first so `{~~old~>new~~}` is consumed before the insertion/
|
|
48
|
+
// deletion passes could see its inner delimiters. Emit delete-then-insert so
|
|
49
|
+
// Word shows the struck-through original followed by the replacement.
|
|
50
|
+
result = result.replace(/\{~~([\s\S]+?)~>([\s\S]+?)~~\}/g, (_m, oldText, newText) => {
|
|
51
|
+
stats.substitutions++;
|
|
52
|
+
return `[${oldText}]${delAttr}[${newText}]${insAttr}`;
|
|
45
53
|
});
|
|
46
|
-
//
|
|
47
|
-
result = result.replace(/\{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
id,
|
|
51
|
-
type: 'substitute',
|
|
52
|
-
content: old,
|
|
53
|
-
replacement,
|
|
54
|
-
author,
|
|
55
|
-
});
|
|
56
|
-
return `{{TC_${id}}}`;
|
|
54
|
+
// Insertions: {++text++}
|
|
55
|
+
result = result.replace(/\{\+\+([\s\S]+?)\+\+\}/g, (_m, content) => {
|
|
56
|
+
stats.insertions++;
|
|
57
|
+
return `[${content}]${insAttr}`;
|
|
57
58
|
});
|
|
58
|
-
//
|
|
59
|
-
result = result.replace(/\{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const colonIdx = content.indexOf(':');
|
|
63
|
-
let commentAuthor = author;
|
|
64
|
-
let commentText = content;
|
|
65
|
-
if (colonIdx > 0 && colonIdx < 30) {
|
|
66
|
-
commentAuthor = content.slice(0, colonIdx).trim();
|
|
67
|
-
commentText = content.slice(colonIdx + 1).trim();
|
|
68
|
-
}
|
|
69
|
-
markers.push({
|
|
70
|
-
id,
|
|
71
|
-
type: 'comment',
|
|
72
|
-
content: commentText,
|
|
73
|
-
author: commentAuthor,
|
|
74
|
-
});
|
|
75
|
-
return `{{TC_${id}}}`;
|
|
59
|
+
// Deletions: {--text--}
|
|
60
|
+
result = result.replace(/\{--([\s\S]+?)--\}/g, (_m, content) => {
|
|
61
|
+
stats.deletions++;
|
|
62
|
+
return `[${content}]${delAttr}`;
|
|
76
63
|
});
|
|
77
|
-
return { text: result,
|
|
64
|
+
return { text: result, stats };
|
|
78
65
|
}
|
|
79
66
|
/**
|
|
80
|
-
*
|
|
67
|
+
* Enable tracked-revision display in a docx's settings.xml (in place).
|
|
81
68
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @returns Result with success status and message
|
|
69
|
+
* The `w:ins`/`w:del` elements already render as tracked changes without this,
|
|
70
|
+
* but `w:trackRevisions` tells Word to keep tracking the author's further
|
|
71
|
+
* edits — the expected state for a "return to author" review document.
|
|
86
72
|
*/
|
|
87
|
-
export
|
|
88
|
-
|
|
89
|
-
return { success: false, message: `File not found: ${docxPath}` };
|
|
90
|
-
}
|
|
91
|
-
let zip;
|
|
92
|
-
try {
|
|
93
|
-
zip = new AdmZip(docxPath);
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
const error = err;
|
|
97
|
-
return { success: false, message: `Invalid DOCX file: ${error.message}` };
|
|
98
|
-
}
|
|
99
|
-
// Read document.xml
|
|
100
|
-
const docEntry = zip.getEntry('word/document.xml');
|
|
101
|
-
if (!docEntry) {
|
|
102
|
-
return { success: false, message: 'Invalid DOCX: no document.xml' };
|
|
103
|
-
}
|
|
104
|
-
let documentXml = zip.readAsText(docEntry);
|
|
105
|
-
// Generate ISO date for track changes
|
|
106
|
-
const now = new Date().toISOString();
|
|
107
|
-
// Replace markers with track change XML
|
|
108
|
-
for (const marker of markers) {
|
|
109
|
-
const placeholder = `{{TC_${marker.id}}}`;
|
|
110
|
-
let replacement = '';
|
|
111
|
-
const escapedContent = escapeXml(marker.content);
|
|
112
|
-
const escapedAuthor = escapeXml(marker.author);
|
|
113
|
-
if (marker.type === 'insert') {
|
|
114
|
-
replacement = `<w:ins w:id="${marker.id}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:t>${escapedContent}</w:t></w:r></w:ins>`;
|
|
115
|
-
}
|
|
116
|
-
else if (marker.type === 'delete') {
|
|
117
|
-
replacement = `<w:del w:id="${marker.id}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:delText>${escapedContent}</w:delText></w:r></w:del>`;
|
|
118
|
-
}
|
|
119
|
-
else if (marker.type === 'substitute') {
|
|
120
|
-
const escapedReplacement = escapeXml(marker.replacement || '');
|
|
121
|
-
replacement = `<w:del w:id="${marker.id}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:delText>${escapedContent}</w:delText></w:r></w:del><w:ins w:id="${marker.id + 1000}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:t>${escapedReplacement}</w:t></w:r></w:ins>`;
|
|
122
|
-
}
|
|
123
|
-
documentXml = documentXml.replace(placeholder, replacement);
|
|
124
|
-
}
|
|
125
|
-
// Update document.xml
|
|
126
|
-
zip.updateFile('word/document.xml', Buffer.from(documentXml));
|
|
127
|
-
// Enable track revisions in settings.xml
|
|
73
|
+
export function enableTrackRevisions(docxPath) {
|
|
74
|
+
const zip = new AdmZip(docxPath);
|
|
128
75
|
const settingsEntry = zip.getEntry('word/settings.xml');
|
|
129
|
-
if (settingsEntry)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
76
|
+
if (!settingsEntry)
|
|
77
|
+
return;
|
|
78
|
+
let settingsXml = zip.readAsText(settingsEntry);
|
|
79
|
+
if (settingsXml.includes('w:trackRevisions'))
|
|
80
|
+
return;
|
|
81
|
+
// trackRevisions must appear early in the ordered settings sequence; placing
|
|
82
|
+
// it right after the opening tag keeps Word from rejecting the schema order.
|
|
83
|
+
settingsXml = settingsXml.replace(/(<w:settings[^>]*>)/, '$1<w:trackRevisions/>');
|
|
84
|
+
if (!settingsXml.includes('<w:trackRevisions/>')) {
|
|
85
|
+
// No opening tag matched (unexpected) — fall back to before the close tag.
|
|
86
|
+
settingsXml = settingsXml.replace('</w:settings>', '<w:trackRevisions/></w:settings>');
|
|
135
87
|
}
|
|
136
|
-
|
|
137
|
-
zip.writeZip(
|
|
138
|
-
return { success: true, message: `Created ${outputPath} with track changes` };
|
|
88
|
+
zip.updateFile('word/settings.xml', Buffer.from(settingsXml, 'utf-8'));
|
|
89
|
+
zip.writeZip(docxPath);
|
|
139
90
|
}
|
|
140
91
|
/**
|
|
141
|
-
* Build a Word document with track changes from annotated markdown
|
|
92
|
+
* Build a standalone Word document with track changes from annotated markdown.
|
|
93
|
+
*
|
|
94
|
+
* Used by `rev apply <md> <docx>` for a single markdown file outside a rev
|
|
95
|
+
* project (no crossref/citeproc/reference-doc). Comments are dropped — use the
|
|
96
|
+
* project build (`rev build docx --show-changes`) for the full filter chain and
|
|
97
|
+
* threaded comments.
|
|
142
98
|
*
|
|
143
99
|
* @param mdPath - Path to markdown file with CriticMarkup
|
|
144
100
|
* @param docxPath - Output path for Word document
|
|
145
|
-
* @param options -
|
|
101
|
+
* @param options - Author name for the revisions
|
|
146
102
|
* @returns Result with success status and message
|
|
147
103
|
*/
|
|
148
104
|
export async function buildWithTrackChanges(mdPath, docxPath, options = {}) {
|
|
149
|
-
const { author = 'Author' } = options;
|
|
150
105
|
if (!fs.existsSync(mdPath)) {
|
|
151
106
|
return { success: false, message: `File not found: ${mdPath}` };
|
|
152
107
|
}
|
|
108
|
+
const { author = 'Author' } = options;
|
|
153
109
|
const content = fs.readFileSync(mdPath, 'utf-8');
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
if (markers.length === 0) {
|
|
158
|
-
try {
|
|
159
|
-
execSync(`pandoc "${mdPath}" -o "${docxPath}"`, { encoding: 'utf-8' });
|
|
160
|
-
return { success: true, message: `Created ${docxPath}` };
|
|
161
|
-
}
|
|
162
|
-
catch (err) {
|
|
163
|
-
const error = err;
|
|
164
|
-
return { success: false, message: error.message };
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// Write prepared content to temp file
|
|
168
|
-
const tempDir = path.dirname(mdPath);
|
|
169
|
-
const tempMd = path.join(tempDir, `.temp-${Date.now()}.md`);
|
|
170
|
-
const tempDocx = path.join(tempDir, `.temp-${Date.now()}.docx`);
|
|
110
|
+
const { text: converted, stats } = criticToNativeTrackChanges(content, { author });
|
|
111
|
+
const total = stats.insertions + stats.deletions + stats.substitutions;
|
|
112
|
+
const tempMd = path.join(path.dirname(mdPath), `.temp-tc-${process.pid}.md`);
|
|
171
113
|
try {
|
|
172
|
-
fs.writeFileSync(tempMd,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// Clean up temp files
|
|
178
|
-
fs.unlinkSync(tempMd);
|
|
179
|
-
fs.unlinkSync(tempDocx);
|
|
180
|
-
return result;
|
|
114
|
+
fs.writeFileSync(tempMd, converted, 'utf-8');
|
|
115
|
+
execSync(`pandoc "${tempMd}" -o "${docxPath}"`, { encoding: 'utf-8' });
|
|
116
|
+
if (total > 0)
|
|
117
|
+
enableTrackRevisions(docxPath);
|
|
118
|
+
return { success: true, message: `Created ${docxPath} with track changes`, stats };
|
|
181
119
|
}
|
|
182
120
|
catch (err) {
|
|
183
|
-
// Clean up on error
|
|
184
|
-
if (fs.existsSync(tempMd))
|
|
185
|
-
fs.unlinkSync(tempMd);
|
|
186
|
-
if (fs.existsSync(tempDocx))
|
|
187
|
-
fs.unlinkSync(tempDocx);
|
|
188
121
|
const error = err;
|
|
189
122
|
return { success: false, message: error.message };
|
|
190
123
|
}
|
|
124
|
+
finally {
|
|
125
|
+
try {
|
|
126
|
+
fs.unlinkSync(tempMd);
|
|
127
|
+
}
|
|
128
|
+
catch { /* best-effort cleanup */ }
|
|
129
|
+
}
|
|
191
130
|
}
|
|
192
131
|
//# sourceMappingURL=trackchanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackchanges.js","sourceRoot":"","sources":["../../lib/trackchanges.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trackchanges.js","sourceRoot":"","sources":["../../lib/trackchanges.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,MAAM,MAAM,SAAS,CAAC;AAyB7B,iFAAiF;AACjF,SAAS,eAAe;IACtB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAY,EACZ,UAAoC,EAAE;IAEtC,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,IAAI,eAAe,EAAE,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,uBAAuB,MAAM,WAAW,IAAI,IAAI,CAAC;IACjE,MAAM,OAAO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OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAE7E,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7C,QAAQ,CAAC,WAAW,MAAM,SAAS,QAAQ,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QACvE,IAAI,KAAK,GAAG,CAAC;YAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,QAAQ,qBAAqB,EAAE,KAAK,EAAE,CAAC;IACrF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAY,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IACpD,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,yBAAyB,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -188,7 +188,13 @@ export interface BibEntry {
|
|
|
188
188
|
}
|
|
189
189
|
export interface DoiCheckResult {
|
|
190
190
|
valid: boolean;
|
|
191
|
-
source?: 'crossref' | 'datacite';
|
|
191
|
+
source?: 'crossref' | 'datacite' | 'doi.org';
|
|
192
|
+
/**
|
|
193
|
+
* True when the registry could not be reached (network error, timeout, or
|
|
194
|
+
* 5xx) — the DOI's validity is unknown, distinct from a definitive "not
|
|
195
|
+
* found". Callers must not report an unreachable DOI as invalid.
|
|
196
|
+
*/
|
|
197
|
+
unreachable?: boolean;
|
|
192
198
|
metadata?: {
|
|
193
199
|
title: string;
|
|
194
200
|
authors: string[];
|
|
@@ -229,6 +235,8 @@ export interface BibCheckResult {
|
|
|
229
235
|
}>;
|
|
230
236
|
valid: number;
|
|
231
237
|
invalid: number;
|
|
238
|
+
/** DOIs whose registry could not be reached (network/timeout) — not invalid. */
|
|
239
|
+
unreachable: number;
|
|
232
240
|
missing: number;
|
|
233
241
|
skipped: number;
|
|
234
242
|
}
|
|
@@ -444,13 +452,6 @@ export interface TrackChangesResult {
|
|
|
444
452
|
deletions: number;
|
|
445
453
|
};
|
|
446
454
|
}
|
|
447
|
-
export interface TrackChangeMarker {
|
|
448
|
-
id: number;
|
|
449
|
-
type: 'insert' | 'delete' | 'substitute' | 'comment';
|
|
450
|
-
content: string;
|
|
451
|
-
author: string;
|
|
452
|
-
replacement?: string;
|
|
453
|
-
}
|
|
454
455
|
export interface SpellingIssue {
|
|
455
456
|
word: string;
|
|
456
457
|
line: number;
|