docrev 0.9.17 → 0.10.0

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.
@@ -6,14 +6,20 @@
6
6
  * tsc compiles bin/rev.ts → dist/bin/rev.js but:
7
7
  * 1. Preserves the #!/usr/bin/env tsx shebang (needs to be node)
8
8
  * 2. Relative paths like '../package.json' break (bin/ → dist/bin/ adds a level)
9
+ *
10
+ * Also copies non-TS asset files (lua filters) from lib/ to dist/lib/ so the
11
+ * compiled output can locate them via `import.meta.url`. Without this step
12
+ * the lua filters live in lib/ in the published tarball while the runtime
13
+ * looks for them in dist/lib/.
9
14
  */
10
15
 
11
- import { readFileSync, writeFileSync } from 'fs';
16
+ import { readFileSync, writeFileSync, readdirSync, copyFileSync, mkdirSync, existsSync } from 'fs';
12
17
  import { join, dirname } from 'path';
13
18
  import { fileURLToPath } from 'url';
14
19
 
15
20
  const __dirname = dirname(fileURLToPath(import.meta.url));
16
- const revPath = join(__dirname, '..', 'dist', 'bin', 'rev.js');
21
+ const projectRoot = join(__dirname, '..');
22
+ const revPath = join(projectRoot, 'dist', 'bin', 'rev.js');
17
23
 
18
24
  let content = readFileSync(revPath, 'utf-8');
19
25
 
@@ -26,3 +32,16 @@ content = content.replace("'../package.json'", "'../../package.json'");
26
32
 
27
33
  writeFileSync(revPath, content, 'utf-8');
28
34
  console.log('postbuild: fixed dist/bin/rev.js (shebang + paths)');
35
+
36
+ // Copy lua filter assets so import.meta.url resolves them at runtime.
37
+ const libDir = join(projectRoot, 'lib');
38
+ const distLibDir = join(projectRoot, 'dist', 'lib');
39
+ if (!existsSync(distLibDir)) {
40
+ mkdirSync(distLibDir, { recursive: true });
41
+ }
42
+ for (const entry of readdirSync(libDir)) {
43
+ if (entry.endsWith('.lua')) {
44
+ copyFileSync(join(libDir, entry), join(distLibDir, entry));
45
+ console.log(`postbuild: copied ${entry} → dist/lib/`);
46
+ }
47
+ }
@@ -62,11 +62,77 @@ rev build docx # DOCX only
62
62
  rev build --toc # Include table of contents
63
63
  rev build docx --dual # Clean + annotated versions
64
64
  rev build docx --show-changes # DOCX with visible track changes (audit)
