docrev 0.9.18 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -1
- package/CHANGELOG.md +173 -149
- package/PLAN-tables-and-postprocess.md +850 -850
- package/README.md +431 -406
- package/bin/rev.js +11 -11
- package/bin/rev.ts +145 -145
- package/completions/rev.bash +127 -127
- package/completions/rev.ps1 +210 -210
- package/completions/rev.zsh +207 -207
- package/dist/lib/build.d.ts +8 -0
- package/dist/lib/build.d.ts.map +1 -1
- package/dist/lib/build.js +62 -6
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/commands/context.d.ts +1 -1
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/context.js +1 -1
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/sections.js +7 -7
- package/dist/lib/commands/sections.js.map +1 -1
- package/dist/lib/commands/sync.d.ts.map +1 -1
- package/dist/lib/commands/sync.js +15 -14
- package/dist/lib/commands/sync.js.map +1 -1
- package/dist/lib/commands/utilities.js +164 -164
- package/dist/lib/commands/verify-anchors.js +6 -6
- package/dist/lib/commands/verify-anchors.js.map +1 -1
- package/dist/lib/commands/word-tools.js +8 -8
- package/dist/lib/grammar.js +3 -3
- package/dist/lib/macro-filter.lua +201 -0
- package/dist/lib/macros.d.ts +102 -0
- package/dist/lib/macros.d.ts.map +1 -0
- package/dist/lib/macros.js +218 -0
- package/dist/lib/macros.js.map +1 -0
- package/dist/lib/pdf-comments.js +44 -44
- package/dist/lib/plugins.js +57 -57
- package/dist/lib/pptx-color-filter.lua +37 -0
- package/dist/lib/pptx-themes.js +115 -115
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +34 -0
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/sections.d.ts +35 -0
- package/dist/lib/sections.d.ts.map +1 -1
- package/dist/lib/sections.js +81 -0
- package/dist/lib/sections.js.map +1 -1
- package/dist/lib/spelling.js +2 -2
- package/dist/lib/templates.js +387 -387
- package/dist/lib/themes.js +51 -51
- package/eslint.config.js +27 -27
- package/lib/anchor-match.ts +276 -276
- package/lib/annotations.ts +644 -644
- package/lib/build.ts +1766 -1694
- package/lib/citations.ts +160 -160
- package/lib/commands/build.ts +855 -855
- package/lib/commands/citations.ts +515 -515
- package/lib/commands/comments.ts +1050 -1050
- package/lib/commands/context.ts +176 -174
- package/lib/commands/core.ts +309 -309
- package/lib/commands/doi.ts +435 -435
- package/lib/commands/file-ops.ts +372 -372
- package/lib/commands/history.ts +320 -320
- package/lib/commands/index.ts +87 -87
- package/lib/commands/init.ts +259 -259
- package/lib/commands/merge-resolve.ts +378 -378
- package/lib/commands/preview.ts +178 -178
- package/lib/commands/project-info.ts +244 -244
- package/lib/commands/quality.ts +517 -517
- package/lib/commands/response.ts +454 -454
- package/lib/commands/section-boundaries.ts +82 -82
- package/lib/commands/sections.ts +451 -451
- package/lib/commands/sync.ts +709 -706
- package/lib/commands/text-ops.ts +449 -449
- package/lib/commands/utilities.ts +448 -448
- package/lib/commands/verify-anchors.ts +272 -272
- package/lib/commands/word-tools.ts +340 -340
- package/lib/comment-realign.ts +517 -517
- package/lib/config.ts +84 -84
- package/lib/crossref.ts +781 -781
- package/lib/csl.ts +191 -191
- package/lib/dependencies.ts +98 -98
- package/lib/diff-engine.ts +465 -465
- package/lib/doi-cache.ts +115 -115
- package/lib/doi.ts +897 -897
- package/lib/equations.ts +506 -506
- package/lib/errors.ts +346 -346
- package/lib/format.ts +541 -541
- package/lib/git.ts +326 -326
- package/lib/grammar.ts +303 -303
- package/lib/image-registry.ts +180 -180
- package/lib/import.ts +911 -911
- package/lib/journals.ts +543 -543
- package/lib/macro-filter.lua +201 -0
- package/lib/macros.ts +273 -0
- package/lib/merge.ts +633 -633
- package/lib/orcid.ts +144 -144
- package/lib/pdf-comments.ts +263 -263
- package/lib/pdf-import.ts +524 -524
- package/lib/plugins.ts +362 -362
- package/lib/postprocess.ts +188 -188
- package/lib/pptx-color-filter.lua +37 -37
- package/lib/pptx-template.ts +469 -469
- package/lib/pptx-themes.ts +483 -483
- package/lib/protect-restore.ts +520 -520
- package/lib/rate-limiter.ts +94 -94
- package/lib/response.ts +197 -197
- package/lib/restore-references.ts +240 -240
- package/lib/review.ts +327 -327
- package/lib/schema.ts +488 -454
- package/lib/scientific-words.ts +73 -73
- package/lib/sections.ts +425 -335
- package/lib/slides.ts +756 -756
- package/lib/spelling.ts +334 -334
- package/lib/templates.ts +526 -526
- package/lib/themes.ts +742 -742
- package/lib/trackchanges.ts +247 -247
- package/lib/tui.ts +450 -450
- package/lib/types.ts +550 -550
- package/lib/undo.ts +250 -250
- package/lib/utils.ts +69 -69
- package/lib/variables.ts +179 -179
- package/lib/word-extraction.ts +806 -806
- package/lib/word.ts +643 -643
- package/lib/wordcomments.ts +840 -840
- package/package.json +137 -137
- package/scripts/postbuild.js +47 -28
- package/skill/REFERENCE.md +539 -539
- package/skill/SKILL.md +295 -295
- package/tsconfig.json +26 -26
- package/types/index.d.ts +525 -525
- package/issues.md +0 -180
- package/site/assets/extra.css +0 -208
- package/site/commands.html +0 -926
- package/site/configuration.html +0 -469
- package/site/index.html +0 -288
- package/site/troubleshooting.html +0 -461
- package/site/workflow.html +0 -518
package/completions/rev.zsh
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
#compdef rev
|
|
2
|
-
|
|
3
|
-
# Zsh completion for rev (docrev)
|
|
4
|
-
# Install: add to fpath or run:
|
|
5
|
-
# eval "$(rev completions zsh)"
|
|
6
|
-
|
|
7
|
-
_rev() {
|
|
8
|
-
local -a commands build_formats doi_actions eq_actions help_topics journals preview_formats
|
|
9
|
-
|
|
10
|
-
commands=(
|
|
11
|
-
'build:Build PDF/DOCX/TEX from sections'
|
|
12
|
-
'new:Create new project from template'
|
|
13
|
-
'import:Import Word document'
|
|
14
|
-
'sections:Import to section files'
|
|
15
|
-
'extract:Extract text from Word'
|
|
16
|
-
'review:Interactive review TUI'
|
|
17
|
-
'status:Show annotation counts'
|
|
18
|
-
'comments:List comments'
|
|
19
|
-
'resolve:Mark comment as resolved'
|
|
20
|
-
'reply:Reply to comments'
|
|
21
|
-
'strip:Output clean markdown'
|
|
22
|
-
'refs:Show reference status'
|
|
23
|
-
'migrate:Convert hardcoded refs'
|
|
24
|
-
'config:Configure settings'
|
|
25
|
-
'install:Check dependencies'
|
|
26
|
-
'doi:DOI validation'
|
|
27
|
-
'citations:Validate citations'
|
|
28
|
-
'equations:Extract equations'
|
|
29
|
-
'figures:List figures'
|
|
30
|
-
'response:Generate response letter'
|
|
31
|
-
'anonymize:Prepare for blind review'
|
|
32
|
-
'validate:Check journal requirements'
|
|
33
|
-
'merge:Merge reviewer feedback'
|
|
34
|
-
'diff:Compare against git history'
|
|
35
|
-
'history:Show revision history'
|
|
36
|
-
'help:Show help'
|
|
37
|
-
'init:Initialize project'
|
|
38
|
-
'split:Split paper.md to sections'
|
|
39
|
-
'word-count:Show word counts per section'
|
|
40
|
-
'wc:Show word counts (alias)'
|
|
41
|
-
'stats:Show project statistics'
|
|
42
|
-
'search:Search across files'
|
|
43
|
-
'backup:Create timestamped backup'
|
|
44
|
-
'export:Export project as zip'
|
|
45
|
-
'preview:Build and open document'
|
|
46
|
-
'watch:Watch and auto-rebuild'
|
|
47
|
-
'lint:Check for issues'
|
|
48
|
-
'grammar:Check grammar and style'
|
|
49
|
-
'annotate:Add comments to DOCX'
|
|
50
|
-
'apply:Apply annotations as track changes'
|
|
51
|
-
'comment:Interactive comment mode'
|
|
52
|
-
'completions:Generate shell completions'
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
preview_formats=(
|
|
56
|
-
'pdf:Preview PDF'
|
|
57
|
-
'docx:Preview Word document'
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
build_formats=(
|
|
61
|
-
'pdf:Build PDF'
|
|
62
|
-
'docx:Build Word document'
|
|
63
|
-
'tex:Build LaTeX'
|
|
64
|
-
'all:Build all formats'
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
doi_actions=(
|
|
68
|
-
'check:Validate DOIs'
|
|
69
|
-
'lookup:Find missing DOIs'
|
|
70
|
-
'fetch:Get BibTeX from DOI'
|
|
71
|
-
'add:Add citation by DOI'
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
eq_actions=(
|
|
75
|
-
'list:List equations'
|
|
76
|
-
'extract:Extract to file'
|
|
77
|
-
'convert:Convert to Word'
|
|
78
|
-
'from-word:Extract from Word'
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
help_topics=(
|
|
82
|
-
'workflow:Review workflow'
|
|
83
|
-
'syntax:CriticMarkup syntax'
|
|
84
|
-
'commands:All commands'
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
journals=(
|
|
88
|
-
'nature:Nature journal'
|
|
89
|
-
'science:Science journal'
|
|
90
|
-
'plos:PLOS ONE'
|
|
91
|
-
'cell:Cell journal'
|
|
92
|
-
'ecology:Ecology journals'
|
|
93
|
-
'custom:Custom profile'
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
case "$words[2]" in
|
|
97
|
-
build)
|
|
98
|
-
_describe -t formats 'format' build_formats
|
|
99
|
-
_arguments \
|
|
100
|
-
'--toc[Include table of contents]' \
|
|
101
|
-
'--show-changes[Show track changes in DOCX]' \
|
|
102
|
-
'--clean[Clean build files]'
|
|
103
|
-
;;
|
|
104
|
-
new)
|
|
105
|
-
_arguments \
|
|
106
|
-
'--list[List templates]' \
|
|
107
|
-
'--template[Template name]:template:(paper minimal thesis proposal)'
|
|
108
|
-
;;
|
|
109
|
-
doi)
|
|
110
|
-
_describe -t actions 'action' doi_actions
|
|
111
|
-
;;
|
|
112
|
-
equations|eq)
|
|
113
|
-
_describe -t actions 'action' eq_actions
|
|
114
|
-
;;
|
|
115
|
-
validate)
|
|
116
|
-
_arguments \
|
|
117
|
-
'--list[List journals]' \
|
|
118
|
-
'--journal[Journal name]:journal:($journals)'
|
|
119
|
-
;;
|
|
120
|
-
help)
|
|
121
|
-
_describe -t topics 'topic' help_topics
|
|
122
|
-
;;
|
|
123
|
-
config)
|
|
124
|
-
_values 'setting' 'user[Set user name]'
|
|
125
|
-
;;
|
|
126
|
-
word-count|wc)
|
|
127
|
-
_arguments \
|
|
128
|
-
'--limit[Word limit]:number:' \
|
|
129
|
-
'--journal[Use journal word limit]:journal:'
|
|
130
|
-
;;
|
|
131
|
-
preview)
|
|
132
|
-
_describe -t formats 'format' preview_formats
|
|
133
|
-
;;
|
|
134
|
-
watch)
|
|
135
|
-
_arguments \
|
|
136
|
-
'--no-open[Do not open after build]'
|
|
137
|
-
_values 'format' 'pdf' 'docx' 'all'
|
|
138
|
-
;;
|
|
139
|
-
lint)
|
|
140
|
-
_arguments \
|
|
141
|
-
'--fix[Auto-fix issues]'
|
|
142
|
-
;;
|
|
143
|
-
grammar)
|
|
144
|
-
_arguments \
|
|
145
|
-
'--learn[Add word to dictionary]:word:' \
|
|
146
|
-
'--forget[Remove from dictionary]:word:' \
|
|
147
|
-
'--list[List dictionary words]' \
|
|
148
|
-
'--rules[List grammar rules]' \
|
|
149
|
-
'--no-scientific[Disable science rules]' \
|
|
150
|
-
'--severity[Minimum severity]:level:(error warning info)'
|
|
151
|
-
_files -g '*.md'
|
|
152
|
-
;;
|
|
153
|
-
annotate)
|
|
154
|
-
_arguments \
|
|
155
|
-
'-m[Comment message]:text:' \
|
|
156
|
-
'-s[Search text]:text:' \
|
|
157
|
-
'-a[Author name]:name:'
|
|
158
|
-
_files -g '*.docx'
|
|
159
|
-
;;
|
|
160
|
-
apply)
|
|
161
|
-
_arguments \
|
|
162
|
-
'-a[Author name]:name:'
|
|
163
|
-
_files -g '*.md'
|
|
164
|
-
;;
|
|
165
|
-
comment)
|
|
166
|
-
_arguments \
|
|
167
|
-
'-a[Author name]:name:'
|
|
168
|
-
_files -g '*.docx'
|
|
169
|
-
;;
|
|
170
|
-
completions)
|
|
171
|
-
_values 'shell' 'bash' 'zsh'
|
|
172
|
-
;;
|
|
173
|
-
import|sections|extract|review|status|comments|strip|refs|migrate|figures|response|anonymize|split|search|stats)
|
|
174
|
-
_files -g '*.md' -g '*.docx'
|
|
175
|
-
;;
|
|
176
|
-
resolve|reply)
|
|
177
|
-
_arguments \
|
|
178
|
-
'-n[Comment number]:number:' \
|
|
179
|
-
'-m[Reply message]:message:'
|
|
180
|
-
_files -g '*.md'
|
|
181
|
-
;;
|
|
182
|
-
check|lookup|add|citations)
|
|
183
|
-
_files -g '*.bib'
|
|
184
|
-
;;
|
|
185
|
-
merge)
|
|
186
|
-
_files -g '*.md' -g '*.docx'
|
|
187
|
-
;;
|
|
188
|
-
backup)
|
|
189
|
-
_arguments \
|
|
190
|
-
'--name[Custom backup name]:name:' \
|
|
191
|
-
'--output[Output directory]:dir:_files -/'
|
|
192
|
-
;;
|
|
193
|
-
export)
|
|
194
|
-
_arguments \
|
|
195
|
-
'--output[Output filename]:file:' \
|
|
196
|
-
'--include-output[Include built files]'
|
|
197
|
-
;;
|
|
198
|
-
*)
|
|
199
|
-
_describe -t commands 'command' commands
|
|
200
|
-
_arguments \
|
|
201
|
-
'--help[Show help]' \
|
|
202
|
-
'--version[Show version]'
|
|
203
|
-
;;
|
|
204
|
-
esac
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
_rev "$@"
|
|
1
|
+
#compdef rev
|
|
2
|
+
|
|
3
|
+
# Zsh completion for rev (docrev)
|
|
4
|
+
# Install: add to fpath or run:
|
|
5
|
+
# eval "$(rev completions zsh)"
|
|
6
|
+
|
|
7
|
+
_rev() {
|
|
8
|
+
local -a commands build_formats doi_actions eq_actions help_topics journals preview_formats
|
|
9
|
+
|
|
10
|
+
commands=(
|
|
11
|
+
'build:Build PDF/DOCX/TEX from sections'
|
|
12
|
+
'new:Create new project from template'
|
|
13
|
+
'import:Import Word document'
|
|
14
|
+
'sections:Import to section files'
|
|
15
|
+
'extract:Extract text from Word'
|
|
16
|
+
'review:Interactive review TUI'
|
|
17
|
+
'status:Show annotation counts'
|
|
18
|
+
'comments:List comments'
|
|
19
|
+
'resolve:Mark comment as resolved'
|
|
20
|
+
'reply:Reply to comments'
|
|
21
|
+
'strip:Output clean markdown'
|
|
22
|
+
'refs:Show reference status'
|
|
23
|
+
'migrate:Convert hardcoded refs'
|
|
24
|
+
'config:Configure settings'
|
|
25
|
+
'install:Check dependencies'
|
|
26
|
+
'doi:DOI validation'
|
|
27
|
+
'citations:Validate citations'
|
|
28
|
+
'equations:Extract equations'
|
|
29
|
+
'figures:List figures'
|
|
30
|
+
'response:Generate response letter'
|
|
31
|
+
'anonymize:Prepare for blind review'
|
|
32
|
+
'validate:Check journal requirements'
|
|
33
|
+
'merge:Merge reviewer feedback'
|
|
34
|
+
'diff:Compare against git history'
|
|
35
|
+
'history:Show revision history'
|
|
36
|
+
'help:Show help'
|
|
37
|
+
'init:Initialize project'
|
|
38
|
+
'split:Split paper.md to sections'
|
|
39
|
+
'word-count:Show word counts per section'
|
|
40
|
+
'wc:Show word counts (alias)'
|
|
41
|
+
'stats:Show project statistics'
|
|
42
|
+
'search:Search across files'
|
|
43
|
+
'backup:Create timestamped backup'
|
|
44
|
+
'export:Export project as zip'
|
|
45
|
+
'preview:Build and open document'
|
|
46
|
+
'watch:Watch and auto-rebuild'
|
|
47
|
+
'lint:Check for issues'
|
|
48
|
+
'grammar:Check grammar and style'
|
|
49
|
+
'annotate:Add comments to DOCX'
|
|
50
|
+
'apply:Apply annotations as track changes'
|
|
51
|
+
'comment:Interactive comment mode'
|
|
52
|
+
'completions:Generate shell completions'
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
preview_formats=(
|
|
56
|
+
'pdf:Preview PDF'
|
|
57
|
+
'docx:Preview Word document'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
build_formats=(
|
|
61
|
+
'pdf:Build PDF'
|
|
62
|
+
'docx:Build Word document'
|
|
63
|
+
'tex:Build LaTeX'
|
|
64
|
+
'all:Build all formats'
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
doi_actions=(
|
|
68
|
+
'check:Validate DOIs'
|
|
69
|
+
'lookup:Find missing DOIs'
|
|
70
|
+
'fetch:Get BibTeX from DOI'
|
|
71
|
+
'add:Add citation by DOI'
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
eq_actions=(
|
|
75
|
+
'list:List equations'
|
|
76
|
+
'extract:Extract to file'
|
|
77
|
+
'convert:Convert to Word'
|
|
78
|
+
'from-word:Extract from Word'
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
help_topics=(
|
|
82
|
+
'workflow:Review workflow'
|
|
83
|
+
'syntax:CriticMarkup syntax'
|
|
84
|
+
'commands:All commands'
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
journals=(
|
|
88
|
+
'nature:Nature journal'
|
|
89
|
+
'science:Science journal'
|
|
90
|
+
'plos:PLOS ONE'
|
|
91
|
+
'cell:Cell journal'
|
|
92
|
+
'ecology:Ecology journals'
|
|
93
|
+
'custom:Custom profile'
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
case "$words[2]" in
|
|
97
|
+
build)
|
|
98
|
+
_describe -t formats 'format' build_formats
|
|
99
|
+
_arguments \
|
|
100
|
+
'--toc[Include table of contents]' \
|
|
101
|
+
'--show-changes[Show track changes in DOCX]' \
|
|
102
|
+
'--clean[Clean build files]'
|
|
103
|
+
;;
|
|
104
|
+
new)
|
|
105
|
+
_arguments \
|
|
106
|
+
'--list[List templates]' \
|
|
107
|
+
'--template[Template name]:template:(paper minimal thesis proposal)'
|
|
108
|
+
;;
|
|
109
|
+
doi)
|
|
110
|
+
_describe -t actions 'action' doi_actions
|
|
111
|
+
;;
|
|
112
|
+
equations|eq)
|
|
113
|
+
_describe -t actions 'action' eq_actions
|
|
114
|
+
;;
|
|
115
|
+
validate)
|
|
116
|
+
_arguments \
|
|
117
|
+
'--list[List journals]' \
|
|
118
|
+
'--journal[Journal name]:journal:($journals)'
|
|
119
|
+
;;
|
|
120
|
+
help)
|
|
121
|
+
_describe -t topics 'topic' help_topics
|
|
122
|
+
;;
|
|
123
|
+
config)
|
|
124
|
+
_values 'setting' 'user[Set user name]'
|
|
125
|
+
;;
|
|
126
|
+
word-count|wc)
|
|
127
|
+
_arguments \
|
|
128
|
+
'--limit[Word limit]:number:' \
|
|
129
|
+
'--journal[Use journal word limit]:journal:'
|
|
130
|
+
;;
|
|
131
|
+
preview)
|
|
132
|
+
_describe -t formats 'format' preview_formats
|
|
133
|
+
;;
|
|
134
|
+
watch)
|
|
135
|
+
_arguments \
|
|
136
|
+
'--no-open[Do not open after build]'
|
|
137
|
+
_values 'format' 'pdf' 'docx' 'all'
|
|
138
|
+
;;
|
|
139
|
+
lint)
|
|
140
|
+
_arguments \
|
|
141
|
+
'--fix[Auto-fix issues]'
|
|
142
|
+
;;
|
|
143
|
+
grammar)
|
|
144
|
+
_arguments \
|
|
145
|
+
'--learn[Add word to dictionary]:word:' \
|
|
146
|
+
'--forget[Remove from dictionary]:word:' \
|
|
147
|
+
'--list[List dictionary words]' \
|
|
148
|
+
'--rules[List grammar rules]' \
|
|
149
|
+
'--no-scientific[Disable science rules]' \
|
|
150
|
+
'--severity[Minimum severity]:level:(error warning info)'
|
|
151
|
+
_files -g '*.md'
|
|
152
|
+
;;
|
|
153
|
+
annotate)
|
|
154
|
+
_arguments \
|
|
155
|
+
'-m[Comment message]:text:' \
|
|
156
|
+
'-s[Search text]:text:' \
|
|
157
|
+
'-a[Author name]:name:'
|
|
158
|
+
_files -g '*.docx'
|
|
159
|
+
;;
|
|
160
|
+
apply)
|
|
161
|
+
_arguments \
|
|
162
|
+
'-a[Author name]:name:'
|
|
163
|
+
_files -g '*.md'
|
|
164
|
+
;;
|
|
165
|
+
comment)
|
|
166
|
+
_arguments \
|
|
167
|
+
'-a[Author name]:name:'
|
|
168
|
+
_files -g '*.docx'
|
|
169
|
+
;;
|
|
170
|
+
completions)
|
|
171
|
+
_values 'shell' 'bash' 'zsh'
|
|
172
|
+
;;
|
|
173
|
+
import|sections|extract|review|status|comments|strip|refs|migrate|figures|response|anonymize|split|search|stats)
|
|
174
|
+
_files -g '*.md' -g '*.docx'
|
|
175
|
+
;;
|
|
176
|
+
resolve|reply)
|
|
177
|
+
_arguments \
|
|
178
|
+
'-n[Comment number]:number:' \
|
|
179
|
+
'-m[Reply message]:message:'
|
|
180
|
+
_files -g '*.md'
|
|
181
|
+
;;
|
|
182
|
+
check|lookup|add|citations)
|
|
183
|
+
_files -g '*.bib'
|
|
184
|
+
;;
|
|
185
|
+
merge)
|
|
186
|
+
_files -g '*.md' -g '*.docx'
|
|
187
|
+
;;
|
|
188
|
+
backup)
|
|
189
|
+
_arguments \
|
|
190
|
+
'--name[Custom backup name]:name:' \
|
|
191
|
+
'--output[Output directory]:dir:_files -/'
|
|
192
|
+
;;
|
|
193
|
+
export)
|
|
194
|
+
_arguments \
|
|
195
|
+
'--output[Output filename]:file:' \
|
|
196
|
+
'--include-output[Include built files]'
|
|
197
|
+
;;
|
|
198
|
+
*)
|
|
199
|
+
_describe -t commands 'command' commands
|
|
200
|
+
_arguments \
|
|
201
|
+
'--help[Show help]' \
|
|
202
|
+
'--version[Show version]'
|
|
203
|
+
;;
|
|
204
|
+
esac
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
_rev "$@"
|
package/dist/lib/build.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - Runs pandoc with crossref filter
|
|
9
9
|
*/
|
|
10
10
|
import type { Author, JournalFormatting } from './types.js';
|
|
11
|
+
import { type MacroDef } from './macros.js';
|
|
11
12
|
export interface CrossrefConfig {
|
|
12
13
|
figureTitle?: string;
|
|
13
14
|
tableTitle?: string;
|
|
@@ -111,6 +112,13 @@ export interface BuildConfig {
|
|
|
111
112
|
pptx: PptxConfig;
|
|
112
113
|
tables: TablesConfig;
|
|
113
114
|
postprocess: PostprocessConfig;
|
|
115
|
+
/**
|
|
116
|
+
* User-declared placeholder macros. Merged with the built-in macros
|
|
117
|
+
* (currently \tofill). Each entry overrides a built-in by name.
|
|
118
|
+
*
|
|
119
|
+
* See lib/macros.ts for the per-format rendering rules.
|
|
120
|
+
*/
|
|
121
|
+
macros?: MacroDef[];
|
|
114
122
|
/**
|
|
115
123
|
* Directory (relative to the project) where final outputs land. Created on
|
|
116
124
|
* demand. Set to null/empty to keep outputs alongside paper.md (legacy
|
package/dist/lib/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../lib/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../lib/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EACL,KAAK,QAAQ,EAKd,MAAM,aAAa,CAAC;AAqBrB,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,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GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAI/E;AAWD,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAalD;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACtD,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,YAAY,CAAC,CAgNvB;AAED;;GAEG;AACH,wBAAsB,KAAK,CACzB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAM,EAAoB,EACnC,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,eAAe,CAAC,CAsE1B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAYjE"}
|
package/dist/lib/build.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import * as fs from 'fs';
|
|
11
11
|
import * as path from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
12
13
|
import { spawn } from 'child_process';
|
|
13
14
|
import YAML from 'yaml';
|
|
14
15
|
import { stripAnnotations } from './annotations.js';
|
|
@@ -22,6 +23,7 @@ import { hasPandoc, hasPandocCrossref, hasLatex } from './dependencies.js';
|
|
|
22
23
|
import { buildImageRegistry, writeImageRegistry } from './image-registry.js';
|
|
23
24
|
import { getJournalProfile } from './journals.js';
|
|
24
25
|
import { resolveCSL } from './csl.js';
|
|
26
|
+
import { mergeMacros, generateLatexPreamble, writeMacrosSidecar, getMacroFilterPath, } from './macros.js';
|
|
25
27
|
// =============================================================================
|
|
26
28
|
// Constants
|
|
27
29
|
// =============================================================================
|
|
@@ -100,6 +102,9 @@ export const DEFAULT_CONFIG = {
|
|
|
100
102
|
beamer: null,
|
|
101
103
|
all: null, // Runs after any format
|
|
102
104
|
},
|
|
105
|
+
// Placeholder/highlight macros. Defaults are the built-ins from
|
|
106
|
+
// lib/macros.ts; users append their own here.
|
|
107
|
+
macros: [],
|
|
103
108
|
// Final outputs land here (created on demand). Set to null or '' to keep
|
|
104
109
|
// outputs in the project root.
|
|
105
110
|
outputDir: 'output',
|
|
@@ -963,10 +968,10 @@ export function buildPandocArgs(format, config, outputPath) {
|
|
|
963
968
|
}
|
|
964
969
|
// Fit images within slide bounds (default: true)
|
|
965
970
|
if (beamer.fit_images !== false) {
|
|
966
|
-
const fitImagesHeader = `\\makeatletter
|
|
967
|
-
\\def\\maxwidth{\\ifdim\\Gin@nat@width>\\linewidth\\linewidth\\else\\Gin@nat@width\\fi}
|
|
968
|
-
\\def\\maxheight{\\ifdim\\Gin@nat@height>0.75\\textheight 0.75\\textheight\\else\\Gin@nat@height\\fi}
|
|
969
|
-
\\makeatother
|
|
971
|
+
const fitImagesHeader = `\\makeatletter
|
|
972
|
+
\\def\\maxwidth{\\ifdim\\Gin@nat@width>\\linewidth\\linewidth\\else\\Gin@nat@width\\fi}
|
|
973
|
+
\\def\\maxheight{\\ifdim\\Gin@nat@height>0.75\\textheight 0.75\\textheight\\else\\Gin@nat@height\\fi}
|
|
974
|
+
\\makeatother
|
|
970
975
|
\\setkeys{Gin}{width=\\maxwidth,height=\\maxheight,keepaspectratio}`;
|
|
971
976
|
args.push('-V', `header-includes=${fitImagesHeader}`);
|
|
972
977
|
}
|
|
@@ -1164,12 +1169,46 @@ export async function runPandoc(inputPath, format, config, options = {}) {
|
|
|
1164
1169
|
if (referenceDoc) {
|
|
1165
1170
|
args.push('--reference-doc', referenceDoc);
|
|
1166
1171
|
}
|
|
1167
|
-
// Add color filter for PPTX (handles [text]{color=#RRGGBB} syntax)
|
|
1168
|
-
|
|
1172
|
+
// Add color filter for PPTX (handles [text]{color=#RRGGBB} syntax).
|
|
1173
|
+
// fileURLToPath handles Windows paths with spaces — the old
|
|
1174
|
+
// `new URL(...).pathname` returned URL-encoded `%20` and fs.existsSync
|
|
1175
|
+
// silently failed.
|
|
1176
|
+
const colorFilterPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pptx-color-filter.lua');
|
|
1169
1177
|
if (fs.existsSync(colorFilterPath)) {
|
|
1170
1178
|
args.push('--lua-filter', colorFilterPath);
|
|
1171
1179
|
}
|
|
1172
1180
|
}
|
|
1181
|
+
// Wire placeholder macros (built-in \tofill plus user-declared entries).
|
|
1182
|
+
// - docx/html: lua filter expands \name{X} to format-specific raw runs.
|
|
1183
|
+
// - pdf/tex/beamer: inject a \providecommand preamble so LaTeX renders it
|
|
1184
|
+
// directly. `\providecommand` is non-clobbering, so a user who already
|
|
1185
|
+
// has `\providecommand{\tofill}{...}` in their own header keeps theirs.
|
|
1186
|
+
//
|
|
1187
|
+
// Sidecar path is passed to the lua filter via DOCREV_MACROS_FILE in the
|
|
1188
|
+
// child env (not pandoc metadata) because pandoc walks RawInline/RawBlock
|
|
1189
|
+
// BEFORE Meta — by the time a Meta handler could read the path, the inline
|
|
1190
|
+
// expansion has already happened.
|
|
1191
|
+
const macroTempFiles = [];
|
|
1192
|
+
let macroEnvFile = null;
|
|
1193
|
+
const macros = mergeMacros(config.macros);
|
|
1194
|
+
if (macros.length > 0) {
|
|
1195
|
+
if (format === 'docx' || format === 'html' || format === 'html5' || format === 'html4') {
|
|
1196
|
+
const sidecarPath = writeMacrosSidecar(directory, macros);
|
|
1197
|
+
macroTempFiles.push(sidecarPath);
|
|
1198
|
+
macroEnvFile = sidecarPath;
|
|
1199
|
+
const filterPath = getMacroFilterPath();
|
|
1200
|
+
if (fs.existsSync(filterPath)) {
|
|
1201
|
+
args.push('--lua-filter', filterPath);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
else if (format === 'pdf' || format === 'tex' || format === 'beamer') {
|
|
1205
|
+
const preamble = generateLatexPreamble(macros);
|
|
1206
|
+
const preamblePath = path.join(directory, '.macros.tex');
|
|
1207
|
+
fs.writeFileSync(preamblePath, preamble, 'utf-8');
|
|
1208
|
+
macroTempFiles.push(preamblePath);
|
|
1209
|
+
args.push('-H', path.basename(preamblePath));
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1173
1212
|
// Add crossref metadata file if exists (skip for slides - they don't use crossref)
|
|
1174
1213
|
if (format !== 'beamer' && format !== 'pptx') {
|
|
1175
1214
|
const crossrefPath = path.join(directory, 'crossref.yaml');
|
|
@@ -1188,15 +1227,31 @@ export async function runPandoc(inputPath, format, config, options = {}) {
|
|
|
1188
1227
|
console.error(` pandoc ${quoted}`);
|
|
1189
1228
|
}
|
|
1190
1229
|
return new Promise((resolve) => {
|
|
1230
|
+
const pandocEnv = { ...process.env };
|
|
1231
|
+
if (macroEnvFile) {
|
|
1232
|
+
pandocEnv.DOCREV_MACROS_FILE = macroEnvFile;
|
|
1233
|
+
}
|
|
1191
1234
|
const pandoc = spawn('pandoc', args, {
|
|
1192
1235
|
cwd: directory,
|
|
1193
1236
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1237
|
+
env: pandocEnv,
|
|
1194
1238
|
});
|
|
1195
1239
|
let stderr = '';
|
|
1196
1240
|
pandoc.stderr?.on('data', (data) => {
|
|
1197
1241
|
stderr += data.toString();
|
|
1198
1242
|
});
|
|
1243
|
+
const cleanupMacroTempFiles = () => {
|
|
1244
|
+
for (const tmp of macroTempFiles) {
|
|
1245
|
+
try {
|
|
1246
|
+
fs.unlinkSync(tmp);
|
|
1247
|
+
}
|
|
1248
|
+
catch {
|
|
1249
|
+
// ignore — best-effort cleanup
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1199
1253
|
pandoc.on('close', async (code) => {
|
|
1254
|
+
cleanupMacroTempFiles();
|
|
1200
1255
|
if (code === 0) {
|
|
1201
1256
|
// For PPTX, post-process to add slide numbers, buildup colors, and logos
|
|
1202
1257
|
if (format === 'pptx') {
|
|
@@ -1247,6 +1302,7 @@ export async function runPandoc(inputPath, format, config, options = {}) {
|
|
|
1247
1302
|
}
|
|
1248
1303
|
});
|
|
1249
1304
|
pandoc.on('error', (err) => {
|
|
1305
|
+
cleanupMacroTempFiles();
|
|
1250
1306
|
resolve({ outputPath, success: false, error: err.message });
|
|
1251
1307
|
});
|
|
1252
1308
|
});
|