@d10f/asciidoc-astro-loader 0.0.7 → 0.0.9
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/dist/{chunk-HVA4AVUD.js → chunk-5LUVP7HW.js} +12 -8
- package/dist/{chunk-5P6LDJGO.js → chunk-IWQC3MJM.js} +36 -2
- package/dist/{index-CS3PBqxf.d.cts → index-DwboxIUQ.d.cts} +3 -3
- package/dist/{index-CS3PBqxf.d.ts → index-DwboxIUQ.d.ts} +3 -3
- package/dist/index.cjs +56 -16
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +11 -9
- 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 +12 -8
- package/dist/lib/asciidoc/templates/engines/index.d.cts +3 -3
- package/dist/lib/asciidoc/templates/engines/index.d.ts +3 -3
- package/dist/lib/asciidoc/templates/engines/index.js +1 -1
- package/dist/lib/shiki/transformers/index.cjs +5 -2
- package/dist/lib/shiki/transformers/index.d.cts +6 -6
- package/dist/lib/shiki/transformers/index.d.ts +6 -6
- package/dist/lib/shiki/transformers/index.js +3 -32
- package/package.json +2 -2
|
@@ -75,11 +75,13 @@ var HandlebarsEngine = class extends AbstractEngine {
|
|
|
75
75
|
super(name, extensions);
|
|
76
76
|
this.render = null;
|
|
77
77
|
}
|
|
78
|
-
async load() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
async load(force = false) {
|
|
79
|
+
if (this.templateList.size > 0 || force) {
|
|
80
|
+
const Handlebars = await import("handlebars");
|
|
81
|
+
this.render = (input, opts) => {
|
|
82
|
+
return Handlebars.default.compile(input)(opts);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
renderNode(node, options = {}) {
|
|
85
87
|
const context = node.getNodeName();
|
|
@@ -105,9 +107,11 @@ var NunjucksEngine = class extends AbstractEngine {
|
|
|
105
107
|
super(name, extensions);
|
|
106
108
|
this.render = null;
|
|
107
109
|
}
|
|
108
|
-
async load() {
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
async load(force = false) {
|
|
111
|
+
if (this.templateList.size > 0 || force) {
|
|
112
|
+
const nunjucks = await import("nunjucks");
|
|
113
|
+
this.render = nunjucks.default.renderString;
|
|
114
|
+
}
|
|
111
115
|
}
|
|
112
116
|
renderNode(node, options = {}) {
|
|
113
117
|
const context = node.getNodeName();
|
|
@@ -44,7 +44,7 @@ var transformAsciidocCallout = (options) => {
|
|
|
44
44
|
tagName: "span",
|
|
45
45
|
properties: {
|
|
46
46
|
class: options?.cssClasses ?? "conum",
|
|
47
|
-
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;
|
|
47
|
+
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;",
|
|
48
48
|
"data-value": calloutId
|
|
49
49
|
},
|
|
50
50
|
children: [
|
|
@@ -60,6 +60,40 @@ var transformAsciidocCallout = (options) => {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
64
|
+
var transformerPrompt = (options) => {
|
|
65
|
+
return (node) => {
|
|
66
|
+
const language = node.getAttribute("language");
|
|
67
|
+
const customPrompt = node.getAttribute(
|
|
68
|
+
options?.promptAttribute ?? "custom-prompt"
|
|
69
|
+
);
|
|
70
|
+
const promptToAdd = customPrompt ?? (options?.langs && options.langs[language]);
|
|
71
|
+
let cssClasses = typeof promptToAdd === "object" ? promptToAdd.cssClasses : options?.cssClasses;
|
|
72
|
+
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
73
|
+
cssClasses = options.langs[language].cssClasses;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
line(hast) {
|
|
77
|
+
if (!promptToAdd) return;
|
|
78
|
+
hast.children.unshift({
|
|
79
|
+
type: "element",
|
|
80
|
+
tagName: "span",
|
|
81
|
+
properties: {
|
|
82
|
+
class: cssClasses
|
|
83
|
+
},
|
|
84
|
+
children: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
value: typeof promptToAdd === "object" ? promptToAdd.prompt : promptToAdd
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
63
96
|
export {
|
|
64
|
-
transformAsciidocCallout
|
|
97
|
+
transformAsciidocCallout,
|
|
98
|
+
transformerPrompt
|
|
65
99
|
};
|
|
@@ -489,7 +489,7 @@ type AsciidocLoader = {
|
|
|
489
489
|
/**
|
|
490
490
|
* A list of transformers to apply for source code blocks.
|
|
491
491
|
*
|
|
492
|
-
* @default [
|
|
492
|
+
* @default [ transformAsciidocCallout ]
|
|
493
493
|
*/
|
|
494
494
|
transformers: Array<ShikiTransformer | ShikiTransformerFactoryFn>;
|
|
495
495
|
callouts: Partial<{
|
|
@@ -517,7 +517,7 @@ interface TemplateModule {
|
|
|
517
517
|
/**
|
|
518
518
|
* Loader function to import third-party modules asynchronously.
|
|
519
519
|
*/
|
|
520
|
-
load(): Promise<void>;
|
|
520
|
+
load(force?: boolean): Promise<void>;
|
|
521
521
|
}
|
|
522
522
|
/**
|
|
523
523
|
* Interface used by the default template engine, which can handle
|
|
@@ -542,4 +542,4 @@ interface RawTemplate {
|
|
|
542
542
|
renderString(content: string, options?: Record<string, unknown>): string;
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
export { type AsciidocLoader as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactoryFn as S, type TemplateModule as T, type AsciidocTemplate as a,
|
|
545
|
+
export { type AsciidocLoader as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactoryFn as S, type TemplateModule as T, type AsciidocTemplate as a, AbstractEngine as b, type ShikiTransformerFactory as c };
|
|
@@ -489,7 +489,7 @@ type AsciidocLoader = {
|
|
|
489
489
|
/**
|
|
490
490
|
* A list of transformers to apply for source code blocks.
|
|
491
491
|
*
|
|
492
|
-
* @default [
|
|
492
|
+
* @default [ transformAsciidocCallout ]
|
|
493
493
|
*/
|
|
494
494
|
transformers: Array<ShikiTransformer | ShikiTransformerFactoryFn>;
|
|
495
495
|
callouts: Partial<{
|
|
@@ -517,7 +517,7 @@ interface TemplateModule {
|
|
|
517
517
|
/**
|
|
518
518
|
* Loader function to import third-party modules asynchronously.
|
|
519
519
|
*/
|
|
520
|
-
load(): Promise<void>;
|
|
520
|
+
load(force?: boolean): Promise<void>;
|
|
521
521
|
}
|
|
522
522
|
/**
|
|
523
523
|
* Interface used by the default template engine, which can handle
|
|
@@ -542,4 +542,4 @@ interface RawTemplate {
|
|
|
542
542
|
renderString(content: string, options?: Record<string, unknown>): string;
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
export { type AsciidocLoader as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactoryFn as S, type TemplateModule as T, type AsciidocTemplate as a,
|
|
545
|
+
export { type AsciidocLoader as A, type CustomConverterFactoryFn as C, type FilesystemTemplate as F, type NodeContext as N, type RawTemplate as R, type ShikiTransformerFactoryFn as S, type TemplateModule as T, type AsciidocTemplate as a, AbstractEngine as b, type ShikiTransformerFactory as c };
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
asciidocLoader: () => asciidocLoader
|
|
33
|
+
asciidocLoader: () => asciidocLoader,
|
|
34
|
+
transformAsciidocCallout: () => transformAsciidocCallout,
|
|
35
|
+
transformerPrompt: () => transformerPrompt
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(index_exports);
|
|
36
38
|
|
|
@@ -172,11 +174,10 @@ var TemplateEngineRegistry = class _TemplateEngineRegistry {
|
|
|
172
174
|
* Asynchronously loads the necessary third party modules.
|
|
173
175
|
*/
|
|
174
176
|
async loadEngines() {
|
|
175
|
-
_TemplateEngineRegistry.modules.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
177
|
+
const promises = _TemplateEngineRegistry.modules.map(
|
|
178
|
+
async (m) => m.canLoad && m.load()
|
|
179
|
+
);
|
|
180
|
+
await Promise.all(promises);
|
|
180
181
|
}
|
|
181
182
|
/**
|
|
182
183
|
* Returns the module with the given name.
|
|
@@ -375,11 +376,13 @@ var HandlebarsEngine = class extends AbstractEngine {
|
|
|
375
376
|
super(name, extensions);
|
|
376
377
|
this.render = null;
|
|
377
378
|
}
|
|
378
|
-
async load() {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
async load(force = false) {
|
|
380
|
+
if (this.templateList.size > 0 || force) {
|
|
381
|
+
const Handlebars = await import("handlebars");
|
|
382
|
+
this.render = (input, opts) => {
|
|
383
|
+
return Handlebars.default.compile(input)(opts);
|
|
384
|
+
};
|
|
385
|
+
}
|
|
383
386
|
}
|
|
384
387
|
renderNode(node, options = {}) {
|
|
385
388
|
const context = node.getNodeName();
|
|
@@ -405,9 +408,11 @@ var NunjucksEngine = class extends AbstractEngine {
|
|
|
405
408
|
super(name, extensions);
|
|
406
409
|
this.render = null;
|
|
407
410
|
}
|
|
408
|
-
async load() {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
+
async load(force = false) {
|
|
412
|
+
if (this.templateList.size > 0 || force) {
|
|
413
|
+
const nunjucks = await import("nunjucks");
|
|
414
|
+
this.render = nunjucks.default.renderString;
|
|
415
|
+
}
|
|
411
416
|
}
|
|
412
417
|
renderNode(node, options = {}) {
|
|
413
418
|
const context = node.getNodeName();
|
|
@@ -628,7 +633,7 @@ var transformAsciidocCallout = (options) => {
|
|
|
628
633
|
tagName: "span",
|
|
629
634
|
properties: {
|
|
630
635
|
class: options?.cssClasses ?? "conum",
|
|
631
|
-
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;
|
|
636
|
+
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;",
|
|
632
637
|
"data-value": calloutId
|
|
633
638
|
},
|
|
634
639
|
children: [
|
|
@@ -765,7 +770,42 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
765
770
|
}
|
|
766
771
|
});
|
|
767
772
|
}
|
|
773
|
+
|
|
774
|
+
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
775
|
+
var transformerPrompt = (options) => {
|
|
776
|
+
return (node) => {
|
|
777
|
+
const language = node.getAttribute("language");
|
|
778
|
+
const customPrompt = node.getAttribute(
|
|
779
|
+
options?.promptAttribute ?? "custom-prompt"
|
|
780
|
+
);
|
|
781
|
+
const promptToAdd = customPrompt ?? (options?.langs && options.langs[language]);
|
|
782
|
+
let cssClasses = typeof promptToAdd === "object" ? promptToAdd.cssClasses : options?.cssClasses;
|
|
783
|
+
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
784
|
+
cssClasses = options.langs[language].cssClasses;
|
|
785
|
+
}
|
|
786
|
+
return {
|
|
787
|
+
line(hast) {
|
|
788
|
+
if (!promptToAdd) return;
|
|
789
|
+
hast.children.unshift({
|
|
790
|
+
type: "element",
|
|
791
|
+
tagName: "span",
|
|
792
|
+
properties: {
|
|
793
|
+
class: cssClasses
|
|
794
|
+
},
|
|
795
|
+
children: [
|
|
796
|
+
{
|
|
797
|
+
type: "text",
|
|
798
|
+
value: typeof promptToAdd === "object" ? promptToAdd.prompt : promptToAdd
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
};
|
|
768
806
|
// Annotate the CommonJS export names for ESM import in node:
|
|
769
807
|
0 && (module.exports = {
|
|
770
|
-
asciidocLoader
|
|
808
|
+
asciidocLoader,
|
|
809
|
+
transformAsciidocCallout,
|
|
810
|
+
transformerPrompt
|
|
771
811
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LoaderContext } from 'astro/loaders';
|
|
2
|
-
import { A as AsciidocLoader } from './index-
|
|
3
|
-
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-
|
|
2
|
+
import { A as AsciidocLoader } from './index-DwboxIUQ.cjs';
|
|
3
|
+
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-DwboxIUQ.cjs';
|
|
4
|
+
export { transformAsciidocCallout, transformerPrompt } from './lib/shiki/transformers/index.cjs';
|
|
4
5
|
import 'shiki';
|
|
5
6
|
import 'asciidoctor';
|
|
6
7
|
import 'astro/zod';
|
|
8
|
+
import 'shiki/types';
|
|
7
9
|
|
|
8
10
|
declare function asciidocLoader(_options: AsciidocLoader): {
|
|
9
11
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LoaderContext } from 'astro/loaders';
|
|
2
|
-
import { A as AsciidocLoader } from './index-
|
|
3
|
-
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-
|
|
2
|
+
import { A as AsciidocLoader } from './index-DwboxIUQ.js';
|
|
3
|
+
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-DwboxIUQ.js';
|
|
4
|
+
export { transformAsciidocCallout, transformerPrompt } from './lib/shiki/transformers/index.js';
|
|
4
5
|
import 'shiki';
|
|
5
6
|
import 'asciidoctor';
|
|
6
7
|
import 'astro/zod';
|
|
8
|
+
import 'shiki/types';
|
|
7
9
|
|
|
8
10
|
declare function asciidocLoader(_options: AsciidocLoader): {
|
|
9
11
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
sourceCodeConverter
|
|
3
3
|
} from "./chunk-NC6IZHLR.js";
|
|
4
4
|
import {
|
|
5
|
-
transformAsciidocCallout
|
|
6
|
-
|
|
5
|
+
transformAsciidocCallout,
|
|
6
|
+
transformerPrompt
|
|
7
|
+
} from "./chunk-IWQC3MJM.js";
|
|
7
8
|
import {
|
|
8
9
|
slugify,
|
|
9
10
|
splitFilenameComponents
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
HandlebarsEngine,
|
|
13
14
|
NunjucksEngine,
|
|
14
15
|
TemplateStr
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-5LUVP7HW.js";
|
|
16
17
|
|
|
17
18
|
// src/loader.ts
|
|
18
19
|
import { readdirSync as readdirSync2, realpathSync } from "fs";
|
|
@@ -135,11 +136,10 @@ var TemplateEngineRegistry = class _TemplateEngineRegistry {
|
|
|
135
136
|
* Asynchronously loads the necessary third party modules.
|
|
136
137
|
*/
|
|
137
138
|
async loadEngines() {
|
|
138
|
-
_TemplateEngineRegistry.modules.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
});
|
|
139
|
+
const promises = _TemplateEngineRegistry.modules.map(
|
|
140
|
+
async (m) => m.canLoad && m.load()
|
|
141
|
+
);
|
|
142
|
+
await Promise.all(promises);
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* Returns the module with the given name.
|
|
@@ -482,5 +482,7 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
export {
|
|
485
|
-
asciidocLoader
|
|
485
|
+
asciidocLoader,
|
|
486
|
+
transformAsciidocCallout,
|
|
487
|
+
transformerPrompt
|
|
486
488
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShikiTransformer } from 'shiki';
|
|
2
|
-
import { C as CustomConverterFactoryFn, S as ShikiTransformerFactoryFn } from '../../../index-
|
|
2
|
+
import { C as CustomConverterFactoryFn, S as ShikiTransformerFactoryFn } from '../../../index-DwboxIUQ.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, S as ShikiTransformerFactoryFn } from '../../../index-
|
|
2
|
+
import { C as CustomConverterFactoryFn, S as ShikiTransformerFactoryFn } from '../../../index-DwboxIUQ.js';
|
|
3
3
|
import 'asciidoctor';
|
|
4
4
|
import 'astro/zod';
|
|
5
5
|
|
|
@@ -114,11 +114,13 @@ var HandlebarsEngine = class extends AbstractEngine {
|
|
|
114
114
|
super(name, extensions);
|
|
115
115
|
this.render = null;
|
|
116
116
|
}
|
|
117
|
-
async load() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
async load(force = false) {
|
|
118
|
+
if (this.templateList.size > 0 || force) {
|
|
119
|
+
const Handlebars = await import("handlebars");
|
|
120
|
+
this.render = (input, opts) => {
|
|
121
|
+
return Handlebars.default.compile(input)(opts);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
renderNode(node, options = {}) {
|
|
124
126
|
const context = node.getNodeName();
|
|
@@ -144,9 +146,11 @@ var NunjucksEngine = class extends AbstractEngine {
|
|
|
144
146
|
super(name, extensions);
|
|
145
147
|
this.render = null;
|
|
146
148
|
}
|
|
147
|
-
async load() {
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
async load(force = false) {
|
|
150
|
+
if (this.templateList.size > 0 || force) {
|
|
151
|
+
const nunjucks = await import("nunjucks");
|
|
152
|
+
this.render = nunjucks.default.renderString;
|
|
153
|
+
}
|
|
150
154
|
}
|
|
151
155
|
renderNode(node, options = {}) {
|
|
152
156
|
const context = node.getNodeName();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-DwboxIUQ.cjs';
|
|
2
2
|
import { AbstractBlock } from 'asciidoctor';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'astro/zod';
|
|
@@ -6,7 +6,7 @@ import 'astro/zod';
|
|
|
6
6
|
declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
7
7
|
private render;
|
|
8
8
|
constructor(name?: string, extensions?: string[]);
|
|
9
|
-
load(): Promise<void>;
|
|
9
|
+
load(force?: boolean): Promise<void>;
|
|
10
10
|
renderNode(node: AbstractBlock, options?: Record<string, unknown>): string;
|
|
11
11
|
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
12
12
|
renderString(str: string, options?: Record<string, unknown>): string;
|
|
@@ -15,7 +15,7 @@ declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplat
|
|
|
15
15
|
declare class NunjucksEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
16
16
|
private render;
|
|
17
17
|
constructor(name?: string, extensions?: string[]);
|
|
18
|
-
load(): Promise<void>;
|
|
18
|
+
load(force?: boolean): Promise<void>;
|
|
19
19
|
renderNode(node: AbstractBlock, options?: Record<string, unknown>): string;
|
|
20
20
|
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
21
21
|
renderString(str: string, options?: Record<string, unknown>): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-DwboxIUQ.js';
|
|
2
2
|
import { AbstractBlock } from 'asciidoctor';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'astro/zod';
|
|
@@ -6,7 +6,7 @@ import 'astro/zod';
|
|
|
6
6
|
declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
7
7
|
private render;
|
|
8
8
|
constructor(name?: string, extensions?: string[]);
|
|
9
|
-
load(): Promise<void>;
|
|
9
|
+
load(force?: boolean): Promise<void>;
|
|
10
10
|
renderNode(node: AbstractBlock, options?: Record<string, unknown>): string;
|
|
11
11
|
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
12
12
|
renderString(str: string, options?: Record<string, unknown>): string;
|
|
@@ -15,7 +15,7 @@ declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplat
|
|
|
15
15
|
declare class NunjucksEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
16
16
|
private render;
|
|
17
17
|
constructor(name?: string, extensions?: string[]);
|
|
18
|
-
load(): Promise<void>;
|
|
18
|
+
load(force?: boolean): Promise<void>;
|
|
19
19
|
renderNode(node: AbstractBlock, options?: Record<string, unknown>): string;
|
|
20
20
|
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
21
21
|
renderString(str: string, options?: Record<string, unknown>): string;
|
|
@@ -73,7 +73,7 @@ var transformAsciidocCallout = (options) => {
|
|
|
73
73
|
tagName: "span",
|
|
74
74
|
properties: {
|
|
75
75
|
class: options?.cssClasses ?? "conum",
|
|
76
|
-
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;
|
|
76
|
+
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;",
|
|
77
77
|
"data-value": calloutId
|
|
78
78
|
},
|
|
79
79
|
children: [
|
|
@@ -97,7 +97,10 @@ var transformerPrompt = (options) => {
|
|
|
97
97
|
options?.promptAttribute ?? "custom-prompt"
|
|
98
98
|
);
|
|
99
99
|
const promptToAdd = customPrompt ?? (options?.langs && options.langs[language]);
|
|
100
|
-
|
|
100
|
+
let cssClasses = typeof promptToAdd === "object" ? promptToAdd.cssClasses : options?.cssClasses;
|
|
101
|
+
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
102
|
+
cssClasses = options.langs[language].cssClasses;
|
|
103
|
+
}
|
|
101
104
|
return {
|
|
102
105
|
line(hast) {
|
|
103
106
|
if (!promptToAdd) return;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as ShikiTransformerFactory } from '../../../index-DwboxIUQ.cjs';
|
|
2
2
|
import { BundledLanguage } from 'shiki/types';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'asciidoctor';
|
|
5
5
|
import 'astro/zod';
|
|
6
6
|
|
|
7
|
-
type TransformerOptions = Partial<{
|
|
8
|
-
cssClasses?: string;
|
|
9
|
-
}>;
|
|
10
|
-
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
11
|
-
|
|
12
7
|
type PromptOptions = {
|
|
13
8
|
prompt: string;
|
|
14
9
|
cssClasses: string;
|
|
@@ -37,4 +32,9 @@ type TransformOptions = {
|
|
|
37
32
|
};
|
|
38
33
|
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
39
34
|
|
|
35
|
+
type TransformerOptions = Partial<{
|
|
36
|
+
cssClasses?: string;
|
|
37
|
+
}>;
|
|
38
|
+
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
39
|
+
|
|
40
40
|
export { transformAsciidocCallout, transformerPrompt };
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as ShikiTransformerFactory } from '../../../index-DwboxIUQ.js';
|
|
2
2
|
import { BundledLanguage } from 'shiki/types';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'asciidoctor';
|
|
5
5
|
import 'astro/zod';
|
|
6
6
|
|
|
7
|
-
type TransformerOptions = Partial<{
|
|
8
|
-
cssClasses?: string;
|
|
9
|
-
}>;
|
|
10
|
-
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
11
|
-
|
|
12
7
|
type PromptOptions = {
|
|
13
8
|
prompt: string;
|
|
14
9
|
cssClasses: string;
|
|
@@ -37,4 +32,9 @@ type TransformOptions = {
|
|
|
37
32
|
};
|
|
38
33
|
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
39
34
|
|
|
35
|
+
type TransformerOptions = Partial<{
|
|
36
|
+
cssClasses?: string;
|
|
37
|
+
}>;
|
|
38
|
+
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
39
|
+
|
|
40
40
|
export { transformAsciidocCallout, transformerPrompt };
|
|
@@ -1,37 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
transformAsciidocCallout
|
|
3
|
-
|
|
2
|
+
transformAsciidocCallout,
|
|
3
|
+
transformerPrompt
|
|
4
|
+
} from "../../../chunk-IWQC3MJM.js";
|
|
4
5
|
import "../../../chunk-2UGTFP4R.js";
|
|
5
|
-
|
|
6
|
-
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
7
|
-
var transformerPrompt = (options) => {
|
|
8
|
-
return (node) => {
|
|
9
|
-
const language = node.getAttribute("language");
|
|
10
|
-
const customPrompt = node.getAttribute(
|
|
11
|
-
options?.promptAttribute ?? "custom-prompt"
|
|
12
|
-
);
|
|
13
|
-
const promptToAdd = customPrompt ?? (options?.langs && options.langs[language]);
|
|
14
|
-
const cssClasses = typeof promptToAdd === "object" ? promptToAdd.cssClasses : options?.cssClasses;
|
|
15
|
-
return {
|
|
16
|
-
line(hast) {
|
|
17
|
-
if (!promptToAdd) return;
|
|
18
|
-
hast.children.unshift({
|
|
19
|
-
type: "element",
|
|
20
|
-
tagName: "span",
|
|
21
|
-
properties: {
|
|
22
|
-
class: cssClasses
|
|
23
|
-
},
|
|
24
|
-
children: [
|
|
25
|
-
{
|
|
26
|
-
type: "text",
|
|
27
|
-
value: typeof promptToAdd === "object" ? promptToAdd.prompt : promptToAdd
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
6
|
export {
|
|
36
7
|
transformAsciidocCallout,
|
|
37
8
|
transformerPrompt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d10f/asciidoc-astro-loader",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "An Astro collections loader for Asciidoc files",
|
|
5
5
|
"author": "D10f",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@shikijs/transformers": "^3.20.0",
|
|
53
53
|
"asciidoctor": "^3.0.4",
|
|
54
|
-
"shiki": "^3.
|
|
54
|
+
"shiki": "^3.20.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"astro": "^5.0.0"
|