65
+ rev build docx --pandoc-arg=--lua-filter=tofill.lua # Pass extra args to pandoc
66
+ rev build -o Final_Report # Override output filename (extension auto-added)
67
+ rev build pdf --verbose # Echo the pandoc invocation (useful for filter debugging)
65
68
  ```
66
69
 
67
70
  By default, outputs land in `output/` next to `rev.yaml`. Override or
68
71
  disable via the `outputDir` field in rev.yaml (see below).
69
72
 
73
+ #### Choosing output filenames
74
+
75
+ By default, the output basename is derived from `title:` (slugified — e.g.
76
+ "My Paper" → `my-paper.docx`). Long titles are truncated at word boundaries
77
+ (at the last `-` at-or-before 80 chars), so `communities` stays whole instead
78
+ of becoming `communitie`.
79
+
80
+ To pick your own filename, set per-format names in `rev.yaml`:
81
+
82
+ ```yaml
83
+ output:
84
+ docx: ADAPT_proposal_draft.docx
85
+ pdf: ADAPT_proposal_draft.pdf
86
+ ```
87
+
88
+ Extensions are optional — `ADAPT_proposal_draft` is fine, the right extension
89
+ is added per format. Relative paths resolve under `outputDir`; absolute paths
90
+ bypass `outputDir`.
91
+
92
+ Or override on the command line with `-o, --output <path>`:
93
+
94
+ ```bash
95
+ rev build docx -o Final_Report # → output/Final_Report.docx
96
+ rev build pdf docx -o Final_Report # Applies to both formats
97
+ rev build -o /tmp/draft.docx docx # Absolute path bypasses outputDir
98
+ ```
99
+
100
+ CLI `-o` wins over `output:` in `rev.yaml`. When `--dual` is on, the
101
+ `_comments` variant piggybacks on the chosen name (e.g.
102
+ `Final_Report_comments.docx`). When `--show-changes` is on, the audit DOCX
103
+ uses the chosen name with a `-changes` suffix
104
+ (e.g. `Final_Report-changes.docx`).
105
+
106
+ #### Passing custom pandoc args
107
+
108
+ For pandoc flags rev doesn't surface directly (Lua/JSON filters, custom
109
+ templates, variables, etc.), use the repeatable `--pandoc-arg` flag or the
110
+ `pandoc-args` field in `rev.yaml`:
111
+
112
+ ```yaml
113
+ # rev.yaml — applies to every format
114
+ pandoc-args:
115
+ - --lua-filter=tofill.lua
116
+ - --shift-heading-level-by=1
117
+
118
+ # Format-specific (concatenated after the top-level list)
119
+ docx:
120
+ pandoc-args:
121
+ - --lua-filter=docx_only.lua
122
+ pdf:
123
+ pandoc-args:
124
+ - --variable=papersize:a4
125
+ ```
126
+
127
+ ```bash
128
+ # CLI overrides — appended last, so pandoc's last-wins rule lets CLI flags
129
+ # beat repeated config flags
130
+ rev build docx --pandoc-arg=--lua-filter=cli.lua --pandoc-arg=--metadata=draft:true
131
+ ```
132
+
133
+ Run with `--verbose` to print the full pandoc command line (one per format).
134
+ Copy-paste it into a terminal to reproduce a build manually.
135
+
70
136
  The `--dual` flag produces:
71
137
  - `output/<title>.docx` — clean, for submission
72
138
  - `output/<title>_comments.docx` — includes comment threads as Word comments
package/skill/SKILL.md CHANGED
@@ -17,9 +17,8 @@ Layout is controlled in `rev.yaml`:
17
17
 
18
18
  ```yaml
19
19
  title: "My Document"
20
- output:
21
- docx:
22
- reference-doc: template.docx
20
+ docx:
21
+ reference: template.docx
23
22
  ```
24
23
 
25
24
  Change the template, rebuild, and every document gets the new formatting.
@@ -98,7 +97,15 @@ revision is rendered as a visible Word track change. Useful when a co-author
98
97
  wants to see what changed since the last shared version.
99
98
 
100
99
  Outputs land in `output/` by default; set `outputDir: null` in `rev.yaml`
101
- to keep them alongside `paper.md` (legacy layout).
100
+ to keep them alongside `paper.md` (legacy layout). The basename is derived
101
+ from `title:` unless overridden — set `output: { docx: foo.docx, pdf: foo.pdf }`
102
+ in `rev.yaml` or pass `-o, --output <path>` on the CLI. See REFERENCE.md →
103
+ "Choosing output filenames".
104
+
105
+ For pandoc flags rev doesn't surface directly (Lua filters, custom variables,
106
+ templates), use `--pandoc-arg` (repeatable) or `pandoc-args:` in `rev.yaml`
107
+ (both top-level and per-format). Run with `--verbose` to see the exact pandoc
108
+ invocation. See REFERENCE.md → "Passing custom pandoc args" for details.
102
109
 
103
110
  ### 8. Archive reviewer files
104
111
 
@@ -183,6 +190,20 @@ Use in markdown files:
183
190
  - `@eq:label` - Equation reference
184
191
  - `{#fig:label}` - Anchor for figures
185
192
 
193
+ Insert a figure with the format-portable syntax (renders in both PDF and Word):
194
+
195
+ ```markdown
196
+ ![Caption text.](figures/foo.pdf){#fig:foo width=80%}
197
+ ```
198
+
199
+ Raw `\begin{figure}...\end{figure}` LaTeX blocks are PDF-only. For docx
200
+ builds, `rev` auto-translates the common shape (single `\includegraphics`
201
+ with optional `\caption{...}` and `\label{...}`) to the markdown form above
202
+ so figures still render. Exotic blocks (`\subfloat`, `\rotatebox`, multiple
203
+ `\includegraphics`) are left alone and warned about — convert them by hand
204
+ or supply a custom Lua filter via `--pandoc-arg`. Opt out of auto-translate
205
+ with `docx.translateRawFigures: false` in `rev.yaml`.
206
+
186
207
  ## Template Variables
187
208
 
188
209
  Available in section files (processed during build):
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Skill(code-quality)"
5
- ],
6
- "deny": [],
7
- "ask": []
8
- }
9
- }