@imontene/mdrender 1.0.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.
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/dist/assets/theme-dark.css +40 -0
- package/dist/assets/theme.css +545 -0
- package/dist/assets.d.ts +45 -0
- package/dist/assets.js +109 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +16 -0
- package/dist/browser/cache.d.ts +15 -0
- package/dist/browser/cache.js +30 -0
- package/dist/browser/detect.d.ts +17 -0
- package/dist/browser/detect.js +90 -0
- package/dist/browser/setup.d.ts +13 -0
- package/dist/browser/setup.js +69 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +194 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +32 -0
- package/dist/convert.d.ts +64 -0
- package/dist/convert.js +167 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.js +6 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +21 -0
- package/dist/exit-codes.d.ts +8 -0
- package/dist/exit-codes.js +8 -0
- package/dist/frontmatter.d.ts +10 -0
- package/dist/frontmatter.js +26 -0
- package/dist/html.d.ts +2 -0
- package/dist/html.js +12 -0
- package/dist/i18n.d.ts +9 -0
- package/dist/i18n.js +59 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +18 -0
- package/dist/inputs.d.ts +26 -0
- package/dist/inputs.js +118 -0
- package/dist/markdown/alerts.d.ts +6 -0
- package/dist/markdown/alerts.js +35 -0
- package/dist/markdown/env.d.ts +29 -0
- package/dist/markdown/env.js +16 -0
- package/dist/markdown/highlight.d.ts +6 -0
- package/dist/markdown/highlight.js +17 -0
- package/dist/markdown/images.d.ts +9 -0
- package/dist/markdown/images.js +93 -0
- package/dist/markdown/index.d.ts +27 -0
- package/dist/markdown/index.js +69 -0
- package/dist/markdown/math.d.ts +9 -0
- package/dist/markdown/math.js +147 -0
- package/dist/markdown/mermaid.d.ts +8 -0
- package/dist/markdown/mermaid.js +22 -0
- package/dist/markdown/task-lists.d.ts +6 -0
- package/dist/markdown/task-lists.js +40 -0
- package/dist/markdown/toc.d.ts +22 -0
- package/dist/markdown/toc.js +101 -0
- package/dist/options.d.ts +55 -0
- package/dist/options.js +131 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +4 -0
- package/dist/preview.d.ts +22 -0
- package/dist/preview.js +126 -0
- package/dist/render/browser.d.ts +48 -0
- package/dist/render/browser.js +134 -0
- package/dist/render/fonts.d.ts +10 -0
- package/dist/render/fonts.js +47 -0
- package/dist/render/header-footer.d.ts +22 -0
- package/dist/render/header-footer.js +39 -0
- package/dist/render/katex.d.ts +2 -0
- package/dist/render/katex.js +19 -0
- package/dist/render/mermaid.d.ts +25 -0
- package/dist/render/mermaid.js +91 -0
- package/dist/render/page.d.ts +7 -0
- package/dist/render/page.js +23 -0
- package/dist/render/template.d.ts +22 -0
- package/dist/render/template.js +54 -0
- package/dist/run.d.ts +26 -0
- package/dist/run.js +71 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/dist/watch.d.ts +25 -0
- package/dist/watch.js +128 -0
- package/package.json +97 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
/* mdrender light theme — Inter for text, JetBrains Mono for code. */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--font-text: "Inter", system-ui, sans-serif;
|
|
5
|
+
/* Inter after the mono font covers symbols (arrows, math) missing from the code font. */
|
|
6
|
+
--font-code: "JetBrains Mono", "Inter", ui-monospace, monospace;
|
|
7
|
+
--color-text: #1f2328;
|
|
8
|
+
--color-muted: #59636e;
|
|
9
|
+
--color-heading: #0d1117;
|
|
10
|
+
--color-link: #0969da;
|
|
11
|
+
--color-border: #d1d9e0;
|
|
12
|
+
--color-subtle-bg: #f6f8fa;
|
|
13
|
+
--color-accent: #0969da;
|
|
14
|
+
--color-bg: #ffffff;
|
|
15
|
+
--color-stripe: #fbfcfd;
|
|
16
|
+
--color-error: #b42318;
|
|
17
|
+
--color-error-bg: #fef3f2;
|
|
18
|
+
--color-error-border: #fda29b;
|
|
19
|
+
--alert-note: #0969da;
|
|
20
|
+
--alert-tip: #1a7f37;
|
|
21
|
+
--alert-important: #8250df;
|
|
22
|
+
--alert-warning: #9a6700;
|
|
23
|
+
--alert-caution: #cf222e;
|
|
24
|
+
/* Syntax highlighting (GitHub light) */
|
|
25
|
+
--code-keyword: #cf222e;
|
|
26
|
+
--code-title: #8250df;
|
|
27
|
+
--code-constant: #0550ae;
|
|
28
|
+
--code-string: #0a3069;
|
|
29
|
+
--code-builtin: #953800;
|
|
30
|
+
--code-comment: #6e7781;
|
|
31
|
+
--code-tag: #116329;
|
|
32
|
+
--code-text: #24292f;
|
|
33
|
+
--code-added: #116329;
|
|
34
|
+
--code-added-bg: #dafbe1;
|
|
35
|
+
--code-removed: #82071e;
|
|
36
|
+
--code-removed-bg: #ffebe9;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
* {
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
html {
|
|
44
|
+
font-size: 10.5pt;
|
|
45
|
+
-webkit-print-color-adjust: exact;
|
|
46
|
+
print-color-adjust: exact;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
html,
|
|
50
|
+
body {
|
|
51
|
+
background: var(--color-bg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
body {
|
|
55
|
+
margin: 0;
|
|
56
|
+
color: var(--color-text);
|
|
57
|
+
font-family: var(--font-text);
|
|
58
|
+
font-feature-settings: "calt", "kern";
|
|
59
|
+
line-height: 1.6;
|
|
60
|
+
text-rendering: optimizeLegibility;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.markdown-body {
|
|
64
|
+
max-width: 860px;
|
|
65
|
+
margin: 0 auto;
|
|
66
|
+
padding: 48px 32px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@media print {
|
|
70
|
+
.markdown-body {
|
|
71
|
+
max-width: none;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Headings */
|
|
77
|
+
h1,
|
|
78
|
+
h2,
|
|
79
|
+
h3,
|
|
80
|
+
h4,
|
|
81
|
+
h5,
|
|
82
|
+
h6 {
|
|
83
|
+
color: var(--color-heading);
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
line-height: 1.25;
|
|
86
|
+
letter-spacing: -0.015em;
|
|
87
|
+
margin: 1.6em 0 0.6em;
|
|
88
|
+
break-after: avoid;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
h1 {
|
|
92
|
+
font-size: 2.1em;
|
|
93
|
+
font-weight: 700;
|
|
94
|
+
letter-spacing: -0.025em;
|
|
95
|
+
padding-bottom: 0.3em;
|
|
96
|
+
border-bottom: 1px solid var(--color-border);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
h2 {
|
|
100
|
+
font-size: 1.55em;
|
|
101
|
+
padding-bottom: 0.25em;
|
|
102
|
+
border-bottom: 1px solid var(--color-border);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
h3 {
|
|
106
|
+
font-size: 1.25em;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
h4 {
|
|
110
|
+
font-size: 1.05em;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
h5,
|
|
114
|
+
h6 {
|
|
115
|
+
font-size: 0.95em;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
h6 {
|
|
119
|
+
color: var(--color-muted);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.markdown-body > :first-child {
|
|
123
|
+
margin-top: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Text blocks */
|
|
127
|
+
p,
|
|
128
|
+
ul,
|
|
129
|
+
ol,
|
|
130
|
+
blockquote,
|
|
131
|
+
pre,
|
|
132
|
+
table,
|
|
133
|
+
dl {
|
|
134
|
+
margin: 0 0 1em;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
p,
|
|
138
|
+
li {
|
|
139
|
+
orphans: 3;
|
|
140
|
+
widows: 3;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
a {
|
|
144
|
+
color: var(--color-link);
|
|
145
|
+
text-decoration: none;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
a:hover {
|
|
149
|
+
text-decoration: underline;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
strong {
|
|
153
|
+
font-weight: 600;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
del {
|
|
157
|
+
color: var(--color-muted);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
hr {
|
|
161
|
+
height: 1px;
|
|
162
|
+
margin: 2em 0;
|
|
163
|
+
border: 0;
|
|
164
|
+
background: var(--color-border);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
blockquote {
|
|
168
|
+
margin-left: 0;
|
|
169
|
+
padding: 0.1em 1em;
|
|
170
|
+
color: var(--color-muted);
|
|
171
|
+
border-left: 0.25em solid var(--color-border);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
blockquote > :last-child {
|
|
175
|
+
margin-bottom: 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Lists */
|
|
179
|
+
ul,
|
|
180
|
+
ol {
|
|
181
|
+
padding-left: 1.8em;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
li + li {
|
|
185
|
+
margin-top: 0.25em;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
li > ul,
|
|
189
|
+
li > ol {
|
|
190
|
+
margin: 0.25em 0 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
ul.contains-task-list {
|
|
194
|
+
list-style: none;
|
|
195
|
+
padding-left: 0.4em;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
ul.contains-task-list ul.contains-task-list {
|
|
199
|
+
padding-left: 1.6em;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.task-list-item-checkbox {
|
|
203
|
+
appearance: none;
|
|
204
|
+
width: 0.95em;
|
|
205
|
+
height: 0.95em;
|
|
206
|
+
margin: 0 0.45em 0 0;
|
|
207
|
+
vertical-align: -0.1em;
|
|
208
|
+
border: 1.5px solid var(--color-muted);
|
|
209
|
+
border-radius: 3px;
|
|
210
|
+
background: var(--color-bg);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.task-list-item-checkbox:checked {
|
|
214
|
+
border-color: var(--color-accent);
|
|
215
|
+
background: var(--color-accent)
|
|
216
|
+
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E")
|
|
217
|
+
center / 100% no-repeat;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Code */
|
|
221
|
+
code,
|
|
222
|
+
kbd,
|
|
223
|
+
pre,
|
|
224
|
+
samp {
|
|
225
|
+
font-family: var(--font-code);
|
|
226
|
+
font-feature-settings: "calt" 0;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
code {
|
|
230
|
+
font-size: 0.88em;
|
|
231
|
+
padding: 0.15em 0.35em;
|
|
232
|
+
border-radius: 4px;
|
|
233
|
+
background: var(--color-subtle-bg);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
pre {
|
|
237
|
+
padding: 0.9em 1.1em;
|
|
238
|
+
overflow-x: auto;
|
|
239
|
+
font-size: 0.85em;
|
|
240
|
+
line-height: 1.5;
|
|
241
|
+
border: 1px solid var(--color-border);
|
|
242
|
+
border-radius: 6px;
|
|
243
|
+
background: var(--color-subtle-bg);
|
|
244
|
+
white-space: pre-wrap;
|
|
245
|
+
overflow-wrap: anywhere;
|
|
246
|
+
break-inside: avoid;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
pre code {
|
|
250
|
+
font-size: inherit;
|
|
251
|
+
padding: 0;
|
|
252
|
+
background: none;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Tables */
|
|
256
|
+
table {
|
|
257
|
+
display: table;
|
|
258
|
+
width: auto;
|
|
259
|
+
max-width: 100%;
|
|
260
|
+
border-collapse: collapse;
|
|
261
|
+
font-variant-numeric: tabular-nums;
|
|
262
|
+
break-inside: auto;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
thead {
|
|
266
|
+
display: table-header-group;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
tr {
|
|
270
|
+
break-inside: avoid;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
th,
|
|
274
|
+
td {
|
|
275
|
+
padding: 0.45em 0.85em;
|
|
276
|
+
border: 1px solid var(--color-border);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
th {
|
|
280
|
+
font-weight: 600;
|
|
281
|
+
background: var(--color-subtle-bg);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
tbody tr:nth-child(2n) {
|
|
285
|
+
background: var(--color-stripe);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* Media */
|
|
289
|
+
img {
|
|
290
|
+
max-width: 100%;
|
|
291
|
+
height: auto;
|
|
292
|
+
break-inside: avoid;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Math (KaTeX) */
|
|
296
|
+
.katex {
|
|
297
|
+
font-size: 1.1em;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.math-display {
|
|
301
|
+
margin: 1em 0;
|
|
302
|
+
overflow-x: auto;
|
|
303
|
+
overflow-y: hidden;
|
|
304
|
+
break-inside: avoid;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.math-display .katex-display {
|
|
308
|
+
margin: 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.math-error {
|
|
312
|
+
color: var(--color-error);
|
|
313
|
+
font-family: var(--font-code);
|
|
314
|
+
font-size: 0.88em;
|
|
315
|
+
background: var(--color-error-bg);
|
|
316
|
+
border-radius: 4px;
|
|
317
|
+
padding: 0.1em 0.3em;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
div.math-error {
|
|
321
|
+
display: block;
|
|
322
|
+
padding: 0.6em 0.9em;
|
|
323
|
+
white-space: pre-wrap;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/* Diagrams (Mermaid) */
|
|
327
|
+
.mermaid-diagram {
|
|
328
|
+
margin: 1.2em 0;
|
|
329
|
+
text-align: center;
|
|
330
|
+
break-inside: avoid;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.mermaid-diagram svg {
|
|
334
|
+
max-width: 100%;
|
|
335
|
+
height: auto;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* Mermaid's HTML labels are <p>/<span> inside <foreignObject>: keep document styles out. */
|
|
339
|
+
.mermaid-diagram foreignObject p {
|
|
340
|
+
margin: 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.mermaid-error {
|
|
344
|
+
color: var(--color-error);
|
|
345
|
+
text-align: left;
|
|
346
|
+
border-color: var(--color-error-border);
|
|
347
|
+
background: var(--color-error-bg);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* Syntax highlighting (highlight.js classes; colors in :root) */
|
|
351
|
+
.hljs-doctag,
|
|
352
|
+
.hljs-keyword,
|
|
353
|
+
.hljs-meta .hljs-keyword,
|
|
354
|
+
.hljs-template-tag,
|
|
355
|
+
.hljs-template-variable,
|
|
356
|
+
.hljs-type,
|
|
357
|
+
.hljs-variable.language_ {
|
|
358
|
+
color: var(--code-keyword);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.hljs-title,
|
|
362
|
+
.hljs-title.class_,
|
|
363
|
+
.hljs-title.class_.inherited__,
|
|
364
|
+
.hljs-title.function_ {
|
|
365
|
+
color: var(--code-title);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.hljs-attr,
|
|
369
|
+
.hljs-attribute,
|
|
370
|
+
.hljs-literal,
|
|
371
|
+
.hljs-meta,
|
|
372
|
+
.hljs-number,
|
|
373
|
+
.hljs-operator,
|
|
374
|
+
.hljs-variable,
|
|
375
|
+
.hljs-selector-attr,
|
|
376
|
+
.hljs-selector-class,
|
|
377
|
+
.hljs-selector-id {
|
|
378
|
+
color: var(--code-constant);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.hljs-regexp,
|
|
382
|
+
.hljs-string,
|
|
383
|
+
.hljs-meta .hljs-string {
|
|
384
|
+
color: var(--code-string);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.hljs-built_in,
|
|
388
|
+
.hljs-symbol {
|
|
389
|
+
color: var(--code-builtin);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.hljs-comment,
|
|
393
|
+
.hljs-code,
|
|
394
|
+
.hljs-formula {
|
|
395
|
+
color: var(--code-comment);
|
|
396
|
+
font-style: italic;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.hljs-name,
|
|
400
|
+
.hljs-quote,
|
|
401
|
+
.hljs-selector-tag,
|
|
402
|
+
.hljs-selector-pseudo {
|
|
403
|
+
color: var(--code-tag);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.hljs-subst {
|
|
407
|
+
color: var(--code-text);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.hljs-section {
|
|
411
|
+
color: var(--code-constant);
|
|
412
|
+
font-weight: 700;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.hljs-bullet {
|
|
416
|
+
color: var(--code-builtin);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.hljs-emphasis {
|
|
420
|
+
font-style: italic;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.hljs-strong {
|
|
424
|
+
font-weight: 700;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.hljs-addition {
|
|
428
|
+
color: var(--code-added);
|
|
429
|
+
background-color: var(--code-added-bg);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.hljs-deletion {
|
|
433
|
+
color: var(--code-removed);
|
|
434
|
+
background-color: var(--code-removed-bg);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* Title block (front matter title, subtitle, author, date) */
|
|
438
|
+
.doc-header {
|
|
439
|
+
margin-bottom: 2em;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.doc-header .doc-title {
|
|
443
|
+
margin: 0 0 0.25em;
|
|
444
|
+
font-size: 2.4em;
|
|
445
|
+
border-bottom: 0;
|
|
446
|
+
padding-bottom: 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.doc-subtitle {
|
|
450
|
+
margin: 0 0 0.6em;
|
|
451
|
+
font-size: 1.25em;
|
|
452
|
+
color: var(--color-muted);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.doc-meta {
|
|
456
|
+
margin: 0;
|
|
457
|
+
padding-bottom: 1em;
|
|
458
|
+
color: var(--color-muted);
|
|
459
|
+
border-bottom: 1px solid var(--color-border);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/* Table of contents */
|
|
463
|
+
.toc {
|
|
464
|
+
margin: 0 0 2em;
|
|
465
|
+
padding: 1em 1.4em;
|
|
466
|
+
border: 1px solid var(--color-border);
|
|
467
|
+
border-radius: 6px;
|
|
468
|
+
background: var(--color-subtle-bg);
|
|
469
|
+
break-inside: avoid;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.toc-title {
|
|
473
|
+
margin: 0 0 0.4em;
|
|
474
|
+
font-weight: 600;
|
|
475
|
+
color: var(--color-heading);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.toc ul {
|
|
479
|
+
list-style: none;
|
|
480
|
+
margin: 0;
|
|
481
|
+
padding-left: 1.2em;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.toc > ul {
|
|
485
|
+
padding-left: 0;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.toc li + li,
|
|
489
|
+
.toc li > ul {
|
|
490
|
+
margin-top: 0.15em;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.toc a {
|
|
494
|
+
color: var(--color-text);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/* Alerts: > [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] */
|
|
498
|
+
.markdown-alert {
|
|
499
|
+
--alert-color: var(--alert-note);
|
|
500
|
+
padding: 0.5em 1em;
|
|
501
|
+
color: inherit;
|
|
502
|
+
border-left: 0.25em solid var(--alert-color);
|
|
503
|
+
break-inside: avoid;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.markdown-alert-title {
|
|
507
|
+
margin: 0 0 0.3em;
|
|
508
|
+
font-weight: 600;
|
|
509
|
+
color: var(--alert-color);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.markdown-alert-tip {
|
|
513
|
+
--alert-color: var(--alert-tip);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.markdown-alert-important {
|
|
517
|
+
--alert-color: var(--alert-important);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.markdown-alert-warning {
|
|
521
|
+
--alert-color: var(--alert-warning);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.markdown-alert-caution {
|
|
525
|
+
--alert-color: var(--alert-caution);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* Footnotes */
|
|
529
|
+
.footnote-ref a,
|
|
530
|
+
.footnote-backref {
|
|
531
|
+
text-decoration: none;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
hr.footnotes-sep {
|
|
535
|
+
margin: 2.5em 0 1em;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.footnotes {
|
|
539
|
+
font-size: 0.9em;
|
|
540
|
+
color: var(--color-muted);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.footnotes-list {
|
|
544
|
+
padding-left: 1.4em;
|
|
545
|
+
}
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Absolute path of an asset when running from node_modules (not inside the executable). */
|
|
2
|
+
export declare function assetPath(key: string): string;
|
|
3
|
+
export declare function readAsset(key: string): Buffer;
|
|
4
|
+
export declare const readTextAsset: (key: string) => string;
|
|
5
|
+
/** Same-package key for a path relative to another asset (e.g. a font next to its CSS). */
|
|
6
|
+
export declare function relativeAsset(fromKey: string, relative: string): string;
|
|
7
|
+
export declare const INTER_DIR = "inter-ui/web";
|
|
8
|
+
/** Inter faces in use: regular, semibold and bold, each with its italic. */
|
|
9
|
+
export declare const INTER_FACES: readonly [{
|
|
10
|
+
readonly weight: 400;
|
|
11
|
+
readonly style: "normal";
|
|
12
|
+
readonly file: "Inter-Regular.woff2";
|
|
13
|
+
}, {
|
|
14
|
+
readonly weight: 400;
|
|
15
|
+
readonly style: "italic";
|
|
16
|
+
readonly file: "Inter-Italic.woff2";
|
|
17
|
+
}, {
|
|
18
|
+
readonly weight: 600;
|
|
19
|
+
readonly style: "normal";
|
|
20
|
+
readonly file: "Inter-SemiBold.woff2";
|
|
21
|
+
}, {
|
|
22
|
+
readonly weight: 600;
|
|
23
|
+
readonly style: "italic";
|
|
24
|
+
readonly file: "Inter-SemiBoldItalic.woff2";
|
|
25
|
+
}, {
|
|
26
|
+
readonly weight: 700;
|
|
27
|
+
readonly style: "normal";
|
|
28
|
+
readonly file: "Inter-Bold.woff2";
|
|
29
|
+
}, {
|
|
30
|
+
readonly weight: 700;
|
|
31
|
+
readonly style: "italic";
|
|
32
|
+
readonly file: "Inter-BoldItalic.woff2";
|
|
33
|
+
}];
|
|
34
|
+
export declare const MONO_STYLESHEETS: string[];
|
|
35
|
+
export declare const KATEX_CSS = "katex/dist/katex.min.css";
|
|
36
|
+
export declare const MERMAID_JS = "mermaid/dist/mermaid.min.js";
|
|
37
|
+
export declare const THEMES: string[];
|
|
38
|
+
export declare const PACKAGE_JSON = "mdrender/package.json";
|
|
39
|
+
/** Fonts referenced by a stylesheet as url(...woff2), as asset keys. */
|
|
40
|
+
export declare function woff2References(cssKey: string, css: string): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Every asset the program reads, as key → file on disk. Used by the executable build to embed
|
|
43
|
+
* them; only callable from a normal (node_modules) install.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assetManifest(): Record<string, string>;
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import sea from "node:sea";
|
|
6
|
+
/**
|
|
7
|
+
* Runtime files (fonts, stylesheets, Mermaid) addressed by a key such as
|
|
8
|
+
* "katex/dist/katex.min.css" (a file inside an npm package) or "mdrender/assets/theme.css"
|
|
9
|
+
* (a file of this project).
|
|
10
|
+
*
|
|
11
|
+
* From npm they are read from node_modules; inside the standalone executable they are embedded
|
|
12
|
+
* as Node SEA assets under the same keys (see scripts/build-sea.mjs and `assetManifest`).
|
|
13
|
+
*/
|
|
14
|
+
const SELF = "mdrender";
|
|
15
|
+
/** Folder holding package.json: the project root, both from src/ (dev) and dist/ (build). */
|
|
16
|
+
const projectRoot = () => path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
|
17
|
+
const packageRoots = new Map();
|
|
18
|
+
/** Root folder of an installed package, even when its "exports" hide package.json. */
|
|
19
|
+
function packageRoot(name) {
|
|
20
|
+
let root = packageRoots.get(name);
|
|
21
|
+
if (root)
|
|
22
|
+
return root;
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
let dir;
|
|
25
|
+
try {
|
|
26
|
+
dir = path.dirname(require.resolve(`${name}/package.json`));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
dir = path.dirname(require.resolve(name));
|
|
30
|
+
while (!existsSync(path.join(dir, "package.json")))
|
|
31
|
+
dir = path.dirname(dir);
|
|
32
|
+
}
|
|
33
|
+
root = dir;
|
|
34
|
+
packageRoots.set(name, root);
|
|
35
|
+
return root;
|
|
36
|
+
}
|
|
37
|
+
function splitKey(key) {
|
|
38
|
+
const parts = key.split("/");
|
|
39
|
+
const scoped = key.startsWith("@");
|
|
40
|
+
const name = parts.slice(0, scoped ? 2 : 1).join("/");
|
|
41
|
+
return [name, parts.slice(scoped ? 2 : 1).join("/")];
|
|
42
|
+
}
|
|
43
|
+
/** Absolute path of an asset when running from node_modules (not inside the executable). */
|
|
44
|
+
export function assetPath(key) {
|
|
45
|
+
const [name, rest] = splitKey(key);
|
|
46
|
+
const root = name === SELF ? projectRoot() : packageRoot(name);
|
|
47
|
+
// Project assets live in src/assets (dev) or dist/assets (build), next to this module.
|
|
48
|
+
if (name === SELF && rest.startsWith("assets/")) {
|
|
49
|
+
return path.join(fileURLToPath(new URL(".", import.meta.url)), rest);
|
|
50
|
+
}
|
|
51
|
+
return path.join(root, rest);
|
|
52
|
+
}
|
|
53
|
+
const isSea = () => {
|
|
54
|
+
try {
|
|
55
|
+
return sea.isSea();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export function readAsset(key) {
|
|
62
|
+
if (isSea())
|
|
63
|
+
return Buffer.from(sea.getRawAsset(key));
|
|
64
|
+
return readFileSync(assetPath(key));
|
|
65
|
+
}
|
|
66
|
+
export const readTextAsset = (key) => readAsset(key).toString("utf8");
|
|
67
|
+
/** Same-package key for a path relative to another asset (e.g. a font next to its CSS). */
|
|
68
|
+
export function relativeAsset(fromKey, relative) {
|
|
69
|
+
return path.posix.normalize(path.posix.join(path.posix.dirname(fromKey), relative));
|
|
70
|
+
}
|
|
71
|
+
export const INTER_DIR = "inter-ui/web";
|
|
72
|
+
/** Inter faces in use: regular, semibold and bold, each with its italic. */
|
|
73
|
+
export const INTER_FACES = [
|
|
74
|
+
{ weight: 400, style: "normal", file: "Inter-Regular.woff2" },
|
|
75
|
+
{ weight: 400, style: "italic", file: "Inter-Italic.woff2" },
|
|
76
|
+
{ weight: 600, style: "normal", file: "Inter-SemiBold.woff2" },
|
|
77
|
+
{ weight: 600, style: "italic", file: "Inter-SemiBoldItalic.woff2" },
|
|
78
|
+
{ weight: 700, style: "normal", file: "Inter-Bold.woff2" },
|
|
79
|
+
{ weight: 700, style: "italic", file: "Inter-BoldItalic.woff2" },
|
|
80
|
+
];
|
|
81
|
+
export const MONO_STYLESHEETS = [
|
|
82
|
+
"@fontsource/jetbrains-mono/400.css",
|
|
83
|
+
"@fontsource/jetbrains-mono/400-italic.css",
|
|
84
|
+
"@fontsource/jetbrains-mono/700.css",
|
|
85
|
+
];
|
|
86
|
+
export const KATEX_CSS = "katex/dist/katex.min.css";
|
|
87
|
+
export const MERMAID_JS = "mermaid/dist/mermaid.min.js";
|
|
88
|
+
export const THEMES = ["mdrender/assets/theme.css", "mdrender/assets/theme-dark.css"];
|
|
89
|
+
export const PACKAGE_JSON = "mdrender/package.json";
|
|
90
|
+
/** Fonts referenced by a stylesheet as url(...woff2), as asset keys. */
|
|
91
|
+
export function woff2References(cssKey, css) {
|
|
92
|
+
return [...css.matchAll(/url\((['"]?)([^)'"]+\.woff2)\1\)/g)].map((m) => relativeAsset(cssKey, m[2]));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every asset the program reads, as key → file on disk. Used by the executable build to embed
|
|
96
|
+
* them; only callable from a normal (node_modules) install.
|
|
97
|
+
*/
|
|
98
|
+
export function assetManifest() {
|
|
99
|
+
const keys = new Set([PACKAGE_JSON, ...THEMES, MERMAID_JS]);
|
|
100
|
+
for (const { file } of INTER_FACES)
|
|
101
|
+
keys.add(`${INTER_DIR}/${file}`);
|
|
102
|
+
for (const cssKey of [...MONO_STYLESHEETS, KATEX_CSS]) {
|
|
103
|
+
keys.add(cssKey);
|
|
104
|
+
for (const font of woff2References(cssKey, readTextAsset(cssKey)))
|
|
105
|
+
keys.add(font);
|
|
106
|
+
}
|
|
107
|
+
return Object.fromEntries([...keys].sort().map((key) => [key, assetPath(key)]));
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=assets.js.map
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point of the `mdrender` command (npm bin and standalone executable).
|
|
3
|
+
import { defaultIo, main } from "./cli.js";
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
process.once("SIGINT", () => controller.abort());
|
|
6
|
+
process.once("SIGTERM", () => controller.abort());
|
|
7
|
+
main(process.argv.slice(2), defaultIo, { signal: controller.signal }).then((code) => {
|
|
8
|
+
process.exitCode = code;
|
|
9
|
+
// Leftover handles (e.g. a keep-alive proxy connection after `setup`) must not keep the CLI
|
|
10
|
+
// running. The timer is unref'd: it only fires if something else holds the process open.
|
|
11
|
+
setTimeout(() => process.exit(), 500).unref();
|
|
12
|
+
}, (error) => {
|
|
13
|
+
console.error(error);
|
|
14
|
+
process.exit(70);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|