@d10f/asciidoc-astro-loader 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  sourceCodeConverter
3
- } from "./chunk-BRMWIQA2.js";
3
+ } from "./chunk-KZRXEKZK.js";
4
+ import {
5
+ transformAsciidocCallout
6
+ } from "./chunk-5P6LDJGO.js";
4
7
  import {
5
8
  slugify,
6
9
  splitFilenameComponents
7
- } from "./chunk-DDIUST2Z.js";
10
+ } from "./chunk-2UGTFP4R.js";
8
11
  import {
9
12
  HandlebarsEngine,
10
13
  NunjucksEngine
@@ -279,13 +282,18 @@ var shikiOptionsSchema = z2.object({
279
282
  cssVariablePrefix: z2.string().default("--shiki-"),
280
283
  mergeWhitespaces: z2.union([z2.boolean(), z2.literal("never")]).default(true),
281
284
  tabindex: z2.union([z2.number(), z2.string(), z2.literal(false)]).default(false),
282
- transformers: z2.array(
283
- z2.object({
284
- name: z2.string(),
285
- enforce: z2.union([z2.literal("pre"), z2.literal("post")])
286
- })
287
- ).optional()
288
- }).transform(({ theme, ...rest }) => ({
285
+ // transformers: z
286
+ // .array(
287
+ // z.object({
288
+ // name: z.string(),
289
+ // enforce: z.union([z.literal('pre'), z.literal('post')]),
290
+ // }),
291
+ // )
292
+ // .optional(),
293
+ callouts: z2.object({
294
+ cssClasses: z2.string().optional()
295
+ }).optional()
296
+ }).passthrough().transform(({ theme, ...rest }) => ({
289
297
  themes: theme,
290
298
  ...rest
291
299
  })).default({
@@ -297,7 +305,8 @@ var shikiOptionsSchema = z2.object({
297
305
  light: "catppuccin-latte",
298
306
  dark: "catppuccin-macchiato"
299
307
  },
300
- transformers: void 0
308
+ // transformers: undefined,
309
+ callouts: void 0
301
310
  });
302
311
  function transformThemeProp(value) {
303
312
  return typeof value === "string" ? { light: value, dark: value } : value;
@@ -342,13 +351,13 @@ async function createHighlighter(documents, themes) {
342
351
  }
343
352
 
344
353
  // src/loader.ts
345
- function asciidocLoader(options) {
346
- const parsedOpts = loaderOptionsSchema.parse(options);
347
- if (parsedOpts.document.converters === void 0) {
348
- parsedOpts.document.converters = [];
354
+ function asciidocLoader(_options) {
355
+ const options = loaderOptionsSchema.parse(_options);
356
+ if (options.document.converters === void 0) {
357
+ options.document.converters = [];
349
358
  }
350
- if (parsedOpts.document.templateEngines === void 0) {
351
- parsedOpts.document.templateEngines = [
359
+ if (options.document.templateEngines === void 0) {
360
+ options.document.templateEngines = [
352
361
  new HandlebarsEngine(),
353
362
  new NunjucksEngine()
354
363
  ];
@@ -360,18 +369,18 @@ function asciidocLoader(options) {
360
369
  async load(loaderContext) {
361
370
  const { config, logger, watcher } = loaderContext;
362
371
  const root = config.root.pathname;
363
- const base = parsedOpts.base.startsWith(".") ? realpathSync(options.base) : root + options.base;
372
+ const base = options.base.startsWith(".") ? realpathSync(options.base) : root + options.base;
364
373
  const docs = readdirSync2(base, "utf8").filter((file) => file.match(/(?:\.a(?:scii)?doc)$/)).map((filename) => new AsciidocDocument(`${base}/${filename}`));
365
374
  if (docs.length === 0) {
366
375
  logger.warn("No documents found for this collection.");
367
376
  return;
368
377
  }
369
- if (parsedOpts.document.template) {
378
+ if (options.document.template) {
370
379
  templateEngine = new TemplateEngineRegistry(
371
- parsedOpts.document.templateEngines,
380
+ options.document.templateEngines,
372
381
  {
373
- rootDir: parsedOpts.document.template,
374
- recursive: parsedOpts.document.recursive
382
+ rootDir: options.document.template,
383
+ recursive: options.document.recursive
375
384
  }
376
385
  );
377
386
  await templateEngine.loadEngines();
@@ -379,11 +388,11 @@ function asciidocLoader(options) {
379
388
  if (!highlighter) {
380
389
  highlighter = await createHighlighter(
381
390
  docs,
382
- parsedOpts.syntaxHighlighting.themes
391
+ options.syntaxHighlighting.themes
383
392
  );
384
393
  }
385
- const converters = parsedOpts.document.converters.map(
386
- (converter) => converter(parsedOpts, highlighter)
394
+ const converters = options.document.converters.map(
395
+ (converter) => converter(options, highlighter)
387
396
  );
388
397
  const hasSourceCodeConverter = converters.find(
389
398
  (converter) => converter.nodeContext === "listing" && converter?.nodeStyle === "source"
@@ -391,18 +400,18 @@ function asciidocLoader(options) {
391
400
  if (!hasSourceCodeConverter) {
392
401
  converters.push(
393
402
  sourceCodeConverter({
394
- transformers: parsedOpts.syntaxHighlighting.transformers
395
- })(parsedOpts, highlighter)
403
+ transformers: [
404
+ ...options.syntaxHighlighting.transformers ?? [],
405
+ transformAsciidocCallout(
406
+ options.syntaxHighlighting.callouts
407
+ )
408
+ ]
409
+ })(options, highlighter)
396
410
  );
397
411
  }
398
412
  await Promise.all(
399
413
  docs.map(
400
- (doc) => syncDocument(
401
- doc,
402
- converters,
403
- templateEngine,
404
- loaderContext
405
- )
414
+ (doc) => setDocument(doc, converters, templateEngine, loaderContext)
406
415
  )
407
416
  );
408
417
  if (watcher) {
@@ -415,11 +424,10 @@ function asciidocLoader(options) {
415
424
  const watchedFileRegExp = new RegExp(
416
425
  `^${base}.*.(a(?:scii)?doc)$`
417
426
  );
418
- console.log(this.name);
419
427
  watcher.on("change", async (changedPath) => {
420
428
  if (changedPath.match(watchedFileRegExp)) {
421
429
  const newDoc = new AsciidocDocument(changedPath);
422
- await syncDocument(
430
+ await setDocument(
423
431
  newDoc,
424
432
  converters,
425
433
  templateEngine,
@@ -427,15 +435,17 @@ function asciidocLoader(options) {
427
435
  );
428
436
  }
429
437
  });
430
- process.on("SIGINT", handle2);
431
- process.on("SIGTERM", handle2);
438
+ if (highlighter) {
439
+ process.on("SIGINT", handle2);
440
+ process.on("SIGTERM", handle2);
441
+ }
432
442
  } else {
433
443
  nextTick(highlighter.dispose);
434
444
  }
435
445
  }
436
446
  };
437
447
  }
438
- async function syncDocument(doc, converters, templateEngine, { parseData, store }) {
448
+ async function setDocument(doc, converters, templateEngine, { parseData, store }) {
439
449
  const data = await parseData({
440
450
  id: doc.slug,
441
451
  data: {
@@ -28,10 +28,6 @@ module.exports = __toCommonJS(converters_exports);
28
28
  var import_node_path = require("path");
29
29
 
30
30
  // src/lib/utils.ts
31
- function escapeRegexCharacters(str) {
32
- const re = /[-\\^$*+?.()|\[\]{}]/g;
33
- return str.replace(re, "\\$&");
34
- }
35
31
  function splitFilenameComponents(filename) {
36
32
  const match = filename.match(/^(?<path>.*\/)*(?<name>[^\.]+)\.(?<ext>.*)$/);
37
33
  return {
@@ -41,96 +37,6 @@ function splitFilenameComponents(filename) {
41
37
  };
42
38
  }
43
39
 
44
- // src/lib/shiki/transformers/transformAsciidocCallout.ts
45
- function transformAsciidocCallout({
46
- node,
47
- cssClasses = "pointer-events-none select-none ml-2"
48
- }) {
49
- const lineComments = ["//", "#", ";;"];
50
- const customLineComment = node.getAttribute("line-comment");
51
- if (customLineComment) {
52
- lineComments.push(escapeRegexCharacters(customLineComment));
53
- }
54
- const calloutReList = [
55
- // Handles C-style and similar comments like Perl, Python...
56
- new RegExp(`(?:${lineComments.join("|")})((?:\\s+<(\\d+)>)+)`),
57
- // Handles XML comments
58
- new RegExp(/((?:\s*<!--(\d+)-->)+)/)
59
- ];
60
- const linesWithCallout = {};
61
- return {
62
- preprocess(code) {
63
- return code.split("\n").map((line, idx) => {
64
- for (const re of calloutReList) {
65
- const match = line.match(re);
66
- if (!match) continue;
67
- const callouts = match[0].trim().replaceAll(/(?:<!--|-->|[<>])/g, "").split(" ");
68
- linesWithCallout[idx + 1] = callouts;
69
- return line.replace(re, "");
70
- }
71
- return line;
72
- }).join("\n");
73
- },
74
- line(hast, line) {
75
- const callouts = linesWithCallout[line];
76
- if (!callouts) return;
77
- callouts.forEach((calloutId) => {
78
- hast.properties[`data-callout-${calloutId}`] = "";
79
- hast.children.push({
80
- type: "element",
81
- tagName: "i",
82
- properties: {
83
- class: `conum ${cssClasses}`,
84
- "data-value": calloutId
85
- },
86
- children: [
87
- {
88
- type: "element",
89
- tagName: "b",
90
- properties: {},
91
- children: [
92
- {
93
- type: "text",
94
- value: calloutId
95
- }
96
- ]
97
- }
98
- ]
99
- });
100
- });
101
- }
102
- };
103
- }
104
-
105
- // src/lib/shiki/transformers/transformConsoleCodeBlock.ts
106
- function transformConsoleCodeBlock(options = {
107
- cssClasses: "pointer-events-none select-none mr-2 opacity-50"
108
- }) {
109
- const unselectablePrompt = `<span $1 class="${options.cssClasses}">$</span>`;
110
- const linePrefix = '<span class="line[^>]+?>';
111
- const splitPrompt = new RegExp(
112
- `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\$\\s+?([^<]))`
113
- );
114
- const trimWhitespace = new RegExp(
115
- `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\$\\s*?<\\/span>(?:<span>\\s+<\\/span>)?)`
116
- );
117
- const trimWhitespaceAhead = new RegExp(
118
- `(?<=${linePrefix}<span [^>]+?>\\$<\\/span>)(<span style="[^"]+?">)\\s+?`
119
- );
120
- return {
121
- postprocess: (html, { lang }) => {
122
- if (lang === "console") {
123
- return html.split("\n").map((line) => {
124
- return line.replace(
125
- splitPrompt,
126
- unselectablePrompt + "<span $1>$2"
127
- ).replace(trimWhitespace, unselectablePrompt).replace(trimWhitespaceAhead, "$1");
128
- }).join("\n");
129
- }
130
- }
131
- };
132
- }
133
-
134
40
  // src/lib/asciidoc/converters/sourceCodeConverter.ts
135
41
  var sourceCodeConverter = ({ transformers, template }) => {
136
42
  return (options, highlighter) => {
@@ -143,11 +49,9 @@ var sourceCodeConverter = ({ transformers, template }) => {
143
49
  const output = highlighter.codeToHtml(input, {
144
50
  ...options.syntaxHighlighting,
145
51
  lang,
146
- transformers: [
147
- ...transformers ?? [],
148
- transformAsciidocCallout({ node }),
149
- transformConsoleCodeBlock()
150
- ]
52
+ transformers: (transformers ?? []).map((transformer) => {
53
+ return typeof transformer === "function" ? transformer(node) : transformer;
54
+ })
151
55
  });
152
56
  if (templateEngine && template) {
153
57
  const { extension } = splitFilenameComponents(template);
@@ -1,10 +1,10 @@
1
1
  import { ShikiTransformer } from 'shiki';
2
- import { C as CustomConverterFactoryFn } from '../../../index-BNxO58s3.cjs';
2
+ import { C as CustomConverterFactoryFn, S as ShikiTransformerFactoryFn } from '../../../index-sFlXF8Qm.cjs';
3
3
  import 'asciidoctor';
4
4
  import 'astro/zod';
5
5
 
6
6
  type CodeBlockConverterOptions = {
7
- transformers: ShikiTransformer[];
7
+ transformers: Array<ShikiTransformer | ShikiTransformerFactoryFn>;
8
8
  template: string;
9
9
  };
10
10
  declare const sourceCodeConverter: CustomConverterFactoryFn<Partial<CodeBlockConverterOptions>>;
@@ -1,10 +1,10 @@
1
1
  import { ShikiTransformer } from 'shiki';
2
- import { C as CustomConverterFactoryFn } from '../../../index-BNxO58s3.js';
2
+ import { C as CustomConverterFactoryFn, S as ShikiTransformerFactoryFn } from '../../../index-sFlXF8Qm.js';
3
3
  import 'asciidoctor';
4
4
  import 'astro/zod';
5
5
 
6
6
  type CodeBlockConverterOptions = {
7
- transformers: ShikiTransformer[];
7
+ transformers: Array<ShikiTransformer | ShikiTransformerFactoryFn>;
8
8
  template: string;
9
9
  };
10
10
  declare const sourceCodeConverter: CustomConverterFactoryFn<Partial<CodeBlockConverterOptions>>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  sourceCodeConverter
3
- } from "../../../chunk-BRMWIQA2.js";
4
- import "../../../chunk-DDIUST2Z.js";
3
+ } from "../../../chunk-KZRXEKZK.js";
4
+ import "../../../chunk-2UGTFP4R.js";
5
5
  export {
6
6
  sourceCodeConverter
7
7
  };
@@ -1,4 +1,4 @@
1
- import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-BNxO58s3.cjs';
1
+ import { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-sFlXF8Qm.cjs';
2
2
  import { AbstractBlock } from 'asciidoctor';
3
3
  import 'shiki';
4
4
  import 'astro/zod';
@@ -1,4 +1,4 @@
1
- import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-BNxO58s3.js';
1
+ import { c as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-sFlXF8Qm.js';
2
2
  import { AbstractBlock } from 'asciidoctor';
3
3
  import 'shiki';
4
4
  import 'astro/zod';
@@ -21,7 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var transformers_exports = {};
22
22
  __export(transformers_exports, {
23
23
  transformAsciidocCallout: () => transformAsciidocCallout,
24
- transformConsoleCodeBlock: () => transformConsoleCodeBlock
24
+ transformConsolePrompt: () => transformConsolePrompt
25
25
  });
26
26
  module.exports = __toCommonJS(transformers_exports);
27
27
 
@@ -32,84 +32,93 @@ function escapeRegexCharacters(str) {
32
32
  }
33
33
 
34
34
  // src/lib/shiki/transformers/transformAsciidocCallout.ts
35
- function transformAsciidocCallout({
36
- node,
37
- cssClasses = "pointer-events-none select-none ml-2"
38
- }) {
39
- const lineComments = ["//", "#", ";;"];
40
- const customLineComment = node.getAttribute("line-comment");
41
- if (customLineComment) {
42
- lineComments.push(escapeRegexCharacters(customLineComment));
43
- }
44
- const calloutReList = [
45
- // Handles C-style and similar comments like Perl, Python...
46
- new RegExp(`(?:${lineComments.join("|")})((?:\\s+<(\\d+)>)+)`),
47
- // Handles XML comments
48
- new RegExp(/((?:\s*<!--(\d+)-->)+)/)
49
- ];
50
- const linesWithCallout = {};
51
- return {
52
- preprocess(code) {
53
- return code.split("\n").map((line, idx) => {
54
- for (const re of calloutReList) {
55
- const match = line.match(re);
56
- if (!match) continue;
57
- const callouts = match[0].trim().replaceAll(/(?:<!--|-->|[<>])/g, "").split(" ");
58
- linesWithCallout[idx + 1] = callouts;
59
- return line.replace(re, "");
60
- }
61
- return line;
62
- }).join("\n");
63
- },
64
- line(hast, line) {
65
- const callouts = linesWithCallout[line];
66
- if (!callouts) return;
67
- callouts.forEach((calloutId) => {
68
- hast.properties[`data-callout-${calloutId}`] = "";
69
- hast.children.push({
70
- type: "element",
71
- tagName: "i",
72
- properties: {
73
- class: `conum ${cssClasses}`,
74
- "data-value": calloutId
75
- },
76
- children: [
77
- {
78
- type: "element",
79
- tagName: "b",
80
- properties: {},
81
- children: [
82
- {
83
- type: "text",
84
- value: calloutId
85
- }
86
- ]
87
- }
88
- ]
89
- });
90
- });
35
+ var transformAsciidocCallout = (options) => {
36
+ return (node) => {
37
+ const lineComments = ["//", "#", ";;"];
38
+ const customLineComment = node.getAttribute("line-comment");
39
+ if (customLineComment) {
40
+ lineComments.push(escapeRegexCharacters(customLineComment));
91
41
  }
42
+ const calloutReList = [
43
+ // Handles C-style and similar comments like Perl, Python...
44
+ new RegExp(`\\s+(?:${lineComments.join("|")})((?:\\s+<(\\d+)>)+)`),
45
+ // Handles XML comments
46
+ new RegExp(/((?:\s*<!--(\d+)-->)+)/)
47
+ ];
48
+ const commentTokensRe = new RegExp(
49
+ `(?:${lineComments.join("|")}|<!--|-->|[<>])`,
50
+ "g"
51
+ );
52
+ const linesWithCallout = {};
53
+ return {
54
+ preprocess(code) {
55
+ return code.split("\n").map((line, idx) => {
56
+ for (const re of calloutReList) {
57
+ const match = line.match(re);
58
+ if (!match) continue;
59
+ const callouts = match[0].replaceAll(commentTokensRe, "").trim().split(" ");
60
+ linesWithCallout[idx + 1] = callouts;
61
+ return line.replace(re, "");
62
+ }
63
+ return line;
64
+ }).join("\n");
65
+ },
66
+ line(hast, line) {
67
+ const callouts = linesWithCallout[line];
68
+ if (!callouts) return;
69
+ callouts.forEach((calloutId) => {
70
+ hast.properties[`data-callout-${calloutId}`] = "";
71
+ hast.children.push({
72
+ type: "element",
73
+ tagName: "span",
74
+ properties: {
75
+ class: options?.cssClasses ?? "conum",
76
+ style: options?.cssClasses ? "" : "user-select:none; pointer-events:none; opacity:0.5; margin-inline:8px;",
77
+ "data-value": calloutId
78
+ },
79
+ children: [
80
+ {
81
+ type: "text",
82
+ value: calloutId
83
+ }
84
+ ]
85
+ });
86
+ });
87
+ }
88
+ };
92
89
  };
93
- }
90
+ };
94
91
 
95
- // src/lib/shiki/transformers/transformConsoleCodeBlock.ts
96
- function transformConsoleCodeBlock(options = {
97
- cssClasses: "pointer-events-none select-none mr-2 opacity-50"
98
- }) {
99
- const unselectablePrompt = `<span $1 class="${options.cssClasses}">$</span>`;
100
- const linePrefix = '<span class="line[^>]+?>';
101
- const splitPrompt = new RegExp(
102
- `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\$\\s+?([^<]))`
103
- );
104
- const trimWhitespace = new RegExp(
105
- `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\$\\s*?<\\/span>(?:<span>\\s+<\\/span>)?)`
106
- );
107
- const trimWhitespaceAhead = new RegExp(
108
- `(?<=${linePrefix}<span [^>]+?>\\$<\\/span>)(<span style="[^"]+?">)\\s+?`
109
- );
110
- return {
111
- postprocess: (html, { lang }) => {
112
- if (lang === "console") {
92
+ // src/lib/shiki/transformers/transformConsolePrompt.ts
93
+ var transformConsolePrompt = (options) => {
94
+ return (node) => {
95
+ const language = node.getAttribute("language");
96
+ const cssClasses = options?.cssClasses;
97
+ const promptChar = options?.promptChar ?? "$";
98
+ const unselectablePrompt = `<span $1 class="${cssClasses}">${promptChar}</span>`;
99
+ const linePrefix = '<span class="line[^>]+?>';
100
+ const splitPrompt = new RegExp(
101
+ `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\${promptChar}\\s+?([^<]))`
102
+ );
103
+ const trimWhitespace = new RegExp(
104
+ `(?<=${linePrefix})(?:<span (style="[^"]*?")>\\s*?\\${promptChar}\\s*?<\\/span>(?:<span>\\s+<\\/span>)?)`
105
+ );
106
+ const trimWhitespaceAhead = new RegExp(
107
+ `(?<=${linePrefix}<span [^>]+?>\\${promptChar}<\\/span>)(<span style="[^"]+?">)\\s+?`
108
+ );
109
+ return {
110
+ line(hast) {
111
+ if (language !== "console") return;
112
+ const textNode = hast.children.at(0)?.children.at(0);
113
+ if (textNode && textNode.type === "text") {
114
+ const leadingChar = textNode.value;
115
+ if (!leadingChar.startsWith(promptChar)) {
116
+ textNode.value = promptChar + " " + textNode.value;
117
+ }
118
+ }
119
+ },
120
+ postprocess: (html) => {
121
+ if (language !== "console") return;
113
122
  return html.split("\n").map((line) => {
114
123
  return line.replace(
115
124
  splitPrompt,
@@ -117,11 +126,11 @@ function transformConsoleCodeBlock(options = {
117
126
  ).replace(trimWhitespace, unselectablePrompt).replace(trimWhitespaceAhead, "$1");
118
127
  }).join("\n");
119
128
  }
120
- }
129
+ };
121
130
  };
122
- }
131
+ };
123
132
  // Annotate the CommonJS export names for ESM import in node:
124
133
  0 && (module.exports = {
125
134
  transformAsciidocCallout,
126
- transformConsoleCodeBlock
135
+ transformConsolePrompt
127
136
  });
@@ -1,43 +1,34 @@
1
- import { Block } from 'asciidoctor';
2
- import { ShikiTransformer } from 'shiki';
3
- import { ShikiTransformer as ShikiTransformer$1 } from 'shiki/types';
1
+ import { b as ShikiTransformerFactory } from '../../../index-sFlXF8Qm.cjs';
2
+ import 'shiki';
3
+ import 'asciidoctor';
4
+ import 'astro/zod';
4
5
 
5
- type TransformOptions$1 = {
6
- /**
7
- * Instance of Asciidoc's Block element to act upon.
8
- */
9
- node: Block;
10
- /**
11
- * String of CSS classes to apply to Asciidoc callout elements.
12
- * Note: this does not override Asciidoctor's default class "conum"
13
- * that applies to callout elements.
14
- *
15
- * @default pointer-events-none select-none ml-2
16
- */
6
+ type TransformerOptions = Partial<{
17
7
  cssClasses?: string;
18
- };
19
- /**
20
- * Transforms source code blocks by converting Asciidoc's callout annotations
21
- * into unselectable tokens.
22
- */
23
- declare function transformAsciidocCallout({ node, cssClasses, }: TransformOptions$1): ShikiTransformer;
8
+ }>;
9
+ declare const transformAsciidocCallout: ShikiTransformerFactory<TransformerOptions>;
24
10
 
25
11
  type TransformOptions = {
26
12
  /**
27
- * String of CSS classes to apply to leading '$' character on console
28
- * code blocks. By default, this transformer makes it unselectable and
29
- * applies 50% opacity.
13
+ * String of CSS classes to apply to leading prompt character(s) on
14
+ * source code blocks of type console.
15
+ */
16
+ cssClasses: string;
17
+ /**
18
+ * The prompt character representing the actual console prompt.
30
19
  *
31
- * @default pointer-events-none select-none mr-2 opacity-50
20
+ * @default $
32
21
  */
33
- cssClasses?: string;
22
+ promptChar?: string;
34
23
  };
35
24
  /**
36
- * For code blocks of language "console", makes the leading prompt
37
- * character "$" unselectable, as it often leads to confusion when
38
- * copying the command and running with the preceding prompt.
25
+ * For code blocks of language "console", prepends each line with a
26
+ * prompt character(s), where applicable. By default, a "$" is used but
27
+ * this can be controlled via the *promptChar* option.
28
+ * Use the *cssClasses* option to style this prompt for things like
29
+ * making it unselectable, or dimmed..
39
30
  *
40
- * Likewise, the leading spaces before the actual command are deleted
31
+ * In addition, the leading spaces before the actual command are deleted
41
32
  * from the span elements generated by Shiki to avoid accidentally
42
33
  * running commands that would not appear in the shell history.
43
34
  *
@@ -54,6 +45,6 @@ type TransformOptions = {
54
45
  * before: <span>$</span><span> npm run dev</span>
55
46
  * after: <span>$</span><span>npm run dev</span>
56
47
  */
57
- declare function transformConsoleCodeBlock(options?: TransformOptions): ShikiTransformer$1;
48
+ declare const transformConsolePrompt: ShikiTransformerFactory<TransformOptions>;
58
49
 
59
- export { transformAsciidocCallout, transformConsoleCodeBlock };
50
+ export { transformAsciidocCallout, transformConsolePrompt };