@d10f/asciidoc-astro-loader 0.0.16 → 0.2.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/README.md +51 -10
- package/dist/{chunk-5LUVP7HW.js → chunk-S7W7VGV4.js} +2 -0
- package/dist/{index-C1F2jTPD.d.cts → index-B1d5alka.d.cts} +53 -197
- package/dist/{index-C1F2jTPD.d.ts → index-B1d5alka.d.ts} +53 -197
- package/dist/index.cjs +24 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -2
- package/dist/lib/asciidoc/converters/index.d.cts +1 -1
- package/dist/lib/asciidoc/converters/index.d.ts +1 -1
- package/dist/lib/asciidoc/templates/engines/index.cjs +2 -0
- package/dist/lib/asciidoc/templates/engines/index.d.cts +1 -1
- package/dist/lib/asciidoc/templates/engines/index.d.ts +1 -1
- package/dist/lib/asciidoc/templates/engines/index.js +1 -1
- package/dist/lib/shiki/transformers/index.d.cts +39 -1
- package/dist/lib/shiki/transformers/index.d.ts +39 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -27,7 +27,8 @@ Install the package from `npm`:
|
|
|
27
27
|
And import the loader function inside your `content.config.ts` file to define a new collection:
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
import { defineCollection
|
|
30
|
+
import { defineCollection } from "astro:content";
|
|
31
|
+
import { z } from 'astro/zod';
|
|
31
32
|
import { asciidocLoader } from "asciidoc-astro-loader";
|
|
32
33
|
|
|
33
34
|
const blog = defineCollection({
|
|
@@ -93,7 +94,7 @@ const blog = defineCollection({
|
|
|
93
94
|
});
|
|
94
95
|
```
|
|
95
96
|
|
|
96
|
-
### Shiki
|
|
97
|
+
### Shiki Transformers
|
|
97
98
|
|
|
98
99
|
One of the coolest features from Shiki are [transformers](https://shiki.style/guide/transformers). You can provide a list of the transformers that you want to use at the loader configuration:
|
|
99
100
|
|
|
@@ -352,18 +353,27 @@ Using a converter might make more sense if you need to keep some state as the do
|
|
|
352
353
|
|
|
353
354
|
## Example
|
|
354
355
|
|
|
355
|
-
This is an example taken from my own website to showcase how to use it in a real world setting
|
|
356
|
+
This is an example taken from my own website to showcase how to use it in a real world setting:
|
|
356
357
|
|
|
357
358
|
```ts
|
|
358
359
|
const blog = defineCollection({
|
|
359
360
|
loader: asciidocLoader({
|
|
360
361
|
base: 'src/content/blog',
|
|
362
|
+
images: {
|
|
363
|
+
imageUrl: '/',
|
|
364
|
+
},
|
|
361
365
|
document: {
|
|
362
366
|
template: './src/templates',
|
|
363
|
-
converters: [
|
|
367
|
+
converters: [
|
|
368
|
+
admonitionConverter(),
|
|
369
|
+
xrefConverter()
|
|
370
|
+
],
|
|
364
371
|
},
|
|
365
372
|
syntaxHighlighting: {
|
|
366
|
-
theme:
|
|
373
|
+
theme: {
|
|
374
|
+
light: 'catppuccin-latte',
|
|
375
|
+
dark: 'catppuccin-frappe',
|
|
376
|
+
},
|
|
367
377
|
transformers: [
|
|
368
378
|
transformerNotationDiff(),
|
|
369
379
|
transformerNotationErrorLevel(),
|
|
@@ -372,6 +382,9 @@ const blog = defineCollection({
|
|
|
372
382
|
transformerPrompt({
|
|
373
383
|
langs: {
|
|
374
384
|
console: '$',
|
|
385
|
+
prolog: {
|
|
386
|
+
hideBreak: true,
|
|
387
|
+
},
|
|
375
388
|
},
|
|
376
389
|
cssClasses: 'unselectable mr-2 opacity-50',
|
|
377
390
|
}),
|
|
@@ -381,10 +394,38 @@ const blog = defineCollection({
|
|
|
381
394
|
},
|
|
382
395
|
},
|
|
383
396
|
}),
|
|
384
|
-
schema: z
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
397
|
+
schema: z
|
|
398
|
+
.object({
|
|
399
|
+
doctitle: z.string(),
|
|
400
|
+
description: z.string(),
|
|
401
|
+
revdate: z.coerce.date(),
|
|
402
|
+
keywords: z.string().transform((t) => t.split(', ')),
|
|
403
|
+
technologies: z.string().transform((t) => t.split(' ')),
|
|
404
|
+
series: z.string().optional(),
|
|
405
|
+
'series-prev': z.string().optional(),
|
|
406
|
+
'series-next': z.string().optional(),
|
|
407
|
+
'series-description': z.string().optional(),
|
|
408
|
+
})
|
|
409
|
+
.transform(({ doctitle, revdate, ...rest }) => ({
|
|
410
|
+
title: doctitle,
|
|
411
|
+
createdAt: revdate,
|
|
412
|
+
...rest,
|
|
413
|
+
})),
|
|
389
414
|
});
|
|
390
415
|
```
|
|
416
|
+
|
|
417
|
+
This configuration uses a couple of custom converters, a custom Shiki transformer and points to a folder where custom templates are found.
|
|
418
|
+
|
|
419
|
+
The first converter applies a simple CSS rule so that admonitions are placed on either side of the main document, in an alternate fashion.
|
|
420
|
+
|
|
421
|
+
The other converter is a little helper to rectify cross-reference links to other documents. I created it because cross-reference in AsciiDoc works by referencing a filename, whereas Astro uses the post title as the URL slug, which makes more sense in the context of the web. This converter handles the conversion so that I can keep things organized neatly based on what makes more sense: use filenames in the file system, and URL slugs in the web.
|
|
422
|
+
|
|
423
|
+
As for the custom Shiki transformer, that's just so that I control how code snippets look like when there's either a prefix expected, or when multi-line is supported. The classic example of this are console commands, but REPL interpreters are also a good example.
|
|
424
|
+
|
|
425
|
+
Here you can see it in action with a command that is written over multiple lines for clarity (horizontal overflow not shown here):
|
|
426
|
+
|
|
427
|
+

|
|
428
|
+
|
|
429
|
+
Notice the escaping of the newline character, which you might want to omit with the `hideBreak` option. This is useful to distinguish code from REPL interpreters:
|
|
430
|
+
|
|
431
|
+

|
|
@@ -7,110 +7,37 @@ type DocumentOptions = RequiredOptions['document'];
|
|
|
7
7
|
type PreambleOptions = RequiredOptions['preamble'];
|
|
8
8
|
declare const loaderOptionsSchema: z.ZodObject<{
|
|
9
9
|
base: z.ZodString;
|
|
10
|
+
images: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
imageDir: z.ZodOptional<z.ZodString>;
|
|
12
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
10
14
|
document: z.ZodDefault<z.ZodObject<{
|
|
11
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
12
|
-
template: z.
|
|
15
|
+
mode: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
16
|
+
template: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<string, string>>;
|
|
13
17
|
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
19
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
20
|
-
template: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
21
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
23
|
-
syntaxHighlighting: z.ZodDefault<z.ZodEffects<z.ZodObject<{
|
|
24
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
25
|
-
light: z.ZodString;
|
|
26
|
-
dark: z.ZodString;
|
|
27
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
18
|
+
}, z.core.$loose>>;
|
|
19
|
+
syntaxHighlighting: z.ZodDefault<z.ZodPipe<z.ZodObject<{
|
|
20
|
+
theme: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
28
21
|
light: z.ZodString;
|
|
29
22
|
dark: z.ZodString;
|
|
30
|
-
}, z.ZodString
|
|
31
|
-
light: z.ZodString;
|
|
32
|
-
dark: z.ZodString;
|
|
33
|
-
}, z.ZodString, "strip">>]>, {
|
|
23
|
+
}, z.core.$catchall<z.ZodString>>]>, z.ZodTransform<{
|
|
34
24
|
light: string;
|
|
35
25
|
dark: string;
|
|
36
26
|
} & {
|
|
37
27
|
[other: string]: string;
|
|
38
|
-
}, string |
|
|
39
|
-
|
|
40
|
-
dark: z.ZodString;
|
|
41
|
-
}, z.ZodString, "strip">>>;
|
|
42
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
43
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
44
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
45
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
46
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
47
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
cssClasses?: string | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
cssClasses?: string | undefined;
|
|
52
|
-
}>>;
|
|
53
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
54
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
55
|
-
light: z.ZodString;
|
|
56
|
-
dark: z.ZodString;
|
|
57
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
58
|
-
light: z.ZodString;
|
|
59
|
-
dark: z.ZodString;
|
|
60
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
61
|
-
light: z.ZodString;
|
|
62
|
-
dark: z.ZodString;
|
|
63
|
-
}, z.ZodString, "strip">>]>, {
|
|
64
|
-
light: string;
|
|
65
|
-
dark: string;
|
|
66
|
-
} & {
|
|
67
|
-
[other: string]: string;
|
|
68
|
-
}, string | z.objectInputType<{
|
|
69
|
-
light: z.ZodString;
|
|
70
|
-
dark: z.ZodString;
|
|
71
|
-
}, z.ZodString, "strip">>>;
|
|
72
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
73
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
74
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
75
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
76
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
78
|
-
}, "strip", z.ZodTypeAny, {
|
|
79
|
-
cssClasses?: string | undefined;
|
|
80
|
-
}, {
|
|
81
|
-
cssClasses?: string | undefined;
|
|
82
|
-
}>>;
|
|
83
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
84
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
85
|
-
light: z.ZodString;
|
|
86
|
-
dark: z.ZodString;
|
|
87
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
88
|
-
light: z.ZodString;
|
|
89
|
-
dark: z.ZodString;
|
|
90
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
91
|
-
light: z.ZodString;
|
|
92
|
-
dark: z.ZodString;
|
|
93
|
-
}, z.ZodString, "strip">>]>, {
|
|
28
|
+
}, string | {
|
|
29
|
+
[x: string]: string;
|
|
94
30
|
light: string;
|
|
95
31
|
dark: string;
|
|
96
|
-
}
|
|
97
|
-
[other: string]: string;
|
|
98
|
-
}, string | z.objectInputType<{
|
|
99
|
-
light: z.ZodString;
|
|
100
|
-
dark: z.ZodString;
|
|
101
|
-
}, z.ZodString, "strip">>>;
|
|
32
|
+
}>>>;
|
|
102
33
|
defaultColor: z.ZodDefault<z.ZodString>;
|
|
103
34
|
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
104
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
105
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
35
|
+
mergeWhitespaces: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
36
|
+
tabindex: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
106
37
|
callouts: z.ZodOptional<z.ZodObject<{
|
|
107
38
|
cssClasses: z.ZodOptional<z.ZodString>;
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
}, {
|
|
111
|
-
cssClasses?: string | undefined;
|
|
112
|
-
}>>;
|
|
113
|
-
}, z.ZodTypeAny, "passthrough">>, {
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
}, z.core.$loose>, z.ZodTransform<{
|
|
114
41
|
defaultColor: string;
|
|
115
42
|
cssVariablePrefix: string;
|
|
116
43
|
mergeWhitespaces: boolean | "never";
|
|
@@ -124,60 +51,14 @@ declare const loaderOptionsSchema: z.ZodObject<{
|
|
|
124
51
|
} & {
|
|
125
52
|
[other: string]: string;
|
|
126
53
|
};
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
dark: z.ZodString;
|
|
131
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
132
|
-
light: z.ZodString;
|
|
133
|
-
dark: z.ZodString;
|
|
134
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
135
|
-
light: z.ZodString;
|
|
136
|
-
dark: z.ZodString;
|
|
137
|
-
}, z.ZodString, "strip">>]>, {
|
|
54
|
+
}, {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
theme: {
|
|
138
57
|
light: string;
|
|
139
58
|
dark: string;
|
|
140
59
|
} & {
|
|
141
60
|
[other: string]: string;
|
|
142
|
-
}
|
|
143
|
-
light: z.ZodString;
|
|
144
|
-
dark: z.ZodString;
|
|
145
|
-
}, z.ZodString, "strip">>>;
|
|
146
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
147
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
148
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
149
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
150
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
151
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
152
|
-
}, "strip", z.ZodTypeAny, {
|
|
153
|
-
cssClasses?: string | undefined;
|
|
154
|
-
}, {
|
|
155
|
-
cssClasses?: string | undefined;
|
|
156
|
-
}>>;
|
|
157
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
158
|
-
preamble: z.ZodDefault<z.ZodObject<{
|
|
159
|
-
tableOfContents: z.ZodDefault<z.ZodBoolean>;
|
|
160
|
-
maxLevel: z.ZodDefault<z.ZodNumber>;
|
|
161
|
-
position: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"before">, z.ZodLiteral<"after">]>>;
|
|
162
|
-
}, "strip", z.ZodTypeAny, {
|
|
163
|
-
tableOfContents: boolean;
|
|
164
|
-
maxLevel: number;
|
|
165
|
-
position: "before" | "after";
|
|
166
|
-
}, {
|
|
167
|
-
tableOfContents?: boolean | undefined;
|
|
168
|
-
maxLevel?: number | undefined;
|
|
169
|
-
position?: "before" | "after" | undefined;
|
|
170
|
-
}>>;
|
|
171
|
-
}, "strip", z.ZodTypeAny, {
|
|
172
|
-
base: string;
|
|
173
|
-
document: {
|
|
174
|
-
mode: "safe" | "unsafe";
|
|
175
|
-
template: string;
|
|
176
|
-
recursive: boolean;
|
|
177
|
-
} & {
|
|
178
|
-
[k: string]: unknown;
|
|
179
|
-
};
|
|
180
|
-
syntaxHighlighting: {
|
|
61
|
+
};
|
|
181
62
|
defaultColor: string;
|
|
182
63
|
cssVariablePrefix: string;
|
|
183
64
|
mergeWhitespaces: boolean | "never";
|
|
@@ -185,62 +66,13 @@ declare const loaderOptionsSchema: z.ZodObject<{
|
|
|
185
66
|
callouts?: {
|
|
186
67
|
cssClasses?: string | undefined;
|
|
187
68
|
} | undefined;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
preamble: {
|
|
196
|
-
tableOfContents: boolean;
|
|
197
|
-
maxLevel: number;
|
|
198
|
-
position: "before" | "after";
|
|
199
|
-
};
|
|
200
|
-
}, {
|
|
201
|
-
base: string;
|
|
202
|
-
document?: z.objectInputType<{
|
|
203
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
204
|
-
template: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
205
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
206
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
207
|
-
syntaxHighlighting?: z.objectInputType<{
|
|
208
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
209
|
-
light: z.ZodString;
|
|
210
|
-
dark: z.ZodString;
|
|
211
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
212
|
-
light: z.ZodString;
|
|
213
|
-
dark: z.ZodString;
|
|
214
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
215
|
-
light: z.ZodString;
|
|
216
|
-
dark: z.ZodString;
|
|
217
|
-
}, z.ZodString, "strip">>]>, {
|
|
218
|
-
light: string;
|
|
219
|
-
dark: string;
|
|
220
|
-
} & {
|
|
221
|
-
[other: string]: string;
|
|
222
|
-
}, string | z.objectInputType<{
|
|
223
|
-
light: z.ZodString;
|
|
224
|
-
dark: z.ZodString;
|
|
225
|
-
}, z.ZodString, "strip">>>;
|
|
226
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
227
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
228
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
229
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
230
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
231
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
232
|
-
}, "strip", z.ZodTypeAny, {
|
|
233
|
-
cssClasses?: string | undefined;
|
|
234
|
-
}, {
|
|
235
|
-
cssClasses?: string | undefined;
|
|
236
|
-
}>>;
|
|
237
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
238
|
-
preamble?: {
|
|
239
|
-
tableOfContents?: boolean | undefined;
|
|
240
|
-
maxLevel?: number | undefined;
|
|
241
|
-
position?: "before" | "after" | undefined;
|
|
242
|
-
} | undefined;
|
|
243
|
-
}>;
|
|
69
|
+
}>>>;
|
|
70
|
+
preamble: z.ZodDefault<z.ZodObject<{
|
|
71
|
+
tableOfContents: z.ZodDefault<z.ZodBoolean>;
|
|
72
|
+
maxLevel: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
position: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"before">, z.ZodLiteral<"after">]>>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
244
76
|
|
|
245
77
|
declare abstract class AbstractEngine {
|
|
246
78
|
private _name;
|
|
@@ -420,6 +252,30 @@ type AsciidocLoader = {
|
|
|
420
252
|
*/
|
|
421
253
|
templateEngines: Array<AbstractEngine & AsciidocTemplate>;
|
|
422
254
|
}>;
|
|
255
|
+
/**
|
|
256
|
+
* Options related to images and their location while parsing documents
|
|
257
|
+
*/
|
|
258
|
+
images?: Partial<{
|
|
259
|
+
/**
|
|
260
|
+
* Path to the directory where images are stored. This is a global
|
|
261
|
+
* setting that applies to all documents that _do not_ already have
|
|
262
|
+
* an imagesdir attribute set.
|
|
263
|
+
*
|
|
264
|
+
* Make use of templates or converters for granuar control over this
|
|
265
|
+
* attribute on individua documents.
|
|
266
|
+
*
|
|
267
|
+
* @see https://docs.asciidoctor.org/pdf-converter/latest/image-paths-and-formats/#imagesdir
|
|
268
|
+
*/
|
|
269
|
+
imagesDir?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Path relative to the base URL of the site that will be used to
|
|
272
|
+
* resolve image src attributes. The base URL is configured via the
|
|
273
|
+
* Astro configuration file.
|
|
274
|
+
*
|
|
275
|
+
* @see https://docs.astro.build/en/reference/configuration-reference/#site
|
|
276
|
+
*/
|
|
277
|
+
imageUrl?: string;
|
|
278
|
+
}>;
|
|
423
279
|
/**
|
|
424
280
|
* Options provided for the output of the preamble section, when
|
|
425
281
|
* there is one present in the parsed document.
|
|
@@ -546,4 +402,4 @@ interface RawTemplate {
|
|
|
546
402
|
renderString(content: string, options?: Record<string, unknown>): string;
|
|
547
403
|
}
|
|
548
404
|
|
|
549
|
-
export {
|
|
405
|
+
export { AbstractEngine as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactory as S, type TemplateModule as T, type AsciidocLoader as a, type AsciidocTemplate as b, type ShikiTransformerFactoryFn as c };
|
|
@@ -7,110 +7,37 @@ type DocumentOptions = RequiredOptions['document'];
|
|
|
7
7
|
type PreambleOptions = RequiredOptions['preamble'];
|
|
8
8
|
declare const loaderOptionsSchema: z.ZodObject<{
|
|
9
9
|
base: z.ZodString;
|
|
10
|
+
images: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
imageDir: z.ZodOptional<z.ZodString>;
|
|
12
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
10
14
|
document: z.ZodDefault<z.ZodObject<{
|
|
11
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
12
|
-
template: z.
|
|
15
|
+
mode: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
16
|
+
template: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<string, string>>;
|
|
13
17
|
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
19
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
20
|
-
template: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
21
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
23
|
-
syntaxHighlighting: z.ZodDefault<z.ZodEffects<z.ZodObject<{
|
|
24
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
25
|
-
light: z.ZodString;
|
|
26
|
-
dark: z.ZodString;
|
|
27
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
18
|
+
}, z.core.$loose>>;
|
|
19
|
+
syntaxHighlighting: z.ZodDefault<z.ZodPipe<z.ZodObject<{
|
|
20
|
+
theme: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
28
21
|
light: z.ZodString;
|
|
29
22
|
dark: z.ZodString;
|
|
30
|
-
}, z.ZodString
|
|
31
|
-
light: z.ZodString;
|
|
32
|
-
dark: z.ZodString;
|
|
33
|
-
}, z.ZodString, "strip">>]>, {
|
|
23
|
+
}, z.core.$catchall<z.ZodString>>]>, z.ZodTransform<{
|
|
34
24
|
light: string;
|
|
35
25
|
dark: string;
|
|
36
26
|
} & {
|
|
37
27
|
[other: string]: string;
|
|
38
|
-
}, string |
|
|
39
|
-
|
|
40
|
-
dark: z.ZodString;
|
|
41
|
-
}, z.ZodString, "strip">>>;
|
|
42
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
43
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
44
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
45
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
46
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
47
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
cssClasses?: string | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
cssClasses?: string | undefined;
|
|
52
|
-
}>>;
|
|
53
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
54
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
55
|
-
light: z.ZodString;
|
|
56
|
-
dark: z.ZodString;
|
|
57
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
58
|
-
light: z.ZodString;
|
|
59
|
-
dark: z.ZodString;
|
|
60
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
61
|
-
light: z.ZodString;
|
|
62
|
-
dark: z.ZodString;
|
|
63
|
-
}, z.ZodString, "strip">>]>, {
|
|
64
|
-
light: string;
|
|
65
|
-
dark: string;
|
|
66
|
-
} & {
|
|
67
|
-
[other: string]: string;
|
|
68
|
-
}, string | z.objectInputType<{
|
|
69
|
-
light: z.ZodString;
|
|
70
|
-
dark: z.ZodString;
|
|
71
|
-
}, z.ZodString, "strip">>>;
|
|
72
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
73
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
74
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
75
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
76
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
78
|
-
}, "strip", z.ZodTypeAny, {
|
|
79
|
-
cssClasses?: string | undefined;
|
|
80
|
-
}, {
|
|
81
|
-
cssClasses?: string | undefined;
|
|
82
|
-
}>>;
|
|
83
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
84
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
85
|
-
light: z.ZodString;
|
|
86
|
-
dark: z.ZodString;
|
|
87
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
88
|
-
light: z.ZodString;
|
|
89
|
-
dark: z.ZodString;
|
|
90
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
91
|
-
light: z.ZodString;
|
|
92
|
-
dark: z.ZodString;
|
|
93
|
-
}, z.ZodString, "strip">>]>, {
|
|
28
|
+
}, string | {
|
|
29
|
+
[x: string]: string;
|
|
94
30
|
light: string;
|
|
95
31
|
dark: string;
|
|
96
|
-
}
|
|
97
|
-
[other: string]: string;
|
|
98
|
-
}, string | z.objectInputType<{
|
|
99
|
-
light: z.ZodString;
|
|
100
|
-
dark: z.ZodString;
|
|
101
|
-
}, z.ZodString, "strip">>>;
|
|
32
|
+
}>>>;
|
|
102
33
|
defaultColor: z.ZodDefault<z.ZodString>;
|
|
103
34
|
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
104
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
105
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
35
|
+
mergeWhitespaces: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
36
|
+
tabindex: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
106
37
|
callouts: z.ZodOptional<z.ZodObject<{
|
|
107
38
|
cssClasses: z.ZodOptional<z.ZodString>;
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
}, {
|
|
111
|
-
cssClasses?: string | undefined;
|
|
112
|
-
}>>;
|
|
113
|
-
}, z.ZodTypeAny, "passthrough">>, {
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
}, z.core.$loose>, z.ZodTransform<{
|
|
114
41
|
defaultColor: string;
|
|
115
42
|
cssVariablePrefix: string;
|
|
116
43
|
mergeWhitespaces: boolean | "never";
|
|
@@ -124,60 +51,14 @@ declare const loaderOptionsSchema: z.ZodObject<{
|
|
|
124
51
|
} & {
|
|
125
52
|
[other: string]: string;
|
|
126
53
|
};
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
dark: z.ZodString;
|
|
131
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
132
|
-
light: z.ZodString;
|
|
133
|
-
dark: z.ZodString;
|
|
134
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
135
|
-
light: z.ZodString;
|
|
136
|
-
dark: z.ZodString;
|
|
137
|
-
}, z.ZodString, "strip">>]>, {
|
|
54
|
+
}, {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
theme: {
|
|
138
57
|
light: string;
|
|
139
58
|
dark: string;
|
|
140
59
|
} & {
|
|
141
60
|
[other: string]: string;
|
|
142
|
-
}
|
|
143
|
-
light: z.ZodString;
|
|
144
|
-
dark: z.ZodString;
|
|
145
|
-
}, z.ZodString, "strip">>>;
|
|
146
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
147
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
148
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
149
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
150
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
151
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
152
|
-
}, "strip", z.ZodTypeAny, {
|
|
153
|
-
cssClasses?: string | undefined;
|
|
154
|
-
}, {
|
|
155
|
-
cssClasses?: string | undefined;
|
|
156
|
-
}>>;
|
|
157
|
-
}, z.ZodTypeAny, "passthrough">>>;
|
|
158
|
-
preamble: z.ZodDefault<z.ZodObject<{
|
|
159
|
-
tableOfContents: z.ZodDefault<z.ZodBoolean>;
|
|
160
|
-
maxLevel: z.ZodDefault<z.ZodNumber>;
|
|
161
|
-
position: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"before">, z.ZodLiteral<"after">]>>;
|
|
162
|
-
}, "strip", z.ZodTypeAny, {
|
|
163
|
-
tableOfContents: boolean;
|
|
164
|
-
maxLevel: number;
|
|
165
|
-
position: "before" | "after";
|
|
166
|
-
}, {
|
|
167
|
-
tableOfContents?: boolean | undefined;
|
|
168
|
-
maxLevel?: number | undefined;
|
|
169
|
-
position?: "before" | "after" | undefined;
|
|
170
|
-
}>>;
|
|
171
|
-
}, "strip", z.ZodTypeAny, {
|
|
172
|
-
base: string;
|
|
173
|
-
document: {
|
|
174
|
-
mode: "safe" | "unsafe";
|
|
175
|
-
template: string;
|
|
176
|
-
recursive: boolean;
|
|
177
|
-
} & {
|
|
178
|
-
[k: string]: unknown;
|
|
179
|
-
};
|
|
180
|
-
syntaxHighlighting: {
|
|
61
|
+
};
|
|
181
62
|
defaultColor: string;
|
|
182
63
|
cssVariablePrefix: string;
|
|
183
64
|
mergeWhitespaces: boolean | "never";
|
|
@@ -185,62 +66,13 @@ declare const loaderOptionsSchema: z.ZodObject<{
|
|
|
185
66
|
callouts?: {
|
|
186
67
|
cssClasses?: string | undefined;
|
|
187
68
|
} | undefined;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
preamble: {
|
|
196
|
-
tableOfContents: boolean;
|
|
197
|
-
maxLevel: number;
|
|
198
|
-
position: "before" | "after";
|
|
199
|
-
};
|
|
200
|
-
}, {
|
|
201
|
-
base: string;
|
|
202
|
-
document?: z.objectInputType<{
|
|
203
|
-
mode: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"safe">, z.ZodLiteral<"unsafe">]>>;
|
|
204
|
-
template: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
205
|
-
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
206
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
207
|
-
syntaxHighlighting?: z.objectInputType<{
|
|
208
|
-
theme: z.ZodDefault<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
209
|
-
light: z.ZodString;
|
|
210
|
-
dark: z.ZodString;
|
|
211
|
-
}, "strip", z.ZodString, z.objectOutputType<{
|
|
212
|
-
light: z.ZodString;
|
|
213
|
-
dark: z.ZodString;
|
|
214
|
-
}, z.ZodString, "strip">, z.objectInputType<{
|
|
215
|
-
light: z.ZodString;
|
|
216
|
-
dark: z.ZodString;
|
|
217
|
-
}, z.ZodString, "strip">>]>, {
|
|
218
|
-
light: string;
|
|
219
|
-
dark: string;
|
|
220
|
-
} & {
|
|
221
|
-
[other: string]: string;
|
|
222
|
-
}, string | z.objectInputType<{
|
|
223
|
-
light: z.ZodString;
|
|
224
|
-
dark: z.ZodString;
|
|
225
|
-
}, z.ZodString, "strip">>>;
|
|
226
|
-
defaultColor: z.ZodDefault<z.ZodString>;
|
|
227
|
-
cssVariablePrefix: z.ZodDefault<z.ZodString>;
|
|
228
|
-
mergeWhitespaces: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"never">]>>;
|
|
229
|
-
tabindex: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodLiteral<false>]>>;
|
|
230
|
-
callouts: z.ZodOptional<z.ZodObject<{
|
|
231
|
-
cssClasses: z.ZodOptional<z.ZodString>;
|
|
232
|
-
}, "strip", z.ZodTypeAny, {
|
|
233
|
-
cssClasses?: string | undefined;
|
|
234
|
-
}, {
|
|
235
|
-
cssClasses?: string | undefined;
|
|
236
|
-
}>>;
|
|
237
|
-
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
238
|
-
preamble?: {
|
|
239
|
-
tableOfContents?: boolean | undefined;
|
|
240
|
-
maxLevel?: number | undefined;
|
|
241
|
-
position?: "before" | "after" | undefined;
|
|
242
|
-
} | undefined;
|
|
243
|
-
}>;
|
|
69
|
+
}>>>;
|
|
70
|
+
preamble: z.ZodDefault<z.ZodObject<{
|
|
71
|
+
tableOfContents: z.ZodDefault<z.ZodBoolean>;
|
|
72
|
+
maxLevel: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
position: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"before">, z.ZodLiteral<"after">]>>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
244
76
|
|
|
245
77
|
declare abstract class AbstractEngine {
|
|
246
78
|
private _name;
|
|
@@ -420,6 +252,30 @@ type AsciidocLoader = {
|
|
|
420
252
|
*/
|
|
421
253
|
templateEngines: Array<AbstractEngine & AsciidocTemplate>;
|
|
422
254
|
}>;
|
|
255
|
+
/**
|
|
256
|
+
* Options related to images and their location while parsing documents
|
|
257
|
+
*/
|
|
258
|
+
images?: Partial<{
|
|
259
|
+
/**
|
|
260
|
+
* Path to the directory where images are stored. This is a global
|
|
261
|
+
* setting that applies to all documents that _do not_ already have
|
|
262
|
+
* an imagesdir attribute set.
|
|
263
|
+
*
|
|
264
|
+
* Make use of templates or converters for granuar control over this
|
|
265
|
+
* attribute on individua documents.
|
|
266
|
+
*
|
|
267
|
+
* @see https://docs.asciidoctor.org/pdf-converter/latest/image-paths-and-formats/#imagesdir
|
|
268
|
+
*/
|
|
269
|
+
imagesDir?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Path relative to the base URL of the site that will be used to
|
|
272
|
+
* resolve image src attributes. The base URL is configured via the
|
|
273
|
+
* Astro configuration file.
|
|
274
|
+
*
|
|
275
|
+
* @see https://docs.astro.build/en/reference/configuration-reference/#site
|
|
276
|
+
*/
|
|
277
|
+
imageUrl?: string;
|
|
278
|
+
}>;
|
|
423
279
|
/**
|
|
424
280
|
* Options provided for the output of the preamble section, when
|
|
425
281
|
* there is one present in the parsed document.
|
|
@@ -546,4 +402,4 @@ interface RawTemplate {
|
|
|
546
402
|
renderString(content: string, options?: Record<string, unknown>): string;
|
|
547
403
|
}
|
|
548
404
|
|
|
549
|
-
export {
|
|
405
|
+
export { AbstractEngine as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactory as S, type TemplateModule as T, type AsciidocLoader as a, type AsciidocTemplate as b, type ShikiTransformerFactoryFn as c };
|
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ var BaseConverter = class {
|
|
|
67
67
|
this.customConverters = /* @__PURE__ */ new Map();
|
|
68
68
|
this.templateEngine = void 0;
|
|
69
69
|
}
|
|
70
|
+
defaultConverter;
|
|
70
71
|
customConverters;
|
|
71
72
|
templateEngine;
|
|
72
73
|
/**
|
|
@@ -297,6 +298,9 @@ var AsciidocDocument = class {
|
|
|
297
298
|
return acc.add(lang);
|
|
298
299
|
}, /* @__PURE__ */ new Set());
|
|
299
300
|
}
|
|
301
|
+
setAttribute(attribute, value) {
|
|
302
|
+
this.document.setAttribute(attribute, value);
|
|
303
|
+
}
|
|
300
304
|
convert(converters = [], templateEngine) {
|
|
301
305
|
converters.forEach((converter) => {
|
|
302
306
|
this.baseConverter.register(converter);
|
|
@@ -318,6 +322,8 @@ var AbstractEngine = class {
|
|
|
318
322
|
this._extensions = _extensions;
|
|
319
323
|
this.templateList = /* @__PURE__ */ new Map();
|
|
320
324
|
}
|
|
325
|
+
_name;
|
|
326
|
+
_extensions;
|
|
321
327
|
templateList;
|
|
322
328
|
/**
|
|
323
329
|
* Returns the given name to this template engine.
|
|
@@ -534,8 +540,13 @@ var preambleOptionsSchema = import_zod3.z.object({
|
|
|
534
540
|
maxLevel: 3,
|
|
535
541
|
position: "after"
|
|
536
542
|
});
|
|
543
|
+
var imagesOptionsSchema = import_zod3.z.object({
|
|
544
|
+
imageDir: import_zod3.z.optional(import_zod3.z.string()),
|
|
545
|
+
imageUrl: import_zod3.z.optional(import_zod3.z.string())
|
|
546
|
+
}).optional();
|
|
537
547
|
var loaderOptionsSchema = import_zod3.z.object({
|
|
538
548
|
base: import_zod3.z.string(),
|
|
549
|
+
images: imagesOptionsSchema,
|
|
539
550
|
document: documentOptionsSchema,
|
|
540
551
|
syntaxHighlighting: shikiOptionsSchema,
|
|
541
552
|
preamble: preambleOptionsSchema
|
|
@@ -682,7 +693,13 @@ function asciidocLoader(_options) {
|
|
|
682
693
|
const { config, logger, watcher } = loaderContext;
|
|
683
694
|
const root = config.root.pathname;
|
|
684
695
|
const base = options.base.startsWith(".") ? (0, import_node_fs4.realpathSync)(options.base) : root + options.base;
|
|
685
|
-
const docs = (0, import_node_fs4.readdirSync)(base, "utf8").filter((file) => file.match(/(?:\.a(?:scii)?doc)$/)).map((filename) =>
|
|
696
|
+
const docs = (0, import_node_fs4.readdirSync)(base, "utf8").filter((file) => file.match(/(?:\.a(?:scii)?doc)$/)).map((filename) => {
|
|
697
|
+
const doc = new AsciidocDocument(`${base}/${filename}`);
|
|
698
|
+
if (options.images?.imageUrl) {
|
|
699
|
+
doc.setAttribute("imagesdir", options.images.imageUrl);
|
|
700
|
+
}
|
|
701
|
+
return doc;
|
|
702
|
+
});
|
|
686
703
|
if (docs.length === 0) {
|
|
687
704
|
logger.warn("No documents found for this collection.");
|
|
688
705
|
return;
|
|
@@ -739,6 +756,12 @@ function asciidocLoader(_options) {
|
|
|
739
756
|
watcher.on("change", async (changedPath) => {
|
|
740
757
|
if (changedPath.match(watchedFileRegExp)) {
|
|
741
758
|
const newDoc = new AsciidocDocument(changedPath);
|
|
759
|
+
if (options.images?.imageUrl) {
|
|
760
|
+
newDoc.setAttribute(
|
|
761
|
+
"imagesdir",
|
|
762
|
+
options.images.imageUrl
|
|
763
|
+
);
|
|
764
|
+
}
|
|
742
765
|
await setDocument(
|
|
743
766
|
newDoc,
|
|
744
767
|
converters,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LoaderContext } from 'astro/loaders';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { a as AsciidocLoader } from './index-B1d5alka.cjs';
|
|
3
|
+
export { b as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-B1d5alka.cjs';
|
|
4
4
|
export { transformAsciidocCallout, transformerPrompt } from './lib/shiki/transformers/index.cjs';
|
|
5
5
|
import 'shiki';
|
|
6
6
|
import 'asciidoctor';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LoaderContext } from 'astro/loaders';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { a as AsciidocLoader } from './index-B1d5alka.js';
|
|
3
|
+
export { b as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-B1d5alka.js';
|
|
4
4
|
export { transformAsciidocCallout, transformerPrompt } from './lib/shiki/transformers/index.js';
|
|
5
5
|
import 'shiki';
|
|
6
6
|
import 'asciidoctor';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
HandlebarsEngine,
|
|
14
14
|
NunjucksEngine,
|
|
15
15
|
TemplateStr
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S7W7VGV4.js";
|
|
17
17
|
|
|
18
18
|
// src/loader.ts
|
|
19
19
|
import { readdirSync as readdirSync2, realpathSync } from "fs";
|
|
@@ -29,6 +29,7 @@ var BaseConverter = class {
|
|
|
29
29
|
this.customConverters = /* @__PURE__ */ new Map();
|
|
30
30
|
this.templateEngine = void 0;
|
|
31
31
|
}
|
|
32
|
+
defaultConverter;
|
|
32
33
|
customConverters;
|
|
33
34
|
templateEngine;
|
|
34
35
|
/**
|
|
@@ -259,6 +260,9 @@ var AsciidocDocument = class {
|
|
|
259
260
|
return acc.add(lang);
|
|
260
261
|
}, /* @__PURE__ */ new Set());
|
|
261
262
|
}
|
|
263
|
+
setAttribute(attribute, value) {
|
|
264
|
+
this.document.setAttribute(attribute, value);
|
|
265
|
+
}
|
|
262
266
|
convert(converters = [], templateEngine) {
|
|
263
267
|
converters.forEach((converter) => {
|
|
264
268
|
this.baseConverter.register(converter);
|
|
@@ -343,8 +347,13 @@ var preambleOptionsSchema = z3.object({
|
|
|
343
347
|
maxLevel: 3,
|
|
344
348
|
position: "after"
|
|
345
349
|
});
|
|
350
|
+
var imagesOptionsSchema = z3.object({
|
|
351
|
+
imageDir: z3.optional(z3.string()),
|
|
352
|
+
imageUrl: z3.optional(z3.string())
|
|
353
|
+
}).optional();
|
|
346
354
|
var loaderOptionsSchema = z3.object({
|
|
347
355
|
base: z3.string(),
|
|
356
|
+
images: imagesOptionsSchema,
|
|
348
357
|
document: documentOptionsSchema,
|
|
349
358
|
syntaxHighlighting: shikiOptionsSchema,
|
|
350
359
|
preamble: preambleOptionsSchema
|
|
@@ -392,7 +401,13 @@ function asciidocLoader(_options) {
|
|
|
392
401
|
const { config, logger, watcher } = loaderContext;
|
|
393
402
|
const root = config.root.pathname;
|
|
394
403
|
const base = options.base.startsWith(".") ? realpathSync(options.base) : root + options.base;
|
|
395
|
-
const docs = readdirSync2(base, "utf8").filter((file) => file.match(/(?:\.a(?:scii)?doc)$/)).map((filename) =>
|
|
404
|
+
const docs = readdirSync2(base, "utf8").filter((file) => file.match(/(?:\.a(?:scii)?doc)$/)).map((filename) => {
|
|
405
|
+
const doc = new AsciidocDocument(`${base}/${filename}`);
|
|
406
|
+
if (options.images?.imageUrl) {
|
|
407
|
+
doc.setAttribute("imagesdir", options.images.imageUrl);
|
|
408
|
+
}
|
|
409
|
+
return doc;
|
|
410
|
+
});
|
|
396
411
|
if (docs.length === 0) {
|
|
397
412
|
logger.warn("No documents found for this collection.");
|
|
398
413
|
return;
|
|
@@ -449,6 +464,12 @@ function asciidocLoader(_options) {
|
|
|
449
464
|
watcher.on("change", async (changedPath) => {
|
|
450
465
|
if (changedPath.match(watchedFileRegExp)) {
|
|
451
466
|
const newDoc = new AsciidocDocument(changedPath);
|
|
467
|
+
if (options.images?.imageUrl) {
|
|
468
|
+
newDoc.setAttribute(
|
|
469
|
+
"imagesdir",
|
|
470
|
+
options.images.imageUrl
|
|
471
|
+
);
|
|
472
|
+
}
|
|
452
473
|
await setDocument(
|
|
453
474
|
newDoc,
|
|
454
475
|
converters,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShikiTransformer } from 'shiki';
|
|
2
|
-
import { C as CustomConverterFactoryFn,
|
|
2
|
+
import { C as CustomConverterFactoryFn, c as ShikiTransformerFactoryFn } from '../../../index-B1d5alka.cjs';
|
|
3
3
|
import 'asciidoctor';
|
|
4
4
|
import 'astro/zod';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShikiTransformer } from 'shiki';
|
|
2
|
-
import { C as CustomConverterFactoryFn,
|
|
2
|
+
import { C as CustomConverterFactoryFn, c as ShikiTransformerFactoryFn } from '../../../index-B1d5alka.js';
|
|
3
3
|
import 'asciidoctor';
|
|
4
4
|
import 'astro/zod';
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AbstractEngine, b as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-B1d5alka.cjs';
|
|
2
2
|
import { AbstractBlock } from 'asciidoctor';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'astro/zod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AbstractEngine, b as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-B1d5alka.js';
|
|
2
2
|
import { AbstractBlock } from 'asciidoctor';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'astro/zod';
|
|
@@ -1,16 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as ShikiTransformerFactory } from '../../../index-B1d5alka.cjs';
|
|
2
2
|
import { BundledLanguage } from 'shiki';
|
|
3
3
|
import 'asciidoctor';
|
|
4
4
|
import 'astro/zod';
|
|
5
5
|
|
|
6
6
|
type PromptOptions = Partial<{
|
|
7
|
+
/**
|
|
8
|
+
* The string prefixed on every line of the code block. It's an empty
|
|
9
|
+
* string by default.
|
|
10
|
+
*
|
|
11
|
+
* @default ''
|
|
12
|
+
*/
|
|
7
13
|
prompt: string;
|
|
14
|
+
/**
|
|
15
|
+
* CSS classes to apply to the newly-inserted node containing the
|
|
16
|
+
* prompt. It's an empty string by default.
|
|
17
|
+
*
|
|
18
|
+
* @default ''
|
|
19
|
+
*/
|
|
8
20
|
cssClasses: string;
|
|
21
|
+
/**
|
|
22
|
+
* Allows to hide the prompt for the next line, if the current line
|
|
23
|
+
* ends with the given string. Use this to output, for example, multi
|
|
24
|
+
* line console commands.
|
|
25
|
+
*
|
|
26
|
+
* @default '\\'
|
|
27
|
+
*/
|
|
9
28
|
breakOn: string;
|
|
29
|
+
/**
|
|
30
|
+
* If the current line ends with a `breakOn` string sequence, this
|
|
31
|
+
* option determines whether the newline break should be hidden from
|
|
32
|
+
* the output or not. For multi-line console commands you may want to
|
|
33
|
+
* display the "\" delimiter for clarity, but other consoles,
|
|
34
|
+
* interpreters, or REPLs might look better with this out of the way.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
10
38
|
hideBreak: boolean;
|
|
11
39
|
}>;
|
|
12
40
|
type TransformerOptions$1 = PromptOptions & Partial<{
|
|
41
|
+
/**
|
|
42
|
+
* Specify options on a per language basis. These take precedence
|
|
43
|
+
* over the options applied to all languages. Or, instead of a whole
|
|
44
|
+
* object, provide a string as a shortcut for the `prompt` option.
|
|
45
|
+
*/
|
|
13
46
|
langs: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
47
|
+
/**
|
|
48
|
+
* If the source AsciiDoc node being processed includes this custom
|
|
49
|
+
* attribue, it will be read and used as the `prompt` for this code
|
|
50
|
+
* block. This takes the most precedence over other prompt options.
|
|
51
|
+
*/
|
|
14
52
|
promptAttribute: string;
|
|
15
53
|
}>;
|
|
16
54
|
declare const transformerPrompt: ShikiTransformerFactory<TransformerOptions$1>;
|
|
@@ -1,16 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as ShikiTransformerFactory } from '../../../index-B1d5alka.js';
|
|
2
2
|
import { BundledLanguage } from 'shiki';
|
|
3
3
|
import 'asciidoctor';
|
|
4
4
|
import 'astro/zod';
|
|
5
5
|
|
|
6
6
|
type PromptOptions = Partial<{
|
|
7
|
+
/**
|
|
8
|
+
* The string prefixed on every line of the code block. It's an empty
|
|
9
|
+
* string by default.
|
|
10
|
+
*
|
|
11
|
+
* @default ''
|
|
12
|
+
*/
|
|
7
13
|
prompt: string;
|
|
14
|
+
/**
|
|
15
|
+
* CSS classes to apply to the newly-inserted node containing the
|
|
16
|
+
* prompt. It's an empty string by default.
|
|
17
|
+
*
|
|
18
|
+
* @default ''
|
|
19
|
+
*/
|
|
8
20
|
cssClasses: string;
|
|
21
|
+
/**
|
|
22
|
+
* Allows to hide the prompt for the next line, if the current line
|
|
23
|
+
* ends with the given string. Use this to output, for example, multi
|
|
24
|
+
* line console commands.
|
|
25
|
+
*
|
|
26
|
+
* @default '\\'
|
|
27
|
+
*/
|
|
9
28
|
breakOn: string;
|
|
29
|
+
/**
|
|
30
|
+
* If the current line ends with a `breakOn` string sequence, this
|
|
31
|
+
* option determines whether the newline break should be hidden from
|
|
32
|
+
* the output or not. For multi-line console commands you may want to
|
|
33
|
+
* display the "\" delimiter for clarity, but other consoles,
|
|
34
|
+
* interpreters, or REPLs might look better with this out of the way.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
10
38
|
hideBreak: boolean;
|
|
11
39
|
}>;
|
|
12
40
|
type TransformerOptions$1 = PromptOptions & Partial<{
|
|
41
|
+
/**
|
|
42
|
+
* Specify options on a per language basis. These take precedence
|
|
43
|
+
* over the options applied to all languages. Or, instead of a whole
|
|
44
|
+
* object, provide a string as a shortcut for the `prompt` option.
|
|
45
|
+
*/
|
|
13
46
|
langs: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
47
|
+
/**
|
|
48
|
+
* If the source AsciiDoc node being processed includes this custom
|
|
49
|
+
* attribue, it will be read and used as the `prompt` for this code
|
|
50
|
+
* block. This takes the most precedence over other prompt options.
|
|
51
|
+
*/
|
|
14
52
|
promptAttribute: string;
|
|
15
53
|
}>;
|
|
16
54
|
declare const transformerPrompt: ShikiTransformerFactory<TransformerOptions$1>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d10f/asciidoc-astro-loader",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "An Astro collections loader for Asciidoc files",
|
|
5
5
|
"author": "D10f",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"./transformers": "./dist/lib/shiki/transformers/index.js"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"
|
|
39
|
+
"@types/node": "^25.9.1",
|
|
40
|
+
"astro": "^6.3.1",
|
|
40
41
|
"eslint": "^9.36.0",
|
|
41
42
|
"eslint-plugin-prettier": "^5.5.4",
|
|
42
43
|
"globals": "^16.4.0",
|
|
@@ -46,14 +47,14 @@
|
|
|
46
47
|
"tsup": "^8.5.0",
|
|
47
48
|
"typescript": "^5.9.3",
|
|
48
49
|
"typescript-eslint": "^8.45.0",
|
|
49
|
-
"vitest": "^
|
|
50
|
+
"vitest": "^5.0.3"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@shikijs/transformers": "^
|
|
53
|
+
"@shikijs/transformers": "^4.5.0",
|
|
53
54
|
"asciidoctor": "^3.0.4",
|
|
54
|
-
"shiki": "^
|
|
55
|
+
"shiki": "^4.5.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"astro": "^
|
|
58
|
+
"astro": "^6.3.1"
|
|
58
59
|
}
|
|
59
60
|
}
|