gutterpress 0.11.22 → 0.11.23-alpha.2
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/README.md +23 -24
- package/dist/{README-3nj919rm.md → README-8ef336pp.md} +1 -1
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +16 -22
- package/dist/{build-53bw14h7.js → build-encgnv0c.js} +9 -10
- package/dist/{chapter-01-rkpyvjna.md → chapter-01-gsbjt584.md} +1 -1
- package/dist/chapter-01-s71xrf5q.md +69 -0
- package/dist/{chapter-01-7jwqg1ct.md → chapter-01-wgjfz4w6.md} +1 -1
- package/dist/checks/source/character-table.d.ts +12 -6
- package/dist/{cli-habkc5ng.js → cli-a35w7wzg.js} +5 -4
- package/dist/{cli-kx4hbnx2.js → cli-aqh6brew.js} +1 -1
- package/dist/{cli-1hxxwbaq.js → cli-evg8sbht.js} +1 -1
- package/dist/{cli-cjftezxr.js → cli-kh8v4vvw.js} +2 -1
- package/dist/{cli-ntwqmdnw.js → cli-pwwfxdgb.js} +846 -13
- package/dist/{cli-8kg0wjdt.js → cli-pz4bn98t.js} +185 -9
- package/dist/{cli-zj5xaepv.js → cli-sdmv4bba.js} +57 -117
- package/dist/{cli-ke86zsz6.js → cli-xq6djqbj.js} +51 -54
- package/dist/{index-r7jcsk6h.js → cli-y28j019d.js} +19 -10
- package/dist/cli.js +12 -12
- package/dist/{doctor-xka1frnx.js → doctor-5gtpgpd1.js} +3 -3
- package/dist/{engine-p93f06gj.js → engine-mc5br8g8.js} +1 -2
- package/dist/{engine-0ndvy8vj.js → engine-tn13gk0b.js} +3 -3
- package/dist/{ext-dwfqyy1j.js → ext-wn2a5afq.js} +18 -33
- package/dist/{extension-restore-ct1wk344.js → extension-restore-g8jnmmzq.js} +5 -6
- package/dist/{extension-restore-7vp3vh77.js → extension-restore-s3x1618g.js} +4 -4
- package/dist/{index-apc8w9w8.js → index-0skhjx3e.js} +180 -1
- package/dist/{index-4v7e621e.js → index-2bjcghze.js} +847 -13
- package/dist/index-46ycxe6r.js +18 -0
- package/dist/{index-53nrm5j1.js → index-4x6y8krm.js} +2 -4
- package/dist/{cli-h3phdstf.js → index-5x42amh8.js} +19 -10
- package/dist/{index-93pqkvty.js → index-h6yk5tjx.js} +5 -4
- package/dist/{index-kh7fayjv.js → index-j5z86r4a.js} +57 -54
- package/dist/{index-6cmn2wpd.js → index-x3ema2w3.js} +69 -128
- package/dist/index.js +17 -23
- package/dist/lib/build-runner.d.ts +1 -1
- package/dist/lib/extension-manager.d.ts +16 -43
- package/dist/lib/extension-scaffold.d.ts +3 -3
- package/dist/lib/extension-specifier.d.ts +23 -6
- package/dist/lib/markdown/assemble.d.ts +7 -1
- package/dist/lib/markdown/gutterpress-css.d.ts +1 -1
- package/dist/lib/markdown/index.d.ts +4 -0
- package/dist/lib/markdown/math.d.ts +43 -0
- package/dist/lib/markdown/renderer.d.ts +11 -8
- package/dist/lib/markdown/table.d.ts +46 -0
- package/dist/lib/markdown/typography.d.ts +12 -0
- package/dist/lib/npm-plugin-installer.d.ts +1 -1
- package/dist/lib/plugin-vendor.d.ts +11 -3
- package/dist/lib/presets.d.ts +1 -1
- package/dist/lib/project-gitignore.d.ts +2 -2
- package/dist/lib/project-scaffold.d.ts +6 -8
- package/dist/lib/project-templates.d.ts +6 -1
- package/dist/lib/snippets.d.ts +2 -1
- package/dist/lib/style-resolver.d.ts +1 -2
- package/dist/manifest-eagfhba6.yaml +19 -0
- package/dist/{manifest.schema-399bx3vc.json → manifest.schema-t7nx2stg.json} +12 -5
- package/dist/{new-1pawj2qf.js → new-mhs46pw3.js} +22 -21
- package/dist/{plugins-fr4fnzhb.js → plugins-1sxe0dkz.js} +4 -4
- package/dist/{plugins-g4dgw7mn.js → plugins-2cek4mz1.js} +2 -2
- package/dist/{preflight-ept9q57t.js → preflight-3k2b1x8e.js} +9 -10
- package/dist/preview/file-watcher.d.ts +1 -0
- package/dist/{preview-fxpnjv7k.js → preview-6p9v6rht.js} +9 -10
- package/dist/{publish-zhqqsgmr.js → publish-qgsngy8s.js} +9 -10
- package/dist/render.js +470 -11
- package/dist/schema/manifest.types.d.ts +8 -0
- package/dist/{source-provider-qbfknhyy.js → source-provider-98k5deda.js} +2 -2
- package/dist/{source-provider-2r74a7wp.js → source-provider-knmcam50.js} +2 -2
- package/dist/{validate-t68gvckq.js → validate-0v7xw6wa.js} +9 -10
- package/package.json +2 -1
- package/dist/cli-1ngqzg8s.js +0 -196
- package/dist/index-vay3ff1f.js +0 -213
- package/dist/package-97gm31sg.json +0 -10
- package/dist/package-gag6ykwn.json +0 -10
- package/dist/package-nrhkwf2m.json +0 -10
- package/dist/theme-h5recz6c.css +0 -61
- package/dist/theme-j2bagrfx.css +0 -59
- package/dist/theme-nn6d53zy.css +0 -71
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PACKAGE_VERSION,
|
|
3
3
|
debug
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-aqh6brew.js";
|
|
5
5
|
import {
|
|
6
6
|
isExactNpmVersion,
|
|
7
7
|
isValidNpmPackageName,
|
|
8
8
|
packageResolutionTargets,
|
|
9
|
+
parseNpmPluginSpec,
|
|
9
10
|
resolvePackageEntry,
|
|
10
11
|
resolveVendoredPluginInstallRoot,
|
|
11
12
|
safePackageTarget,
|
|
12
13
|
vendoredNpmPluginPackageDir
|
|
13
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-y28j019d.js";
|
|
14
15
|
|
|
15
16
|
// src/lib/markdown/plugins.ts
|
|
16
17
|
import { existsSync as existsSync2, readFileSync, statSync, unlinkSync } from "node:fs";
|
|
@@ -19,6 +20,374 @@ import { isBuiltin } from "node:module";
|
|
|
19
20
|
import { resolve as resolve2, join, dirname, basename, extname, isAbsolute, relative, sep } from "node:path";
|
|
20
21
|
import { pathToFileURL } from "node:url";
|
|
21
22
|
|
|
23
|
+
// src/assets/themes/clean-book/theme.css
|
|
24
|
+
var theme_default = `/* =============================================================================
|
|
25
|
+
Clean Book — gutterpress built-in theme (theme.css)
|
|
26
|
+
A calm, classic long-form book look. Change the :root tokens from the book's own stylesheet.
|
|
27
|
+
============================================================================= */
|
|
28
|
+
|
|
29
|
+
:root {
|
|
30
|
+
--color-ink: #1a1a1a; /* body text */
|
|
31
|
+
--color-ink-muted: #555555; /* captions, secondary text */
|
|
32
|
+
--color-accent: #2b4c7e; /* headings, links */
|
|
33
|
+
--color-paper: #ffffff; /* page background */
|
|
34
|
+
--color-rule: #d9d9d9; /* borders, rules */
|
|
35
|
+
|
|
36
|
+
--font-body: "Georgia", "Times New Roman", serif;
|
|
37
|
+
--font-display: "Georgia", "Times New Roman", serif;
|
|
38
|
+
--font-mono: "Menlo", "Consolas", monospace;
|
|
39
|
+
|
|
40
|
+
--fs-body: 11pt;
|
|
41
|
+
--fs-h1: 2.1rem;
|
|
42
|
+
--fs-h2: 1.5rem;
|
|
43
|
+
--fs-h3: 1.2rem;
|
|
44
|
+
--leading: 1.55;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@page {
|
|
48
|
+
size: 6in 9in;
|
|
49
|
+
margin: 0.85in 0.75in;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
body {
|
|
53
|
+
color: var(--color-ink);
|
|
54
|
+
background: var(--color-paper);
|
|
55
|
+
font-family: var(--font-body);
|
|
56
|
+
line-height: var(--leading);
|
|
57
|
+
font-size: var(--fs-body);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
h1, h2, h3 {
|
|
61
|
+
font-family: var(--font-display);
|
|
62
|
+
color: var(--color-accent);
|
|
63
|
+
line-height: 1.2;
|
|
64
|
+
font-weight: 600;
|
|
65
|
+
}
|
|
66
|
+
h1 { font-size: var(--fs-h1); margin: 0 0 0.6em; }
|
|
67
|
+
h2 { font-size: var(--fs-h2); margin: 1.4em 0 0.4em; }
|
|
68
|
+
h3 { font-size: var(--fs-h3); margin: 1.2em 0 0.3em; }
|
|
69
|
+
|
|
70
|
+
p { margin: 0 0 0.8em; text-align: justify; hyphens: auto; }
|
|
71
|
+
|
|
72
|
+
a { color: var(--color-accent); text-decoration: none; }
|
|
73
|
+
|
|
74
|
+
blockquote {
|
|
75
|
+
margin: 1em 0; padding: 0.2em 0 0.2em 1em;
|
|
76
|
+
border-left: 3px solid var(--color-rule);
|
|
77
|
+
color: var(--color-ink-muted); font-style: italic;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
code, pre { font-family: var(--font-mono); font-size: 0.9em; }
|
|
81
|
+
|
|
82
|
+
hr { border: 0; border-top: 1px solid var(--color-rule); margin: 1.5em 0; }
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
// src/assets/themes/zine/theme.css
|
|
86
|
+
var theme_default2 = `/* =============================================================================
|
|
87
|
+
Zine — gutterpress built-in theme (theme.css)
|
|
88
|
+
High-contrast, punchy, photocopier-friendly. Change the :root tokens from the book's own stylesheet.
|
|
89
|
+
============================================================================= */
|
|
90
|
+
|
|
91
|
+
:root {
|
|
92
|
+
--color-ink: #000000; /* body text */
|
|
93
|
+
--color-ink-muted: #333333; /* secondary text */
|
|
94
|
+
--color-accent: #000000; /* headings (mono, high ink) */
|
|
95
|
+
--color-paper: #ffffff; /* page background */
|
|
96
|
+
--color-rule: #000000; /* heavy borders, rules */
|
|
97
|
+
|
|
98
|
+
--font-body: "Helvetica Neue", "Arial", sans-serif;
|
|
99
|
+
--font-display: "Impact", "Haettenschweiler", "Arial Black", sans-serif;
|
|
100
|
+
--font-mono: "Courier New", monospace;
|
|
101
|
+
|
|
102
|
+
--fs-body: 10pt;
|
|
103
|
+
--fs-h1: 2.8rem;
|
|
104
|
+
--fs-h2: 1.8rem;
|
|
105
|
+
--fs-h3: 1.3rem;
|
|
106
|
+
--leading: 1.4;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@page {
|
|
110
|
+
size: 5.5in 8.5in;
|
|
111
|
+
margin: 0.4in;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
body {
|
|
115
|
+
color: var(--color-ink);
|
|
116
|
+
background: var(--color-paper);
|
|
117
|
+
font-family: var(--font-body);
|
|
118
|
+
line-height: var(--leading);
|
|
119
|
+
font-size: var(--fs-body);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
h1, h2, h3 {
|
|
123
|
+
font-family: var(--font-display);
|
|
124
|
+
color: var(--color-accent);
|
|
125
|
+
text-transform: uppercase;
|
|
126
|
+
letter-spacing: -0.01em;
|
|
127
|
+
line-height: 0.95;
|
|
128
|
+
font-weight: 900;
|
|
129
|
+
}
|
|
130
|
+
h1 { font-size: var(--fs-h1); margin: 0 0 0.4em; }
|
|
131
|
+
h2 { font-size: var(--fs-h2); margin: 1.1em 0 0.3em; }
|
|
132
|
+
h3 { font-size: var(--fs-h3); margin: 1em 0 0.25em; }
|
|
133
|
+
|
|
134
|
+
p { margin: 0 0 0.6em; }
|
|
135
|
+
|
|
136
|
+
a { color: var(--color-accent); text-decoration: underline; font-weight: 700; }
|
|
137
|
+
|
|
138
|
+
blockquote {
|
|
139
|
+
margin: 1em 0; padding: 0.5em 0.8em;
|
|
140
|
+
border: 2px solid var(--color-rule);
|
|
141
|
+
font-weight: 700;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
hr { border: 0; border-top: 3px solid var(--color-rule); margin: 1em 0; }
|
|
145
|
+
|
|
146
|
+
code, pre { font-family: var(--font-mono); font-size: 0.95em; }
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
// src/assets/themes/technical-doc/theme.css
|
|
150
|
+
var theme_default3 = `/* =============================================================================
|
|
151
|
+
Technical Document — gutterpress built-in theme (theme.css)
|
|
152
|
+
Clean sans-serif manual look with clear hierarchy. Change the :root tokens from the book's own stylesheet.
|
|
153
|
+
============================================================================= */
|
|
154
|
+
|
|
155
|
+
:root {
|
|
156
|
+
--color-ink: #1c1e21; /* body text */
|
|
157
|
+
--color-ink-muted: #5a5f66; /* captions, secondary text */
|
|
158
|
+
--color-accent: #0b5fff; /* headings, links */
|
|
159
|
+
--color-paper: #ffffff; /* page background */
|
|
160
|
+
--color-tint: #f3f5f9; /* code / note fill */
|
|
161
|
+
--color-rule: #d6dae0; /* borders, rules */
|
|
162
|
+
|
|
163
|
+
--font-body: "Helvetica Neue", "Segoe UI", Arial, sans-serif;
|
|
164
|
+
--font-display: "Helvetica Neue", "Segoe UI", Arial, sans-serif;
|
|
165
|
+
--font-mono: "SFMono-Regular", "Consolas", "Menlo", monospace;
|
|
166
|
+
|
|
167
|
+
--fs-body: 10.5pt;
|
|
168
|
+
--fs-h1: 2.0rem;
|
|
169
|
+
--fs-h2: 1.45rem;
|
|
170
|
+
--fs-h3: 1.15rem;
|
|
171
|
+
--leading: 1.5;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@page {
|
|
175
|
+
size: 8.5in 11in;
|
|
176
|
+
margin: 0.9in 1in;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
body {
|
|
180
|
+
color: var(--color-ink);
|
|
181
|
+
background: var(--color-paper);
|
|
182
|
+
font-family: var(--font-body);
|
|
183
|
+
line-height: var(--leading);
|
|
184
|
+
font-size: var(--fs-body);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
h1, h2, h3 {
|
|
188
|
+
font-family: var(--font-display);
|
|
189
|
+
color: var(--color-ink);
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
line-height: 1.25;
|
|
192
|
+
}
|
|
193
|
+
h1 { font-size: var(--fs-h1); margin: 0 0 0.5em; color: var(--color-accent); }
|
|
194
|
+
h2 { font-size: var(--fs-h2); margin: 1.4em 0 0.4em; border-bottom: 1px solid var(--color-rule); padding-bottom: 0.15em; }
|
|
195
|
+
h3 { font-size: var(--fs-h3); margin: 1.2em 0 0.3em; }
|
|
196
|
+
|
|
197
|
+
p { margin: 0 0 0.7em; }
|
|
198
|
+
|
|
199
|
+
a { color: var(--color-accent); text-decoration: none; }
|
|
200
|
+
|
|
201
|
+
code {
|
|
202
|
+
font-family: var(--font-mono); font-size: 0.88em;
|
|
203
|
+
background: var(--color-tint); padding: 0.1em 0.35em; border-radius: 3px;
|
|
204
|
+
}
|
|
205
|
+
pre {
|
|
206
|
+
font-family: var(--font-mono); font-size: 0.85em;
|
|
207
|
+
background: var(--color-tint); border: 1px solid var(--color-rule);
|
|
208
|
+
border-radius: 4px; padding: 0.7em 0.9em; overflow: auto;
|
|
209
|
+
}
|
|
210
|
+
pre code { background: none; padding: 0; }
|
|
211
|
+
|
|
212
|
+
table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.95em; }
|
|
213
|
+
th, td { border: 1px solid var(--color-rule); padding: 0.4em 0.6em; text-align: left; }
|
|
214
|
+
th { background: var(--color-tint); font-weight: 600; }
|
|
215
|
+
|
|
216
|
+
blockquote {
|
|
217
|
+
margin: 1em 0; padding: 0.5em 0.9em;
|
|
218
|
+
background: var(--color-tint); border-left: 3px solid var(--color-accent);
|
|
219
|
+
color: var(--color-ink-muted);
|
|
220
|
+
}
|
|
221
|
+
`;
|
|
222
|
+
|
|
223
|
+
// src/assets/themes/academic/theme.css
|
|
224
|
+
var theme_default4 = `/* =============================================================================
|
|
225
|
+
Academic — gutterpress built-in theme (theme.css)
|
|
226
|
+
A journal-article look in the spirit of LaTeX's \`article\` class: a serif
|
|
227
|
+
text face, justified and hyphenated text, 1in margins, a centred page
|
|
228
|
+
number, and the parts of a paper styled by the @section they sit in.
|
|
229
|
+
Change the :root tokens from the book's own stylesheet. The page SIZE comes from the manifest
|
|
230
|
+
(\`page:\` — US Letter or A4), so it is deliberately not set here.
|
|
231
|
+
============================================================================= */
|
|
232
|
+
|
|
233
|
+
:root {
|
|
234
|
+
--color-ink: #111111; /* body text */
|
|
235
|
+
--color-ink-muted: #555555; /* captions, secondary text */
|
|
236
|
+
--color-accent: #111111; /* headings, links */
|
|
237
|
+
--color-paper: #ffffff; /* page background */
|
|
238
|
+
--color-rule: #111111; /* table rules */
|
|
239
|
+
|
|
240
|
+
--font-body: "Latin Modern Roman", "CMU Serif", "STIX Two Text", "Times New Roman", "Liberation Serif", serif;
|
|
241
|
+
--font-display: "Latin Modern Roman", "CMU Serif", "STIX Two Text", "Times New Roman", "Liberation Serif", serif;
|
|
242
|
+
--font-mono: "Latin Modern Mono", "Menlo", "Consolas", monospace;
|
|
243
|
+
|
|
244
|
+
--fs-body: 10.5pt;
|
|
245
|
+
--fs-h1: 1.65em;
|
|
246
|
+
--fs-h2: 1.2em;
|
|
247
|
+
--fs-h3: 1em;
|
|
248
|
+
--leading: 1.38;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@page {
|
|
252
|
+
margin: 1in;
|
|
253
|
+
@bottom-center { content: counter(page); font-family: var(--font-body); font-size: 9pt; }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
body {
|
|
257
|
+
color: var(--color-ink);
|
|
258
|
+
background: var(--color-paper);
|
|
259
|
+
font-family: var(--font-body);
|
|
260
|
+
line-height: var(--leading);
|
|
261
|
+
font-size: var(--fs-body);
|
|
262
|
+
text-align: justify;
|
|
263
|
+
hyphens: auto;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
h1, h2, h3 {
|
|
267
|
+
font-family: var(--font-display);
|
|
268
|
+
color: var(--color-accent);
|
|
269
|
+
line-height: 1.2;
|
|
270
|
+
font-weight: bold;
|
|
271
|
+
}
|
|
272
|
+
h1 { font-size: var(--fs-h1); margin: 0 0 0.7em; }
|
|
273
|
+
h2 { font-size: var(--fs-h2); margin: 1.4em 0 0.5em; }
|
|
274
|
+
h3 { font-size: var(--fs-h3); margin: 1.2em 0 0.4em; }
|
|
275
|
+
|
|
276
|
+
a { color: var(--color-accent); text-decoration: none; }
|
|
277
|
+
|
|
278
|
+
code, pre { font-family: var(--font-mono); }
|
|
279
|
+
pre { font-size: 0.8em; line-height: 1.3; }
|
|
280
|
+
|
|
281
|
+
/* @section .title — the title, authors, affiliations and date */
|
|
282
|
+
.title { text-align: center; hyphens: manual; margin-bottom: 2em; }
|
|
283
|
+
|
|
284
|
+
/* @section .abstract — the abstract, keywords and subject classes */
|
|
285
|
+
.abstract { font-size: 0.9em; margin: 0 2.5em 2em; }
|
|
286
|
+
|
|
287
|
+
/* @section .figure — a figure, table or listing kept on one page with its caption */
|
|
288
|
+
.figure { break-inside: avoid; margin: 1.4em 0; }
|
|
289
|
+
.caption { font-size: 0.9em; color: var(--color-ink-muted); }
|
|
290
|
+
|
|
291
|
+
/* Tables ruled above, below and under the header row, as journals set them */
|
|
292
|
+
table { border-collapse: collapse; margin: 0.6em auto; border-top: 1pt solid var(--color-rule); border-bottom: 1pt solid var(--color-rule); }
|
|
293
|
+
thead th { border-bottom: 0.5pt solid var(--color-rule); }
|
|
294
|
+
th, td { padding: 0.2em 0.8em; }
|
|
295
|
+
|
|
296
|
+
/* Notes (from [^1] footnotes) and @section .references, a size smaller than the text */
|
|
297
|
+
.footnotes, .references { font-size: 0.85em; }
|
|
298
|
+
.footnotes-sep { border: 0; border-top: 0.5pt solid var(--color-rule); width: 30%; margin: 1.5em 0 0.5em; }
|
|
299
|
+
.footnote-backref { display: none; }
|
|
300
|
+
`;
|
|
301
|
+
|
|
302
|
+
// src/lib/extension-specifier.ts
|
|
303
|
+
var BUNDLED_EXTENSIONS = [
|
|
304
|
+
{
|
|
305
|
+
name: "markdown-it-mark",
|
|
306
|
+
label: "Highlight",
|
|
307
|
+
description: "Highlight text by wrapping it in `==double equals==`."
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "markdown-it-sub",
|
|
311
|
+
label: "Subscript",
|
|
312
|
+
description: "Lower text below the line, like the 2 in `H~2~O`."
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: "markdown-it-sup",
|
|
316
|
+
label: "Superscript",
|
|
317
|
+
description: "Raise text above the line, like the th in `29^th^`."
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "markdown-it-abbr",
|
|
321
|
+
label: "Abbreviations",
|
|
322
|
+
description: "Explain an abbreviation when readers hover over it. Define it once, like `*[GPS]: Global Positioning System`."
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "gutterpress-gfm-alerts",
|
|
326
|
+
label: "Callouts",
|
|
327
|
+
description: "Turn a quote into a boxed note: start it with `> [!NOTE]` (or `TIP`, `IMPORTANT`, `WARNING`, `CAUTION`)."
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: "gutterpress-math",
|
|
331
|
+
label: "Math",
|
|
332
|
+
description: "Write LaTeX math between dollar signs: `$E = mc^2$` in a line, or `$$` … `$$` on lines of their own."
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "clean-book",
|
|
336
|
+
label: "Clean book",
|
|
337
|
+
description: "A calm, classic book look: serif body, generous margins, restrained accents.",
|
|
338
|
+
css: theme_default
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "zine",
|
|
342
|
+
label: "Zine",
|
|
343
|
+
description: "High-contrast, punchy sans-serif look for short photocopier-friendly zines.",
|
|
344
|
+
css: theme_default2
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "technical-doc",
|
|
348
|
+
label: "Technical doc",
|
|
349
|
+
description: "Clean sans-serif manual look with clear hierarchy, code styling, and tidy tables.",
|
|
350
|
+
css: theme_default3
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "academic",
|
|
354
|
+
label: "Academic",
|
|
355
|
+
description: "A journal-article look: serif text, justified and hyphenated, ruled tables, notes and references set smaller.",
|
|
356
|
+
css: theme_default4
|
|
357
|
+
}
|
|
358
|
+
];
|
|
359
|
+
function bundledExtension(name) {
|
|
360
|
+
return BUNDLED_EXTENSIONS.find((e) => e.name === name);
|
|
361
|
+
}
|
|
362
|
+
function isBundledExtension(name) {
|
|
363
|
+
return bundledExtension(name) !== undefined;
|
|
364
|
+
}
|
|
365
|
+
function isPathSpecifier(use) {
|
|
366
|
+
return use.startsWith("./") || use.startsWith("../") || use.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(use);
|
|
367
|
+
}
|
|
368
|
+
function parseExtensionSpecifier(use) {
|
|
369
|
+
const spec = use.trim();
|
|
370
|
+
if (!spec) {
|
|
371
|
+
throw new Error("An extension specifier is required — an npm package name, or a ./ path.");
|
|
372
|
+
}
|
|
373
|
+
if (isPathSpecifier(spec))
|
|
374
|
+
return { kind: "path", path: spec };
|
|
375
|
+
if (/\.(m?js|cjs)$/i.test(spec) || !spec.startsWith("@") && spec.includes("/")) {
|
|
376
|
+
throw new Error(`"${spec}" looks like a path; write it as "./${spec}". A specifier that does not ` + "start with ./, ../ or / is an npm package name.");
|
|
377
|
+
}
|
|
378
|
+
const parsed = parseNpmPluginSpec(spec);
|
|
379
|
+
if (isBundledExtension(parsed.name)) {
|
|
380
|
+
if (parsed.selector !== undefined) {
|
|
381
|
+
throw new Error(`"${parsed.name}" is bundled with Gutterpress and always resolves to the bundled copy — ` + `drop "@${parsed.selector}".`);
|
|
382
|
+
}
|
|
383
|
+
return { kind: "bundled", name: parsed.name };
|
|
384
|
+
}
|
|
385
|
+
return parsed.selector === undefined ? { kind: "npm", name: parsed.name } : { kind: "npm", name: parsed.name, version: parsed.selector };
|
|
386
|
+
}
|
|
387
|
+
function pinnedNpmSpecifier(name, version) {
|
|
388
|
+
return `${name}@${version}`;
|
|
389
|
+
}
|
|
390
|
+
|
|
22
391
|
// src/lib/style-declarations.ts
|
|
23
392
|
import { existsSync } from "node:fs";
|
|
24
393
|
import { resolve } from "node:path";
|
|
@@ -1589,6 +1958,38 @@ img.gp-shape {
|
|
|
1589
1958
|
:where(.gp-alert-important) { --gp-alert-color: var(--gp-alert-important-color); }
|
|
1590
1959
|
:where(.gp-alert-warning) { --gp-alert-color: var(--gp-alert-warning-color); }
|
|
1591
1960
|
:where(.gp-alert-caution) { --gp-alert-color: var(--gp-alert-caution-color); }
|
|
1961
|
+
|
|
1962
|
+
/* Math (the bundled gutterpress-math feature, math.ts): MathJax's own rules
|
|
1963
|
+
for the <mjx-container> SVG output it emits, from its SVG output jax's
|
|
1964
|
+
stylesheet, less the ones for its interactive menu and tooltips. Inert in
|
|
1965
|
+
a book without formulas. */
|
|
1966
|
+
mjx-container[jax="SVG"] { direction: ltr; }
|
|
1967
|
+
mjx-container[jax="SVG"] > svg { overflow: visible; min-height: 1px; min-width: 1px; }
|
|
1968
|
+
mjx-container[jax="SVG"] > svg a { fill: blue; stroke: blue; }
|
|
1969
|
+
mjx-container[jax="SVG"][display="true"] { display: block; text-align: center; margin: 1em 0; }
|
|
1970
|
+
mjx-container[jax="SVG"][display="true"][width="full"] { display: flex; }
|
|
1971
|
+
mjx-container[jax="SVG"][justify="left"] { text-align: left; }
|
|
1972
|
+
mjx-container[jax="SVG"][justify="right"] { text-align: right; }
|
|
1973
|
+
mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c] { stroke-width: 3; }
|
|
1974
|
+
mjx-assistive-mml {
|
|
1975
|
+
position: absolute !important;
|
|
1976
|
+
top: 0px; left: 0px;
|
|
1977
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
1978
|
+
padding: 1px 0px 0px 0px !important;
|
|
1979
|
+
border: 0px !important;
|
|
1980
|
+
display: block !important;
|
|
1981
|
+
width: auto !important;
|
|
1982
|
+
overflow: hidden !important;
|
|
1983
|
+
user-select: none;
|
|
1984
|
+
}
|
|
1985
|
+
mjx-assistive-mml[display="block"] { width: 100% !important; }
|
|
1986
|
+
g[data-mml-node="merror"] > g { fill: red; stroke: red; }
|
|
1987
|
+
g[data-mml-node="merror"] > rect[data-background] { fill: yellow; stroke: none; }
|
|
1988
|
+
g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line] { stroke-width: 70px; fill: none; }
|
|
1989
|
+
g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame] { stroke-width: 70px; fill: none; }
|
|
1990
|
+
g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed { stroke-dasharray: 140; }
|
|
1991
|
+
g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted { stroke-linecap: round; stroke-dasharray: 0,140; }
|
|
1992
|
+
g[data-mml-node="mtable"] > g > svg { overflow: visible; }
|
|
1592
1993
|
`;
|
|
1593
1994
|
var GP_CLASSES = new Set([
|
|
1594
1995
|
"gp-left",
|
|
@@ -1903,6 +2304,224 @@ function gpBlockNames(md) {
|
|
|
1903
2304
|
md.core.ruler.push("gp_block_names", (state) => nameBlocksAndHeadings(state.tokens));
|
|
1904
2305
|
}
|
|
1905
2306
|
|
|
2307
|
+
// src/lib/markdown/table.ts
|
|
2308
|
+
import { isSpace } from "markdown-it/lib/common/utils.mjs";
|
|
2309
|
+
var scanCodeSpan = (src, start, max) => {
|
|
2310
|
+
let open = start;
|
|
2311
|
+
while (open < max && src.charCodeAt(open) === 96)
|
|
2312
|
+
open++;
|
|
2313
|
+
const length = open - start;
|
|
2314
|
+
let pos = open;
|
|
2315
|
+
while (pos < max) {
|
|
2316
|
+
if (src.charCodeAt(pos) !== 96) {
|
|
2317
|
+
pos++;
|
|
2318
|
+
continue;
|
|
2319
|
+
}
|
|
2320
|
+
let run = pos;
|
|
2321
|
+
while (run < max && src.charCodeAt(run) === 96)
|
|
2322
|
+
run++;
|
|
2323
|
+
if (run - pos === length)
|
|
2324
|
+
return run;
|
|
2325
|
+
pos = run;
|
|
2326
|
+
}
|
|
2327
|
+
return open;
|
|
2328
|
+
};
|
|
2329
|
+
var DEFAULT_SPANS = { 96: scanCodeSpan };
|
|
2330
|
+
function splitCells(str2, spans) {
|
|
2331
|
+
const result = [];
|
|
2332
|
+
const max = str2.length;
|
|
2333
|
+
let pos = 0;
|
|
2334
|
+
let lastPos = 0;
|
|
2335
|
+
let current = "";
|
|
2336
|
+
let isEscaped = false;
|
|
2337
|
+
while (pos < max) {
|
|
2338
|
+
const ch = str2.charCodeAt(pos);
|
|
2339
|
+
if (ch === 124) {
|
|
2340
|
+
if (!isEscaped) {
|
|
2341
|
+
result.push(current + str2.substring(lastPos, pos));
|
|
2342
|
+
current = "";
|
|
2343
|
+
lastPos = pos + 1;
|
|
2344
|
+
} else {
|
|
2345
|
+
current += str2.substring(lastPos, pos - 1);
|
|
2346
|
+
lastPos = pos;
|
|
2347
|
+
}
|
|
2348
|
+
} else if (!isEscaped && spans[ch]) {
|
|
2349
|
+
pos = spans[ch](str2, pos, max);
|
|
2350
|
+
continue;
|
|
2351
|
+
}
|
|
2352
|
+
isEscaped = ch === 92;
|
|
2353
|
+
pos++;
|
|
2354
|
+
}
|
|
2355
|
+
result.push(current + str2.substring(lastPos));
|
|
2356
|
+
return result;
|
|
2357
|
+
}
|
|
2358
|
+
function getLine(state, line) {
|
|
2359
|
+
const pos = state.bMarks[line] + state.tShift[line];
|
|
2360
|
+
const max = state.eMarks[line];
|
|
2361
|
+
return state.src.slice(pos, max);
|
|
2362
|
+
}
|
|
2363
|
+
var MAX_AUTOCOMPLETED_CELLS = 65536;
|
|
2364
|
+
function warnExtraCells(env, line, cells, columns) {
|
|
2365
|
+
if (!env.layoutWarnings)
|
|
2366
|
+
env.layoutWarnings = [];
|
|
2367
|
+
const extra = cells - columns;
|
|
2368
|
+
env.layoutWarnings.push({
|
|
2369
|
+
line: line + 1,
|
|
2370
|
+
type: "table_extra_cells",
|
|
2371
|
+
message: `This row has ${cells} cells but the table has ${columns} columns, so its last ` + `${extra === 1 ? "cell is" : `${extra} cells are`} left out. ` + "A | inside a cell splits it: write \\| for a literal one."
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
function tableRule(spans) {
|
|
2375
|
+
return function table(state, startLine, endLine, silent) {
|
|
2376
|
+
if (startLine + 2 > endLine)
|
|
2377
|
+
return false;
|
|
2378
|
+
let nextLine = startLine + 1;
|
|
2379
|
+
if (state.sCount[nextLine] < state.blkIndent)
|
|
2380
|
+
return false;
|
|
2381
|
+
if (state.sCount[nextLine] - state.blkIndent >= 4)
|
|
2382
|
+
return false;
|
|
2383
|
+
let pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
2384
|
+
if (pos >= state.eMarks[nextLine])
|
|
2385
|
+
return false;
|
|
2386
|
+
const firstCh = state.src.charCodeAt(pos++);
|
|
2387
|
+
if (firstCh !== 124 && firstCh !== 45 && firstCh !== 58)
|
|
2388
|
+
return false;
|
|
2389
|
+
if (pos >= state.eMarks[nextLine])
|
|
2390
|
+
return false;
|
|
2391
|
+
const secondCh = state.src.charCodeAt(pos++);
|
|
2392
|
+
if (secondCh !== 124 && secondCh !== 45 && secondCh !== 58 && !isSpace(secondCh)) {
|
|
2393
|
+
return false;
|
|
2394
|
+
}
|
|
2395
|
+
if (firstCh === 45 && isSpace(secondCh))
|
|
2396
|
+
return false;
|
|
2397
|
+
while (pos < state.eMarks[nextLine]) {
|
|
2398
|
+
const ch = state.src.charCodeAt(pos);
|
|
2399
|
+
if (ch !== 124 && ch !== 45 && ch !== 58 && !isSpace(ch))
|
|
2400
|
+
return false;
|
|
2401
|
+
pos++;
|
|
2402
|
+
}
|
|
2403
|
+
let lineText = getLine(state, startLine + 1);
|
|
2404
|
+
let columns = lineText.split("|");
|
|
2405
|
+
const aligns = [];
|
|
2406
|
+
for (let i = 0;i < columns.length; i++) {
|
|
2407
|
+
const t = columns[i].trim();
|
|
2408
|
+
if (!t) {
|
|
2409
|
+
if (i === 0 || i === columns.length - 1) {
|
|
2410
|
+
continue;
|
|
2411
|
+
} else {
|
|
2412
|
+
return false;
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
if (!/^:?-+:?$/.test(t))
|
|
2416
|
+
return false;
|
|
2417
|
+
if (t.charCodeAt(t.length - 1) === 58) {
|
|
2418
|
+
aligns.push(t.charCodeAt(0) === 58 ? "center" : "right");
|
|
2419
|
+
} else if (t.charCodeAt(0) === 58) {
|
|
2420
|
+
aligns.push("left");
|
|
2421
|
+
} else {
|
|
2422
|
+
aligns.push("");
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
lineText = getLine(state, startLine).trim();
|
|
2426
|
+
if (lineText.indexOf("|") === -1)
|
|
2427
|
+
return false;
|
|
2428
|
+
if (state.sCount[startLine] - state.blkIndent >= 4)
|
|
2429
|
+
return false;
|
|
2430
|
+
columns = splitCells(lineText, spans);
|
|
2431
|
+
if (columns.length && columns[0] === "")
|
|
2432
|
+
columns.shift();
|
|
2433
|
+
if (columns.length && columns[columns.length - 1] === "")
|
|
2434
|
+
columns.pop();
|
|
2435
|
+
const columnCount = columns.length;
|
|
2436
|
+
if (columnCount === 0 || columnCount !== aligns.length)
|
|
2437
|
+
return false;
|
|
2438
|
+
if (silent)
|
|
2439
|
+
return true;
|
|
2440
|
+
const oldParentType = state.parentType;
|
|
2441
|
+
state.parentType = "table";
|
|
2442
|
+
const terminatorRules = state.md.block.ruler.getRules("blockquote");
|
|
2443
|
+
const token_to = state.push("table_open", "table", 1);
|
|
2444
|
+
const tableLines = [startLine, 0];
|
|
2445
|
+
token_to.map = tableLines;
|
|
2446
|
+
const token_tho = state.push("thead_open", "thead", 1);
|
|
2447
|
+
token_tho.map = [startLine, startLine + 1];
|
|
2448
|
+
const token_htro = state.push("tr_open", "tr", 1);
|
|
2449
|
+
token_htro.map = [startLine, startLine + 1];
|
|
2450
|
+
for (let i = 0;i < columns.length; i++) {
|
|
2451
|
+
const token_ho = state.push("th_open", "th", 1);
|
|
2452
|
+
if (aligns[i]) {
|
|
2453
|
+
token_ho.attrs = [["style", "text-align:" + aligns[i]]];
|
|
2454
|
+
}
|
|
2455
|
+
const token_il = state.push("inline", "", 0);
|
|
2456
|
+
token_il.content = columns[i].trim();
|
|
2457
|
+
token_il.children = [];
|
|
2458
|
+
state.push("th_close", "th", -1);
|
|
2459
|
+
}
|
|
2460
|
+
state.push("tr_close", "tr", -1);
|
|
2461
|
+
state.push("thead_close", "thead", -1);
|
|
2462
|
+
let tbodyLines;
|
|
2463
|
+
let autocompletedCells = 0;
|
|
2464
|
+
for (nextLine = startLine + 2;nextLine < endLine; nextLine++) {
|
|
2465
|
+
if (state.sCount[nextLine] < state.blkIndent)
|
|
2466
|
+
break;
|
|
2467
|
+
let terminate = false;
|
|
2468
|
+
for (let i = 0, l = terminatorRules.length;i < l; i++) {
|
|
2469
|
+
if (terminatorRules[i](state, nextLine, endLine, true)) {
|
|
2470
|
+
terminate = true;
|
|
2471
|
+
break;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
if (terminate)
|
|
2475
|
+
break;
|
|
2476
|
+
lineText = getLine(state, nextLine).trim();
|
|
2477
|
+
if (!lineText)
|
|
2478
|
+
break;
|
|
2479
|
+
if (state.sCount[nextLine] - state.blkIndent >= 4)
|
|
2480
|
+
break;
|
|
2481
|
+
columns = splitCells(lineText, spans);
|
|
2482
|
+
if (columns.length && columns[0] === "")
|
|
2483
|
+
columns.shift();
|
|
2484
|
+
if (columns.length && columns[columns.length - 1] === "")
|
|
2485
|
+
columns.pop();
|
|
2486
|
+
if (columns.length > columnCount) {
|
|
2487
|
+
warnExtraCells(state.env, nextLine, columns.length, columnCount);
|
|
2488
|
+
}
|
|
2489
|
+
autocompletedCells += columnCount - columns.length;
|
|
2490
|
+
if (autocompletedCells > MAX_AUTOCOMPLETED_CELLS)
|
|
2491
|
+
break;
|
|
2492
|
+
if (nextLine === startLine + 2) {
|
|
2493
|
+
const token_tbo = state.push("tbody_open", "tbody", 1);
|
|
2494
|
+
token_tbo.map = tbodyLines = [startLine + 2, 0];
|
|
2495
|
+
}
|
|
2496
|
+
const token_tro = state.push("tr_open", "tr", 1);
|
|
2497
|
+
token_tro.map = [nextLine, nextLine + 1];
|
|
2498
|
+
for (let i = 0;i < columnCount; i++) {
|
|
2499
|
+
const token_tdo = state.push("td_open", "td", 1);
|
|
2500
|
+
if (aligns[i]) {
|
|
2501
|
+
token_tdo.attrs = [["style", "text-align:" + aligns[i]]];
|
|
2502
|
+
}
|
|
2503
|
+
const token_il = state.push("inline", "", 0);
|
|
2504
|
+
token_il.content = columns[i] ? columns[i].trim() : "";
|
|
2505
|
+
token_il.children = [];
|
|
2506
|
+
state.push("td_close", "td", -1);
|
|
2507
|
+
}
|
|
2508
|
+
state.push("tr_close", "tr", -1);
|
|
2509
|
+
}
|
|
2510
|
+
if (tbodyLines) {
|
|
2511
|
+
state.push("tbody_close", "tbody", -1);
|
|
2512
|
+
tbodyLines[1] = nextLine;
|
|
2513
|
+
}
|
|
2514
|
+
state.push("table_close", "table", -1);
|
|
2515
|
+
tableLines[1] = nextLine;
|
|
2516
|
+
state.parentType = oldParentType;
|
|
2517
|
+
state.line = nextLine;
|
|
2518
|
+
return true;
|
|
2519
|
+
};
|
|
2520
|
+
}
|
|
2521
|
+
function gpTable(md, options) {
|
|
2522
|
+
md.block.ruler.at("table", tableRule(options?.spans ?? DEFAULT_SPANS), { alt: ["paragraph", "reference"] });
|
|
2523
|
+
}
|
|
2524
|
+
|
|
1906
2525
|
// src/lib/markdown/table-align.ts
|
|
1907
2526
|
var ALIGN = /^text-align:(left|center|right)$/;
|
|
1908
2527
|
function gpTableAlign(md) {
|
|
@@ -1924,6 +2543,57 @@ th[data-align="center"], td[data-align="center"] { text-align: center; }
|
|
|
1924
2543
|
th[data-align="right"], td[data-align="right"] { text-align: right; }
|
|
1925
2544
|
`;
|
|
1926
2545
|
|
|
2546
|
+
// src/lib/markdown/typography.ts
|
|
2547
|
+
var EM_DASH = /(^|[^-])---(?=[^-]|$)/gm;
|
|
2548
|
+
var EN_DASH_SPACED = /(^|\s)--(?=\s|$)/gm;
|
|
2549
|
+
var EN_DASH = /(^|[^-\s])--(?=[^-\s]|$)/gm;
|
|
2550
|
+
var ELLIPSIS = /\.\.\./g;
|
|
2551
|
+
var CANDIDATE = /--|\.\.\./;
|
|
2552
|
+
function replaceInText(children) {
|
|
2553
|
+
let insideAutolink = 0;
|
|
2554
|
+
for (let i = children.length - 1;i >= 0; i--) {
|
|
2555
|
+
const token = children[i];
|
|
2556
|
+
if (token.type === "text" && !insideAutolink && CANDIDATE.test(token.content)) {
|
|
2557
|
+
token.content = token.content.replace(ELLIPSIS, "…").replace(EM_DASH, "$1—").replace(EN_DASH_SPACED, "$1–").replace(EN_DASH, "$1–");
|
|
2558
|
+
}
|
|
2559
|
+
if (token.type === "link_close" && token.info === "auto")
|
|
2560
|
+
insideAutolink++;
|
|
2561
|
+
if (token.type === "link_open" && token.info === "auto")
|
|
2562
|
+
insideAutolink--;
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
var QUOTES = {
|
|
2566
|
+
en: "“”‘’",
|
|
2567
|
+
de: "„“‚‘",
|
|
2568
|
+
"de-ch": "«»‹›",
|
|
2569
|
+
"de-li": "«»‹›",
|
|
2570
|
+
fr: ["« ", " »", "‹ ", " ›"],
|
|
2571
|
+
es: "«»“”",
|
|
2572
|
+
it: "«»“”",
|
|
2573
|
+
pt: "«»“”",
|
|
2574
|
+
"pt-br": "“”‘’",
|
|
2575
|
+
ru: "«»„“",
|
|
2576
|
+
pl: "„”«»",
|
|
2577
|
+
cs: "„“‚‘",
|
|
2578
|
+
sk: "„“‚‘",
|
|
2579
|
+
sv: "””’’",
|
|
2580
|
+
fi: "””’’"
|
|
2581
|
+
};
|
|
2582
|
+
function quotesFor(language) {
|
|
2583
|
+
const tag = (language ?? "en").toLowerCase();
|
|
2584
|
+
return QUOTES[tag] ?? QUOTES[tag.split("-")[0]] ?? QUOTES.en;
|
|
2585
|
+
}
|
|
2586
|
+
function gpTypography(md) {
|
|
2587
|
+
md.disable("replacements");
|
|
2588
|
+
md.core.ruler.after("linkify", "gp_typography", (state) => {
|
|
2589
|
+
for (const token of state.tokens) {
|
|
2590
|
+
if (token.type !== "inline" || !token.children || !CANDIDATE.test(token.content))
|
|
2591
|
+
continue;
|
|
2592
|
+
replaceInText(token.children);
|
|
2593
|
+
}
|
|
2594
|
+
});
|
|
2595
|
+
}
|
|
2596
|
+
|
|
1927
2597
|
// src/lib/two-versions-markers.ts
|
|
1928
2598
|
var YOUR_VERSION_LABEL = "your version";
|
|
1929
2599
|
var ONLINE_VERSION_LABEL = "online version";
|
|
@@ -2145,6 +2815,159 @@ function gfmAlerts(md) {
|
|
|
2145
2815
|
md.core.ruler.after("block", "gp_gfm_alerts", gfmAlertsRule);
|
|
2146
2816
|
}
|
|
2147
2817
|
|
|
2818
|
+
// src/lib/markdown/math.ts
|
|
2819
|
+
import { mathjax } from "mathjax-full/js/mathjax.js";
|
|
2820
|
+
import { TeX } from "mathjax-full/js/input/tex.js";
|
|
2821
|
+
import { SVG } from "mathjax-full/js/output/svg.js";
|
|
2822
|
+
import { liteAdaptor } from "mathjax-full/js/adaptors/liteAdaptor.js";
|
|
2823
|
+
import { RegisterHTMLHandler } from "mathjax-full/js/handlers/html.js";
|
|
2824
|
+
import { AssistiveMmlHandler } from "mathjax-full/js/a11y/assistive-mml.js";
|
|
2825
|
+
import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
|
|
2826
|
+
function findInlineMathEnd(src, start, max) {
|
|
2827
|
+
const after = src.charCodeAt(start + 1);
|
|
2828
|
+
if (after === 32 || after === 9)
|
|
2829
|
+
return -1;
|
|
2830
|
+
let match = start + 1;
|
|
2831
|
+
while ((match = src.indexOf("$", match)) !== -1 && match < max) {
|
|
2832
|
+
let pos = match - 1;
|
|
2833
|
+
while (src.charCodeAt(pos) === 92)
|
|
2834
|
+
pos--;
|
|
2835
|
+
if ((match - pos) % 2 === 1)
|
|
2836
|
+
break;
|
|
2837
|
+
match++;
|
|
2838
|
+
}
|
|
2839
|
+
if (match === -1 || match >= max)
|
|
2840
|
+
return -1;
|
|
2841
|
+
if (match === start + 1)
|
|
2842
|
+
return -2;
|
|
2843
|
+
const before = src.charCodeAt(match - 1);
|
|
2844
|
+
const next = src.charCodeAt(match + 1);
|
|
2845
|
+
if (before === 32 || before === 9 || next >= 48 && next <= 57)
|
|
2846
|
+
return -1;
|
|
2847
|
+
return match;
|
|
2848
|
+
}
|
|
2849
|
+
var scanInlineMath = (src, start, max) => {
|
|
2850
|
+
const end = findInlineMathEnd(src, start, max);
|
|
2851
|
+
return end >= 0 ? end + 1 : end === -2 ? start + 2 : start + 1;
|
|
2852
|
+
};
|
|
2853
|
+
function mathInline(state, silent) {
|
|
2854
|
+
if (state.src.charCodeAt(state.pos) !== 36)
|
|
2855
|
+
return false;
|
|
2856
|
+
const end = findInlineMathEnd(state.src, state.pos, state.posMax);
|
|
2857
|
+
if (end < 0) {
|
|
2858
|
+
const literal = end === -2 ? "$$" : "$";
|
|
2859
|
+
if (!silent)
|
|
2860
|
+
state.pending += literal;
|
|
2861
|
+
state.pos += literal.length;
|
|
2862
|
+
return true;
|
|
2863
|
+
}
|
|
2864
|
+
if (!silent) {
|
|
2865
|
+
const token = state.push("math_inline", "math", 0);
|
|
2866
|
+
token.markup = "$";
|
|
2867
|
+
token.content = state.src.slice(state.pos + 1, end);
|
|
2868
|
+
}
|
|
2869
|
+
state.pos = end + 1;
|
|
2870
|
+
return true;
|
|
2871
|
+
}
|
|
2872
|
+
function mathBlock(state, start, end, silent) {
|
|
2873
|
+
let pos = state.bMarks[start] + state.tShift[start];
|
|
2874
|
+
let max = state.eMarks[start];
|
|
2875
|
+
if (pos + 2 > max)
|
|
2876
|
+
return false;
|
|
2877
|
+
if (state.src.slice(pos, pos + 2) !== "$$")
|
|
2878
|
+
return false;
|
|
2879
|
+
pos += 2;
|
|
2880
|
+
let firstLine = state.src.slice(pos, max);
|
|
2881
|
+
if (silent)
|
|
2882
|
+
return true;
|
|
2883
|
+
let found = false;
|
|
2884
|
+
let lastLine = "";
|
|
2885
|
+
if (firstLine.trim().slice(-2) === "$$") {
|
|
2886
|
+
firstLine = firstLine.trim().slice(0, -2);
|
|
2887
|
+
found = true;
|
|
2888
|
+
}
|
|
2889
|
+
let next = start;
|
|
2890
|
+
while (!found) {
|
|
2891
|
+
next++;
|
|
2892
|
+
if (next >= end)
|
|
2893
|
+
break;
|
|
2894
|
+
pos = state.bMarks[next] + state.tShift[next];
|
|
2895
|
+
max = state.eMarks[next];
|
|
2896
|
+
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
2897
|
+
break;
|
|
2898
|
+
}
|
|
2899
|
+
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
2900
|
+
const lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
2901
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
2902
|
+
found = true;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
state.line = next + 1;
|
|
2906
|
+
const token = state.push("math_block", "math", 0);
|
|
2907
|
+
token.block = true;
|
|
2908
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + `
|
|
2909
|
+
` : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
2910
|
+
token.map = [start, state.line];
|
|
2911
|
+
token.markup = "$$";
|
|
2912
|
+
return true;
|
|
2913
|
+
}
|
|
2914
|
+
var adaptor = null;
|
|
2915
|
+
function getAdaptor() {
|
|
2916
|
+
if (!adaptor) {
|
|
2917
|
+
adaptor = liteAdaptor();
|
|
2918
|
+
AssistiveMmlHandler(RegisterHTMLHandler(adaptor));
|
|
2919
|
+
}
|
|
2920
|
+
return adaptor;
|
|
2921
|
+
}
|
|
2922
|
+
var PACKAGES = AllPackages.filter((name) => name !== "noerrors" && name !== "noundefined");
|
|
2923
|
+
function gpMath(md) {
|
|
2924
|
+
const html = getAdaptor();
|
|
2925
|
+
let errors = [];
|
|
2926
|
+
const tex = new TeX({
|
|
2927
|
+
packages: PACKAGES,
|
|
2928
|
+
formatError: (jax, err) => {
|
|
2929
|
+
errors.push(err.message);
|
|
2930
|
+
return jax.formatError(err);
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
const document = mathjax.document("", { InputJax: tex, OutputJax: new SVG({ fontCache: "none" }) });
|
|
2934
|
+
const typeset = (token, display, env) => {
|
|
2935
|
+
errors = [];
|
|
2936
|
+
const out = html.outerHTML(document.convert(token.content, { display }));
|
|
2937
|
+
for (const message of errors) {
|
|
2938
|
+
if (!env.layoutWarnings)
|
|
2939
|
+
env.layoutWarnings = [];
|
|
2940
|
+
env.layoutWarnings.push({
|
|
2941
|
+
line: token.meta?.line ?? (token.map?.[0] ?? 0) + 1,
|
|
2942
|
+
type: "math_error",
|
|
2943
|
+
message: `This formula could not be typeset: ${message}. It prints in red until it is fixed.`
|
|
2944
|
+
});
|
|
2945
|
+
}
|
|
2946
|
+
return display ? out + `
|
|
2947
|
+
` : out;
|
|
2948
|
+
};
|
|
2949
|
+
md.inline.ruler.after("escape", "math_inline", mathInline);
|
|
2950
|
+
md.block.ruler.after("blockquote", "math_block", mathBlock, {
|
|
2951
|
+
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
2952
|
+
});
|
|
2953
|
+
md.core.ruler.after("inline", "math_lines", (state) => {
|
|
2954
|
+
let line = 1;
|
|
2955
|
+
for (const token of state.tokens) {
|
|
2956
|
+
if (token.map)
|
|
2957
|
+
line = token.map[0] + 1;
|
|
2958
|
+
if (token.type !== "inline" || !token.children)
|
|
2959
|
+
continue;
|
|
2960
|
+
for (const child of token.children) {
|
|
2961
|
+
if (child.type === "math_inline")
|
|
2962
|
+
child.meta = { line };
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
});
|
|
2966
|
+
md.renderer.rules.math_inline = (tokens, idx, _options, env) => typeset(tokens[idx], false, env);
|
|
2967
|
+
md.renderer.rules.math_block = (tokens, idx, _options, env) => typeset(tokens[idx], true, env);
|
|
2968
|
+
md.use(gpTable, { spans: { ...DEFAULT_SPANS, 36: scanInlineMath } });
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2148
2971
|
// src/lib/markdown/images.ts
|
|
2149
2972
|
var isSrcsetSpace = (char) => char === "\t" || char === `
|
|
2150
2973
|
` || char === "\f" || char === "\r" || char === " ";
|
|
@@ -2571,14 +3394,17 @@ var BUILTIN_OPTIONAL_PLUGINS = {
|
|
|
2571
3394
|
"markdown-it-sub": unwrapPlugin(markdownItSub),
|
|
2572
3395
|
"markdown-it-sup": unwrapPlugin(markdownItSup),
|
|
2573
3396
|
"markdown-it-abbr": unwrapPlugin(markdownItAbbr),
|
|
2574
|
-
"gutterpress-gfm-alerts": gfmAlerts
|
|
3397
|
+
"gutterpress-gfm-alerts": gfmAlerts,
|
|
3398
|
+
"gutterpress-math": gpMath
|
|
2575
3399
|
};
|
|
2576
|
-
function createMarkdownRenderer(customPlugins) {
|
|
3400
|
+
function createMarkdownRenderer(customPlugins, options) {
|
|
2577
3401
|
const md = new MarkdownIt({
|
|
2578
3402
|
html: true,
|
|
2579
3403
|
linkify: true,
|
|
2580
|
-
typographer: true
|
|
3404
|
+
typographer: true,
|
|
3405
|
+
quotes: quotesFor(options?.language)
|
|
2581
3406
|
});
|
|
3407
|
+
md.use(gpTypography);
|
|
2582
3408
|
md.use(unwrapPlugin(markdownItAttrs));
|
|
2583
3409
|
md.use(unwrapPlugin(markdownItFootnote));
|
|
2584
3410
|
md.use(unwrapPlugin(markdownItDeflist));
|
|
@@ -2588,6 +3414,7 @@ function createMarkdownRenderer(customPlugins) {
|
|
|
2588
3414
|
md.use(plugin, { declaredMarkers });
|
|
2589
3415
|
md.use(gpPinScope);
|
|
2590
3416
|
md.use(gpBlockNames);
|
|
3417
|
+
md.use(gpTable);
|
|
2591
3418
|
md.use(gpTableAlign);
|
|
2592
3419
|
md.use(gpTwoVersions);
|
|
2593
3420
|
registerImageRule(md);
|
|
@@ -2724,7 +3551,7 @@ async function importVendoredEntry(installRoot, packageDir, spec) {
|
|
|
2724
3551
|
try {
|
|
2725
3552
|
entry = await resolvePackageEntry(packageDir);
|
|
2726
3553
|
} catch (cause) {
|
|
2727
|
-
throw new Error(`the downloaded copy of ${spec} under
|
|
3554
|
+
throw new Error(`the downloaded copy of ${spec} under extensions/npm/ is incomplete ` + `(${cause instanceof Error ? cause.message : String(cause)}). ` + `Reinstall it with \`gutterpress ext add ${spec}\`.`, { cause });
|
|
2728
3555
|
}
|
|
2729
3556
|
const entryPath = join(packageDir, ...entry.split("/"));
|
|
2730
3557
|
vendoredRootsOpened.add(installRoot);
|
|
@@ -2944,12 +3771,18 @@ async function loadPlugin(config, baseDir) {
|
|
|
2944
3771
|
if (!config.path && !config.name) {
|
|
2945
3772
|
throw new Error("Plugin manifest entry must specify either `path` or `name`. Got an empty plugin config.");
|
|
2946
3773
|
}
|
|
2947
|
-
if (!config.path && !config.version && config.name
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
3774
|
+
if (!config.path && !config.version && config.name) {
|
|
3775
|
+
const bundled = bundledExtension(config.name);
|
|
3776
|
+
if (bundled?.css !== undefined) {
|
|
3777
|
+
return { name: config.name, plugin: noopPlugin, css: bundled.css, options: config.options };
|
|
3778
|
+
}
|
|
3779
|
+
if (BUILTIN_OPTIONAL_PLUGINS[config.name]) {
|
|
3780
|
+
return {
|
|
3781
|
+
name: config.name,
|
|
3782
|
+
plugin: BUILTIN_OPTIONAL_PLUGINS[config.name],
|
|
3783
|
+
options: config.options
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
2953
3786
|
}
|
|
2954
3787
|
if (config.path) {
|
|
2955
3788
|
const candidatePath = resolve2(baseDir, config.path);
|
|
@@ -3070,4 +3903,4 @@ async function loadPluginsWithCss(configs, baseDir, onError) {
|
|
|
3070
3903
|
};
|
|
3071
3904
|
}
|
|
3072
3905
|
|
|
3073
|
-
export { TWO_VERSIONS_OPEN, TWO_VERSIONS_CLOSE, MARKER_CSS, GUTTERPRESS_CSS, TWO_VERSIONS_CSS, TABLE_ALIGN_CSS, slugify, prettify, parseSrcsetUrlCandidates, collectHtmlImageRefs, createMarkdownRenderer, applyPlugins, collectPluginCss, collectPluginStylePaths, collectPluginStyleGroups, resolveDeclaredStyles, EXTENSION_MANIFEST_FILENAME, readExtensionMeta, extensionStyleList, extensionEntry, extensionCarries, assertExtensionContained, __resetPathPluginCacheForTests, loadPlugin, loadPublishFunction, loadPlugins, loadPluginsWithCss };
|
|
3906
|
+
export { bundledExtension, isPathSpecifier, parseExtensionSpecifier, pinnedNpmSpecifier, TWO_VERSIONS_OPEN, TWO_VERSIONS_CLOSE, MARKER_CSS, GUTTERPRESS_CSS, TWO_VERSIONS_CSS, TABLE_ALIGN_CSS, slugify, prettify, parseSrcsetUrlCandidates, collectHtmlImageRefs, createMarkdownRenderer, applyPlugins, collectPluginCss, collectPluginStylePaths, collectPluginStyleGroups, resolveDeclaredStyles, EXTENSION_MANIFEST_FILENAME, readExtensionMeta, extensionStyleList, extensionEntry, extensionCarries, assertExtensionContained, __resetPathPluginCacheForTests, loadPlugin, loadPublishFunction, loadPlugins, loadPluginsWithCss };
|