@d10f/asciidoc-astro-loader 0.0.15 → 0.0.16
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-4JCAN3ZN.js → chunk-TCLZUBH3.js} +42 -28
- package/dist/index.cjs +42 -28
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/lib/shiki/transformers/index.cjs +42 -28
- package/dist/lib/shiki/transformers/index.d.cts +10 -48
- package/dist/lib/shiki/transformers/index.d.ts +10 -48
- package/dist/lib/shiki/transformers/index.js +1 -1
- package/package.json +1 -1
|
@@ -61,43 +61,57 @@ var transformAsciidocCallout = (options) => {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
64
|
-
var
|
|
64
|
+
var DEFAULT_OPTS = {
|
|
65
|
+
breakOn: "\\",
|
|
66
|
+
cssClasses: "",
|
|
67
|
+
hideBreak: false,
|
|
68
|
+
prompt: "",
|
|
69
|
+
promptAttribute: "custom-prompt"
|
|
70
|
+
};
|
|
71
|
+
var transformerPrompt = (opts) => {
|
|
65
72
|
return (node) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
const config = {
|
|
74
|
+
breakOn: opts?.breakOn ?? DEFAULT_OPTS.breakOn,
|
|
75
|
+
cssClasses: opts?.cssClasses ?? DEFAULT_OPTS.cssClasses,
|
|
76
|
+
hideBreak: opts?.hideBreak ?? DEFAULT_OPTS.hideBreak,
|
|
77
|
+
prompt: opts?.prompt ?? DEFAULT_OPTS.prompt
|
|
78
|
+
};
|
|
79
|
+
if (opts && opts.langs) {
|
|
80
|
+
const lang = node.getAttribute("language");
|
|
81
|
+
const langOpts = opts.langs[lang];
|
|
82
|
+
Object.assign(
|
|
83
|
+
config,
|
|
84
|
+
typeof langOpts === "object" ? langOpts : { prompt: langOpts }
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const promptAttr = node.getAttribute(
|
|
88
|
+
opts?.promptAttribute ?? DEFAULT_OPTS.promptAttribute
|
|
69
89
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
if (promptAttr) {
|
|
91
|
+
Object.assign(config, {
|
|
92
|
+
prompt: promptAttr
|
|
93
|
+
});
|
|
94
|
+
}
|
|
73
95
|
const breakOnRe = new RegExp(
|
|
74
|
-
`\\s+${escapeRegexCharacters(breakOn)}\\s*$`
|
|
96
|
+
`\\s+${escapeRegexCharacters(config.breakOn)}\\s*$`
|
|
75
97
|
);
|
|
76
|
-
const hideBreak = options?.langs && options.langs[language] && typeof options.langs[language] === "object" && options.langs[language].hideBreak;
|
|
77
|
-
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
78
|
-
cssClasses = options.langs[language].cssClasses;
|
|
79
|
-
}
|
|
80
98
|
let skipNext = false;
|
|
99
|
+
let skipCurrent = false;
|
|
81
100
|
return {
|
|
82
101
|
enforce: "pre",
|
|
83
102
|
line(hast) {
|
|
84
|
-
if (!
|
|
85
|
-
|
|
103
|
+
if (!config.prompt || !config.prompt.trim()) return;
|
|
104
|
+
skipCurrent = skipNext;
|
|
86
105
|
skipNext = false;
|
|
87
106
|
const lastChild = hast.children.at(-1);
|
|
88
|
-
const lastToken = lastChild
|
|
89
|
-
if (
|
|
107
|
+
const lastToken = lastChild?.children[0];
|
|
108
|
+
if (lastToken) {
|
|
90
109
|
skipNext = breakOnRe.test(lastToken.value);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
lastChild.children[0].value.replace(
|
|
97
|
-
breakOnRe,
|
|
98
|
-
""
|
|
99
|
-
);
|
|
100
|
-
}
|
|
110
|
+
if (skipNext && config.hideBreak) {
|
|
111
|
+
lastToken.value = lastToken.value.replace(
|
|
112
|
+
breakOnRe,
|
|
113
|
+
""
|
|
114
|
+
);
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
if (skipCurrent) return;
|
|
@@ -105,12 +119,12 @@ var transformerPrompt = (options) => {
|
|
|
105
119
|
type: "element",
|
|
106
120
|
tagName: "span",
|
|
107
121
|
properties: {
|
|
108
|
-
class: cssClasses
|
|
122
|
+
class: config.cssClasses
|
|
109
123
|
},
|
|
110
124
|
children: [
|
|
111
125
|
{
|
|
112
126
|
type: "text",
|
|
113
|
-
value:
|
|
127
|
+
value: config.prompt
|
|
114
128
|
}
|
|
115
129
|
]
|
|
116
130
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -785,43 +785,57 @@ async function setDocument(doc, converters, templateEngine, { parseData, store }
|
|
|
785
785
|
}
|
|
786
786
|
|
|
787
787
|
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
788
|
-
var
|
|
788
|
+
var DEFAULT_OPTS = {
|
|
789
|
+
breakOn: "\\",
|
|
790
|
+
cssClasses: "",
|
|
791
|
+
hideBreak: false,
|
|
792
|
+
prompt: "",
|
|
793
|
+
promptAttribute: "custom-prompt"
|
|
794
|
+
};
|
|
795
|
+
var transformerPrompt = (opts) => {
|
|
789
796
|
return (node) => {
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
797
|
+
const config = {
|
|
798
|
+
breakOn: opts?.breakOn ?? DEFAULT_OPTS.breakOn,
|
|
799
|
+
cssClasses: opts?.cssClasses ?? DEFAULT_OPTS.cssClasses,
|
|
800
|
+
hideBreak: opts?.hideBreak ?? DEFAULT_OPTS.hideBreak,
|
|
801
|
+
prompt: opts?.prompt ?? DEFAULT_OPTS.prompt
|
|
802
|
+
};
|
|
803
|
+
if (opts && opts.langs) {
|
|
804
|
+
const lang = node.getAttribute("language");
|
|
805
|
+
const langOpts = opts.langs[lang];
|
|
806
|
+
Object.assign(
|
|
807
|
+
config,
|
|
808
|
+
typeof langOpts === "object" ? langOpts : { prompt: langOpts }
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
const promptAttr = node.getAttribute(
|
|
812
|
+
opts?.promptAttribute ?? DEFAULT_OPTS.promptAttribute
|
|
793
813
|
);
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
814
|
+
if (promptAttr) {
|
|
815
|
+
Object.assign(config, {
|
|
816
|
+
prompt: promptAttr
|
|
817
|
+
});
|
|
818
|
+
}
|
|
797
819
|
const breakOnRe = new RegExp(
|
|
798
|
-
`\\s+${escapeRegexCharacters(breakOn)}\\s*$`
|
|
820
|
+
`\\s+${escapeRegexCharacters(config.breakOn)}\\s*$`
|
|
799
821
|
);
|
|
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
822
|
let skipNext = false;
|
|
823
|
+
let skipCurrent = false;
|
|
805
824
|
return {
|
|
806
825
|
enforce: "pre",
|
|
807
826
|
line(hast) {
|
|
808
|
-
if (!
|
|
809
|
-
|
|
827
|
+
if (!config.prompt || !config.prompt.trim()) return;
|
|
828
|
+
skipCurrent = skipNext;
|
|
810
829
|
skipNext = false;
|
|
811
830
|
const lastChild = hast.children.at(-1);
|
|
812
|
-
const lastToken = lastChild
|
|
813
|
-
if (
|
|
831
|
+
const lastToken = lastChild?.children[0];
|
|
832
|
+
if (lastToken) {
|
|
814
833
|
skipNext = breakOnRe.test(lastToken.value);
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
lastChild.children[0].value.replace(
|
|
821
|
-
breakOnRe,
|
|
822
|
-
""
|
|
823
|
-
);
|
|
824
|
-
}
|
|
834
|
+
if (skipNext && config.hideBreak) {
|
|
835
|
+
lastToken.value = lastToken.value.replace(
|
|
836
|
+
breakOnRe,
|
|
837
|
+
""
|
|
838
|
+
);
|
|
825
839
|
}
|
|
826
840
|
}
|
|
827
841
|
if (skipCurrent) return;
|
|
@@ -829,12 +843,12 @@ var transformerPrompt = (options) => {
|
|
|
829
843
|
type: "element",
|
|
830
844
|
tagName: "span",
|
|
831
845
|
properties: {
|
|
832
|
-
class: cssClasses
|
|
846
|
+
class: config.cssClasses
|
|
833
847
|
},
|
|
834
848
|
children: [
|
|
835
849
|
{
|
|
836
850
|
type: "text",
|
|
837
|
-
value:
|
|
851
|
+
value: config.prompt
|
|
838
852
|
}
|
|
839
853
|
]
|
|
840
854
|
});
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -90,43 +90,57 @@ var transformAsciidocCallout = (options) => {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
// src/lib/shiki/transformers/transformerPrompt.ts
|
|
93
|
-
var
|
|
93
|
+
var DEFAULT_OPTS = {
|
|
94
|
+
breakOn: "\\",
|
|
95
|
+
cssClasses: "",
|
|
96
|
+
hideBreak: false,
|
|
97
|
+
prompt: "",
|
|
98
|
+
promptAttribute: "custom-prompt"
|
|
99
|
+
};
|
|
100
|
+
var transformerPrompt = (opts) => {
|
|
94
101
|
return (node) => {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
const config = {
|
|
103
|
+
breakOn: opts?.breakOn ?? DEFAULT_OPTS.breakOn,
|
|
104
|
+
cssClasses: opts?.cssClasses ?? DEFAULT_OPTS.cssClasses,
|
|
105
|
+
hideBreak: opts?.hideBreak ?? DEFAULT_OPTS.hideBreak,
|
|
106
|
+
prompt: opts?.prompt ?? DEFAULT_OPTS.prompt
|
|
107
|
+
};
|
|
108
|
+
if (opts && opts.langs) {
|
|
109
|
+
const lang = node.getAttribute("language");
|
|
110
|
+
const langOpts = opts.langs[lang];
|
|
111
|
+
Object.assign(
|
|
112
|
+
config,
|
|
113
|
+
typeof langOpts === "object" ? langOpts : { prompt: langOpts }
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const promptAttr = node.getAttribute(
|
|
117
|
+
opts?.promptAttribute ?? DEFAULT_OPTS.promptAttribute
|
|
98
118
|
);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
if (promptAttr) {
|
|
120
|
+
Object.assign(config, {
|
|
121
|
+
prompt: promptAttr
|
|
122
|
+
});
|
|
123
|
+
}
|
|
102
124
|
const breakOnRe = new RegExp(
|
|
103
|
-
`\\s+${escapeRegexCharacters(breakOn)}\\s*$`
|
|
125
|
+
`\\s+${escapeRegexCharacters(config.breakOn)}\\s*$`
|
|
104
126
|
);
|
|
105
|
-
const hideBreak = options?.langs && options.langs[language] && typeof options.langs[language] === "object" && options.langs[language].hideBreak;
|
|
106
|
-
if (customPrompt && options?.langs && typeof options.langs[language] === "object") {
|
|
107
|
-
cssClasses = options.langs[language].cssClasses;
|
|
108
|
-
}
|
|
109
127
|
let skipNext = false;
|
|
128
|
+
let skipCurrent = false;
|
|
110
129
|
return {
|
|
111
130
|
enforce: "pre",
|
|
112
131
|
line(hast) {
|
|
113
|
-
if (!
|
|
114
|
-
|
|
132
|
+
if (!config.prompt || !config.prompt.trim()) return;
|
|
133
|
+
skipCurrent = skipNext;
|
|
115
134
|
skipNext = false;
|
|
116
135
|
const lastChild = hast.children.at(-1);
|
|
117
|
-
const lastToken = lastChild
|
|
118
|
-
if (
|
|
136
|
+
const lastToken = lastChild?.children[0];
|
|
137
|
+
if (lastToken) {
|
|
119
138
|
skipNext = breakOnRe.test(lastToken.value);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
lastChild.children[0].value.replace(
|
|
126
|
-
breakOnRe,
|
|
127
|
-
""
|
|
128
|
-
);
|
|
129
|
-
}
|
|
139
|
+
if (skipNext && config.hideBreak) {
|
|
140
|
+
lastToken.value = lastToken.value.replace(
|
|
141
|
+
breakOnRe,
|
|
142
|
+
""
|
|
143
|
+
);
|
|
130
144
|
}
|
|
131
145
|
}
|
|
132
146
|
if (skipCurrent) return;
|
|
@@ -134,12 +148,12 @@ var transformerPrompt = (options) => {
|
|
|
134
148
|
type: "element",
|
|
135
149
|
tagName: "span",
|
|
136
150
|
properties: {
|
|
137
|
-
class: cssClasses
|
|
151
|
+
class: config.cssClasses
|
|
138
152
|
},
|
|
139
153
|
children: [
|
|
140
154
|
{
|
|
141
155
|
type: "text",
|
|
142
|
-
value:
|
|
156
|
+
value: config.prompt
|
|
143
157
|
}
|
|
144
158
|
]
|
|
145
159
|
});
|
|
@@ -1,57 +1,19 @@
|
|
|
1
1
|
import { c as ShikiTransformerFactory } from '../../../index-C1F2jTPD.cjs';
|
|
2
|
-
import { BundledLanguage } from 'shiki
|
|
3
|
-
import 'shiki';
|
|
2
|
+
import { BundledLanguage } from 'shiki';
|
|
4
3
|
import 'asciidoctor';
|
|
5
4
|
import 'astro/zod';
|
|
6
5
|
|
|
7
|
-
type PromptOptions = {
|
|
6
|
+
type PromptOptions = Partial<{
|
|
8
7
|
prompt: string;
|
|
9
8
|
cssClasses: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
breakOn?: string;
|
|
20
|
-
/**
|
|
21
|
-
* This option is used to control whether the `breakOn` character
|
|
22
|
-
* sequence should be removed from the output code block. This can be
|
|
23
|
-
* useful to control multiline blocks that are intrinsically based on
|
|
24
|
-
* newline characters which aren't visible, as opposed to other type
|
|
25
|
-
* of breaks like shell console that rely on visible characters like
|
|
26
|
-
* the backslash.
|
|
27
|
-
*
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
hideBreak?: boolean;
|
|
31
|
-
};
|
|
32
|
-
type TransformOptions = {
|
|
33
|
-
/**
|
|
34
|
-
* String of CSS classes to apply to leading prompt character(s) on
|
|
35
|
-
* source code blocks of type console.
|
|
36
|
-
*/
|
|
37
|
-
cssClasses?: string;
|
|
38
|
-
/**
|
|
39
|
-
* An object mapping each language block to a prompt string. An object
|
|
40
|
-
* can also be provided specified with two keys, the prompt and the
|
|
41
|
-
* CSS classes that modify this prompt in particular. Useful when you
|
|
42
|
-
* want to style them differently from the
|
|
43
|
-
* If not provided, it will default to look at the block attribute.
|
|
44
|
-
*/
|
|
45
|
-
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
46
|
-
/**
|
|
47
|
-
* The name of the block attribute on the original document to look
|
|
48
|
-
* for and use as the prompt for this block.
|
|
49
|
-
*
|
|
50
|
-
* @default custom-prompt
|
|
51
|
-
*/
|
|
52
|
-
promptAttribute?: string;
|
|
53
|
-
};
|
|
54
|
-
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
9
|
+
breakOn: string;
|
|
10
|
+
hideBreak: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
type TransformerOptions$1 = PromptOptions & Partial<{
|
|
13
|
+
langs: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
14
|
+
promptAttribute: string;
|
|
15
|
+
}>;
|
|
16
|
+
declare const transformerPrompt: ShikiTransformerFactory<TransformerOptions$1>;
|
|
55
17
|
|
|
56
18
|
type TransformerOptions = Partial<{
|
|
57
19
|
cssClasses?: string;
|
|
@@ -1,57 +1,19 @@
|
|
|
1
1
|
import { c as ShikiTransformerFactory } from '../../../index-C1F2jTPD.js';
|
|
2
|
-
import { BundledLanguage } from 'shiki
|
|
3
|
-
import 'shiki';
|
|
2
|
+
import { BundledLanguage } from 'shiki';
|
|
4
3
|
import 'asciidoctor';
|
|
5
4
|
import 'astro/zod';
|
|
6
5
|
|
|
7
|
-
type PromptOptions = {
|
|
6
|
+
type PromptOptions = Partial<{
|
|
8
7
|
prompt: string;
|
|
9
8
|
cssClasses: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
breakOn?: string;
|
|
20
|
-
/**
|
|
21
|
-
* This option is used to control whether the `breakOn` character
|
|
22
|
-
* sequence should be removed from the output code block. This can be
|
|
23
|
-
* useful to control multiline blocks that are intrinsically based on
|
|
24
|
-
* newline characters which aren't visible, as opposed to other type
|
|
25
|
-
* of breaks like shell console that rely on visible characters like
|
|
26
|
-
* the backslash.
|
|
27
|
-
*
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
hideBreak?: boolean;
|
|
31
|
-
};
|
|
32
|
-
type TransformOptions = {
|
|
33
|
-
/**
|
|
34
|
-
* String of CSS classes to apply to leading prompt character(s) on
|
|
35
|
-
* source code blocks of type console.
|
|
36
|
-
*/
|
|
37
|
-
cssClasses?: string;
|
|
38
|
-
/**
|
|
39
|
-
* An object mapping each language block to a prompt string. An object
|
|
40
|
-
* can also be provided specified with two keys, the prompt and the
|
|
41
|
-
* CSS classes that modify this prompt in particular. Useful when you
|
|
42
|
-
* want to style them differently from the
|
|
43
|
-
* If not provided, it will default to look at the block attribute.
|
|
44
|
-
*/
|
|
45
|
-
langs?: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
46
|
-
/**
|
|
47
|
-
* The name of the block attribute on the original document to look
|
|
48
|
-
* for and use as the prompt for this block.
|
|
49
|
-
*
|
|
50
|
-
* @default custom-prompt
|
|
51
|
-
*/
|
|
52
|
-
promptAttribute?: string;
|
|
53
|
-
};
|
|
54
|
-
declare const transformerPrompt: ShikiTransformerFactory<TransformOptions>;
|
|
9
|
+
breakOn: string;
|
|
10
|
+
hideBreak: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
type TransformerOptions$1 = PromptOptions & Partial<{
|
|
13
|
+
langs: Partial<Record<BundledLanguage, PromptOptions | string>>;
|
|
14
|
+
promptAttribute: string;
|
|
15
|
+
}>;
|
|
16
|
+
declare const transformerPrompt: ShikiTransformerFactory<TransformerOptions$1>;
|
|
55
17
|
|
|
56
18
|
type TransformerOptions = Partial<{
|
|
57
19
|
cssClasses?: string;
|