@d10f/asciidoc-astro-loader 0.0.15 → 0.1.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 +3 -2
- package/dist/{chunk-5LUVP7HW.js → chunk-S7W7VGV4.js} +2 -0
- package/dist/{chunk-4JCAN3ZN.js → chunk-TCLZUBH3.js} +42 -28
- 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 +66 -29
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +24 -3
- 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.cjs +42 -28
- package/dist/lib/shiki/transformers/index.d.cts +38 -38
- package/dist/lib/shiki/transformers/index.d.ts +38 -38
- package/dist/lib/shiki/transformers/index.js +1 -1
- package/package.json +4 -3
|
@@ -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,
|
|
@@ -785,43 +808,57 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
785
808
|
}
|
|
786
809
|
|
|
787
810
|
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
788
|
-
var
|
|
811
|
+
var DEFAULT_OPTS = {
|
|
812
|
+
breakOn: "\\",
|
|
813
|
+
cssClasses: "",
|
|
814
|
+
hideBreak: false,
|
|
815
|
+
prompt: "",
|
|
816
|
+
promptAttribute: "custom-prompt"
|
|
817
|
+
};
|
|
818
|
+
var transformerPrompt = (opts) => {
|
|
789
819
|
return (node) => {
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
820
|
+
const config = {
|
|
821
|
+
breakOn: opts?.breakOn ?? DEFAULT_OPTS.breakOn,
|
|
822
|
+
cssClasses: opts?.cssClasses ?? DEFAULT_OPTS.cssClasses,
|
|
823
|
+
hideBreak: opts?.hideBreak ?? DEFAULT_OPTS.hideBreak,
|
|
824
|
+
prompt: opts?.prompt ?? DEFAULT_OPTS.prompt
|
|
825
|
+
};
|
|
826
|
+
if (opts && opts.langs) {
|
|
827
|
+
const lang = node.getAttribute("language");
|
|
828
|
+
const langOpts = opts.langs[lang];
|
|
829
|
+
Object.assign(
|
|
830
|
+
config,
|
|
831
|
+
typeof langOpts === "object" ? langOpts : { prompt: langOpts }
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
const promptAttr = node.getAttribute(
|
|
835
|
+
opts?.promptAttribute ?? DEFAULT_OPTS.promptAttribute
|
|
793
836
|
);
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
837
|
+
if (promptAttr) {
|
|
838
|
+
Object.assign(config, {
|
|
839
|
+
prompt: promptAttr
|
|
840
|
+
});
|
|
841
|
+
}
|
|
797
842
|
const breakOnRe = new RegExp(
|
|
798
|
-
`\\s+${escapeRegexCharacters(breakOn)}\\s*$`
|
|
843
|
+
`\\s+${escapeRegexCharacters(config.breakOn)}\\s*$`
|
|
799
844
|
);
|
|
800
|
-
const hideBreak = options?.langs && options.langs[language] && typeof options.langs[language] === "object" && options.langs[language].hideBreak;
|
|
801
|
-
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
802
|
-
cssClasses = options.langs[language].cssClasses;
|
|
803
|
-
}
|
|
804
845
|
let skipNext = false;
|
|
846
|
+
let skipCurrent = false;
|
|
805
847
|
return {
|
|
806
848
|
enforce: "pre",
|
|
807
849
|
line(hast) {
|
|
808
|
-
if (!
|
|
809
|
-
|
|
850
|
+
if (!config.prompt || !config.prompt.trim()) return;
|
|
851
|
+
skipCurrent = skipNext;
|
|
810
852
|
skipNext = false;
|
|
811
853
|
const lastChild = hast.children.at(-1);
|
|
812
|
-
const lastToken = lastChild
|
|
813
|
-
if (
|
|
854
|
+
const lastToken = lastChild?.children[0];
|
|
855
|
+
if (lastToken) {
|
|
814
856
|
skipNext = breakOnRe.test(lastToken.value);
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
lastChild.children[0].value.replace(
|
|
821
|
-
breakOnRe,
|
|
822
|
-
""
|
|
823
|
-
);
|
|
824
|
-
}
|
|
857
|
+
if (skipNext && config.hideBreak) {
|
|
858
|
+
lastToken.value = lastToken.value.replace(
|
|
859
|
+
breakOnRe,
|
|
860
|
+
""
|
|
861
|
+
);
|
|
825
862
|
}
|
|
826
863
|
}
|
|
827
864
|
if (skipCurrent) return;
|
|
@@ -829,12 +866,12 @@ var transformerPrompt = (options) => {
|
|
|
829
866
|
type: "element",
|
|
830
867
|
tagName: "span",
|
|
831
868
|
properties: {
|
|
832
|
-
class: cssClasses
|
|
869
|
+
class: config.cssClasses
|
|
833
870
|
},
|
|
834
871
|
children: [
|
|
835
872
|
{
|
|
836
873
|
type: "text",
|
|
837
|
-
value:
|
|
874
|
+
value: config.prompt
|
|
838
875
|
}
|
|
839
876
|
]
|
|
840
877
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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';
|
|
7
7
|
import 'astro/zod';
|
|
8
|
-
import 'shiki/types';
|
|
9
8
|
|
|
10
9
|
declare function asciidocLoader(_options: AsciidocLoader): {
|
|
11
10
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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';
|
|
7
7
|
import 'astro/zod';
|
|
8
|
-
import 'shiki/types';
|
|
9
8
|
|
|
10
9
|
declare function asciidocLoader(_options: AsciidocLoader): {
|
|
11
10
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
transformAsciidocCallout,
|
|
6
6
|
transformerPrompt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TCLZUBH3.js";
|
|
8
8
|
import {
|
|
9
9
|
slugify,
|
|
10
10
|
splitFilenameComponents
|
|
@@ -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';
|