@d10f/asciidoc-astro-loader 0.0.7 → 0.0.8
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-PY1MiQbP.d.cts} +1 -1
- package/dist/{index-CS3PBqxf.d.ts → index-PY1MiQbP.d.ts} +1 -1
- package/dist/index.cjs +54 -16
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +10 -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 +4 -31
- package/dist/lib/shiki/transformers/index.d.ts +4 -31
- package/dist/lib/shiki/transformers/index.js +3 -32
- package/dist/transformerPrompt-DfCRhAD2.d.ts +32 -0
- package/dist/transformerPrompt-n_gHpQ3r.d.cts +32 -0
- package/package.json +1 -1
|
@@ -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
|
};
|
|
@@ -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
|
|
@@ -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
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,8 @@ 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
|
+
transformerPrompt: () => transformerPrompt
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(index_exports);
|
|
36
37
|
|
|
@@ -172,11 +173,10 @@ var TemplateEngineRegistry = class _TemplateEngineRegistry {
|
|
|
172
173
|
* Asynchronously loads the necessary third party modules.
|
|
173
174
|
*/
|
|
174
175
|
async loadEngines() {
|
|
175
|
-
_TemplateEngineRegistry.modules.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
176
|
+
const promises = _TemplateEngineRegistry.modules.map(
|
|
177
|
+
async (m) => m.canLoad && m.load()
|
|
178
|
+
);
|
|
179
|
+
await Promise.all(promises);
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Returns the module with the given name.
|
|
@@ -375,11 +375,13 @@ var HandlebarsEngine = class extends AbstractEngine {
|
|
|
375
375
|
super(name, extensions);
|
|
376
376
|
this.render = null;
|
|
377
377
|
}
|
|
378
|
-
async load() {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
async load(force = false) {
|
|
379
|
+
if (this.templateList.size > 0 || force) {
|
|
380
|
+
const Handlebars = await import("handlebars");
|
|
381
|
+
this.render = (input, opts) => {
|
|
382
|
+
return Handlebars.default.compile(input)(opts);
|
|
383
|
+
};
|
|
384
|
+
}
|
|
383
385
|
}
|
|
384
386
|
renderNode(node, options = {}) {
|
|
385
387
|
const context = node.getNodeName();
|
|
@@ -405,9 +407,11 @@ var NunjucksEngine = class extends AbstractEngine {
|
|
|
405
407
|
super(name, extensions);
|
|
406
408
|
this.render = null;
|
|
407
409
|
}
|
|
408
|
-
async load() {
|
|
409
|
-
|
|
410
|
-
|
|
410
|
+
async load(force = false) {
|
|
411
|
+
if (this.templateList.size > 0 || force) {
|
|
412
|
+
const nunjucks = await import("nunjucks");
|
|
413
|
+
this.render = nunjucks.default.renderString;
|
|
414
|
+
}
|
|
411
415
|
}
|
|
412
416
|
renderNode(node, options = {}) {
|
|
413
417
|
const context = node.getNodeName();
|
|
@@ -628,7 +632,7 @@ var transformAsciidocCallout = (options) => {
|
|
|
628
632
|
tagName: "span",
|
|
629
633
|
properties: {
|
|
630
634
|
class: options?.cssClasses ?? "conum",
|
|
631
|
-
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;
|
|
635
|
+
style: options?.cssClasses ? "" : "user-select:none; pointer-events:none;",
|
|
632
636
|
"data-value": calloutId
|
|
633
637
|
},
|
|
634
638
|
children: [
|
|
@@ -765,7 +769,41 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
765
769
|
}
|
|
766
770
|
});
|
|
767
771
|
}
|
|
772
|
+
|
|
773
|
+
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
774
|
+
var transformerPrompt = (options) => {
|
|
775
|
+
return (node) => {
|
|
776
|
+
const language = node.getAttribute("language");
|
|
777
|
+
const customPrompt = node.getAttribute(
|
|
778
|
+
options?.promptAttribute ?? "custom-prompt"
|
|
779
|
+
);
|
|
780
|
+
const promptToAdd = customPrompt ?? (options?.langs && options.langs[language]);
|
|
781
|
+
let cssClasses = typeof promptToAdd === "object" ? promptToAdd.cssClasses : options?.cssClasses;
|
|
782
|
+
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
783
|
+
cssClasses = options.langs[language].cssClasses;
|
|
784
|
+
}
|
|
785
|
+
return {
|
|
786
|
+
line(hast) {
|
|
787
|
+
if (!promptToAdd) return;
|
|
788
|
+
hast.children.unshift({
|
|
789
|
+
type: "element",
|
|
790
|
+
tagName: "span",
|
|
791
|
+
properties: {
|
|
792
|
+
class: cssClasses
|
|
793
|
+
},
|
|
794
|
+
children: [
|
|
795
|
+
{
|
|
796
|
+
type: "text",
|
|
797
|
+
value: typeof promptToAdd === "object" ? promptToAdd.prompt : promptToAdd
|
|
798
|
+
}
|
|
799
|
+
]
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
};
|
|
804
|
+
};
|
|
768
805
|
// Annotate the CommonJS export names for ESM import in node:
|
|
769
806
|
0 && (module.exports = {
|
|
770
|
-
asciidocLoader
|
|
807
|
+
asciidocLoader,
|
|
808
|
+
transformerPrompt
|
|
771
809
|
});
|
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-PY1MiQbP.cjs';
|
|
3
|
+
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-PY1MiQbP.cjs';
|
|
4
|
+
export { t as transformerPrompt } from './transformerPrompt-n_gHpQ3r.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-PY1MiQbP.js';
|
|
3
|
+
export { a as AsciidocTemplate, C as CustomConverterFactoryFn, F as FilesystemTemplate, N as NodeContext, R as RawTemplate } from './index-PY1MiQbP.js';
|
|
4
|
+
export { t as transformerPrompt } from './transformerPrompt-DfCRhAD2.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,6 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
export {
|
|
485
|
-
asciidocLoader
|
|
485
|
+
asciidocLoader,
|
|
486
|
+
transformerPrompt
|
|
486
487
|
};
|
|
@@ -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-PY1MiQbP.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-PY1MiQbP.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 { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-
|
|
1
|
+
import { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-PY1MiQbP.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 { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-
|
|
1
|
+
import { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-PY1MiQbP.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,40 +1,13 @@
|
|
|
1
|
-
import { b as ShikiTransformerFactory } from '../../../index-
|
|
2
|
-
|
|
1
|
+
import { b as ShikiTransformerFactory } from '../../../index-PY1MiQbP.cjs';
|
|
2
|
+
export { t as transformerPrompt } from '../../../transformerPrompt-n_gHpQ3r.cjs';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'asciidoctor';
|
|
5
5
|
import 'astro/zod';
|
|
6
|
+
import 'shiki/types';
|
|
6
7
|
|
|
7
8
|
type TransformerOptions = Partial<{
|
|
8
9
|
cssClasses?: string;
|
|
9
10
|
}>;
|
|
10
11
|
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
prompt: string;
|
|
14
|
-
cssClasses: string;
|
|
15
|
-
};
|
|
16
|
-
type TransformOptions = {
|
|
17
|
-
/**
|
|
18
|
-
* String of CSS classes to apply to leading prompt character(s) on
|
|
19
|
-
* source code blocks of type console.
|
|
20
|
-
*/
|
|
21
|
-
cssClasses?: string;
|
|
22
|
-
/**
|
|
23
|
-
* An object mapping each language block to a prompt string. An object
|
|
24
|
-
* can also be provided specified with two keys, the prompt and the
|
|
25
|
-
* css classes that modify this prompt in particular. Useful when you
|
|
26
|
-
* want to style them differently from the
|
|
27
|
-
* If not provided, it will default to look at the block attribute.
|
|
28
|
-
*/
|
|
29
|
-
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
30
|
-
/**
|
|
31
|
-
* The name of the block attribute on the original document to look
|
|
32
|
-
* for and use as the prompt for this block.
|
|
33
|
-
*
|
|
34
|
-
* @default custom-prompt
|
|
35
|
-
*/
|
|
36
|
-
promptAttribute?: string;
|
|
37
|
-
};
|
|
38
|
-
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
39
|
-
|
|
40
|
-
export { transformAsciidocCallout, transformerPrompt };
|
|
13
|
+
export { transformAsciidocCallout };
|
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
import { b as ShikiTransformerFactory } from '../../../index-
|
|
2
|
-
|
|
1
|
+
import { b as ShikiTransformerFactory } from '../../../index-PY1MiQbP.js';
|
|
2
|
+
export { t as transformerPrompt } from '../../../transformerPrompt-DfCRhAD2.js';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'asciidoctor';
|
|
5
5
|
import 'astro/zod';
|
|
6
|
+
import 'shiki/types';
|
|
6
7
|
|
|
7
8
|
type TransformerOptions = Partial<{
|
|
8
9
|
cssClasses?: string;
|
|
9
10
|
}>;
|
|
10
11
|
declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
prompt: string;
|
|
14
|
-
cssClasses: string;
|
|
15
|
-
};
|
|
16
|
-
type TransformOptions = {
|
|
17
|
-
/**
|
|
18
|
-
* String of CSS classes to apply to leading prompt character(s) on
|
|
19
|
-
* source code blocks of type console.
|
|
20
|
-
*/
|
|
21
|
-
cssClasses?: string;
|
|
22
|
-
/**
|
|
23
|
-
* An object mapping each language block to a prompt string. An object
|
|
24
|
-
* can also be provided specified with two keys, the prompt and the
|
|
25
|
-
* css classes that modify this prompt in particular. Useful when you
|
|
26
|
-
* want to style them differently from the
|
|
27
|
-
* If not provided, it will default to look at the block attribute.
|
|
28
|
-
*/
|
|
29
|
-
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
30
|
-
/**
|
|
31
|
-
* The name of the block attribute on the original document to look
|
|
32
|
-
* for and use as the prompt for this block.
|
|
33
|
-
*
|
|
34
|
-
* @default custom-prompt
|
|
35
|
-
*/
|
|
36
|
-
promptAttribute?: string;
|
|
37
|
-
};
|
|
38
|
-
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
39
|
-
|
|
40
|
-
export { transformAsciidocCallout, transformerPrompt };
|
|
13
|
+
export { transformAsciidocCallout };
|
|
@@ -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
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BundledLanguage } from 'shiki/types';
|
|
2
|
+
import { b as ShikiTransformerFactory } from './index-PY1MiQbP.js';
|
|
3
|
+
|
|
4
|
+
type PromptOptions = {
|
|
5
|
+
prompt: string;
|
|
6
|
+
cssClasses: string;
|
|
7
|
+
};
|
|
8
|
+
type TransformOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* String of CSS classes to apply to leading prompt character(s) on
|
|
11
|
+
* source code blocks of type console.
|
|
12
|
+
*/
|
|
13
|
+
cssClasses?: string;
|
|
14
|
+
/**
|
|
15
|
+
* An object mapping each language block to a prompt string. An object
|
|
16
|
+
* can also be provided specified with two keys, the prompt and the
|
|
17
|
+
* css classes that modify this prompt in particular. Useful when you
|
|
18
|
+
* want to style them differently from the
|
|
19
|
+
* If not provided, it will default to look at the block attribute.
|
|
20
|
+
*/
|
|
21
|
+
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the block attribute on the original document to look
|
|
24
|
+
* for and use as the prompt for this block.
|
|
25
|
+
*
|
|
26
|
+
* @default custom-prompt
|
|
27
|
+
*/
|
|
28
|
+
promptAttribute?: string;
|
|
29
|
+
};
|
|
30
|
+
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
31
|
+
|
|
32
|
+
export { transformerPrompt as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BundledLanguage } from 'shiki/types';
|
|
2
|
+
import { b as ShikiTransformerFactory } from './index-PY1MiQbP.cjs';
|
|
3
|
+
|
|
4
|
+
type PromptOptions = {
|
|
5
|
+
prompt: string;
|
|
6
|
+
cssClasses: string;
|
|
7
|
+
};
|
|
8
|
+
type TransformOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* String of CSS classes to apply to leading prompt character(s) on
|
|
11
|
+
* source code blocks of type console.
|
|
12
|
+
*/
|
|
13
|
+
cssClasses?: string;
|
|
14
|
+
/**
|
|
15
|
+
* An object mapping each language block to a prompt string. An object
|
|
16
|
+
* can also be provided specified with two keys, the prompt and the
|
|
17
|
+
* css classes that modify this prompt in particular. Useful when you
|
|
18
|
+
* want to style them differently from the
|
|
19
|
+
* If not provided, it will default to look at the block attribute.
|
|
20
|
+
*/
|
|
21
|
+
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the block attribute on the original document to look
|
|
24
|
+
* for and use as the prompt for this block.
|
|
25
|
+
*
|
|
26
|
+
* @default custom-prompt
|
|
27
|
+
*/
|
|
28
|
+
promptAttribute?: string;
|
|
29
|
+
};
|
|
30
|
+
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
31
|
+
|
|
32
|
+
export { transformerPrompt as t };
|