@d10f/asciidoc-astro-loader 0.0.1
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/LICENSE +21 -0
- package/README.md +286 -0
- package/dist/chunk-2F52PMNV.js +132 -0
- package/dist/chunk-DDIUST2Z.js +113 -0
- package/dist/chunk-HAZIHU2Y.js +56 -0
- package/dist/index-Cf7MF6tZ.d.cts +325 -0
- package/dist/index-Cf7MF6tZ.d.ts +325 -0
- package/dist/index.cjs +708 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +402 -0
- package/dist/lib/asciidoc/converters/index.cjs +178 -0
- package/dist/lib/asciidoc/converters/index.d.cts +13 -0
- package/dist/lib/asciidoc/converters/index.d.ts +13 -0
- package/dist/lib/asciidoc/converters/index.js +7 -0
- package/dist/lib/asciidoc/templates/engines/index.cjs +191 -0
- package/dist/lib/asciidoc/templates/engines/index.d.cts +30 -0
- package/dist/lib/asciidoc/templates/engines/index.d.ts +30 -0
- package/dist/lib/asciidoc/templates/engines/index.js +30 -0
- package/dist/lib/shiki/transformers/index.cjs +127 -0
- package/dist/lib/shiki/transformers/index.d.cts +59 -0
- package/dist/lib/shiki/transformers/index.d.ts +59 -0
- package/dist/lib/shiki/transformers/index.js +8 -0
- package/package.json +58 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/lib/asciidoc/templates/engines/index.ts
|
|
31
|
+
var engines_exports = {};
|
|
32
|
+
__export(engines_exports, {
|
|
33
|
+
AbstractEngine: () => AbstractEngine,
|
|
34
|
+
HandlebarsEngine: () => HandlebarsEngine,
|
|
35
|
+
NunjucksEngine: () => NunjucksEngine,
|
|
36
|
+
PhpEngine: () => PhpEngine
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(engines_exports);
|
|
39
|
+
|
|
40
|
+
// src/lib/asciidoc/templates/engines/Base.ts
|
|
41
|
+
var AbstractEngine = class {
|
|
42
|
+
constructor(_name, _extensions) {
|
|
43
|
+
this._name = _name;
|
|
44
|
+
this._extensions = _extensions;
|
|
45
|
+
this.templateList = /* @__PURE__ */ new Map();
|
|
46
|
+
}
|
|
47
|
+
templateList;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the given name to this template engine.
|
|
50
|
+
*/
|
|
51
|
+
get name() {
|
|
52
|
+
return this._name;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the list of extensions this template engine supports.
|
|
56
|
+
*/
|
|
57
|
+
get extensions() {
|
|
58
|
+
return this._extensions;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Accessor method to check if instance implements the
|
|
62
|
+
* TemplateModule interface.
|
|
63
|
+
*/
|
|
64
|
+
get canLoad() {
|
|
65
|
+
return "load" in this && typeof this.load === "function";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Accessor method to check if instance implements the
|
|
69
|
+
* AsciidocTemplate interface.
|
|
70
|
+
*/
|
|
71
|
+
get canRenderNode() {
|
|
72
|
+
return "renderNode" in this && typeof this.renderNode === "function";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Accessor method to check if instance implements the
|
|
76
|
+
* FilesystemTemplate interface.
|
|
77
|
+
*/
|
|
78
|
+
get canRenderFile() {
|
|
79
|
+
return "renderFile" in this && typeof this.renderFile === "function";
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Accessor method to check if instance implements the
|
|
83
|
+
* RawTemplate interface.
|
|
84
|
+
*/
|
|
85
|
+
get canRenderString() {
|
|
86
|
+
return "renderString" in this && typeof this.renderString === "function";
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Appends a new context that this template engine will act upon.
|
|
90
|
+
*/
|
|
91
|
+
addContext(context, filepath) {
|
|
92
|
+
this.templateList.set(context, filepath);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Verifies whether the specified context is being tracked or not.
|
|
96
|
+
*/
|
|
97
|
+
hasContext(context) {
|
|
98
|
+
return typeof context === "string" ? this.templateList.has(context) : this.templateList.has(context.getNodeName());
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Verifies if the specified file extension is supported
|
|
102
|
+
* by this template engine.
|
|
103
|
+
*/
|
|
104
|
+
supportsExt(extension) {
|
|
105
|
+
return this.extensions.includes(extension);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/lib/asciidoc/templates/engines/Handlebars.ts
|
|
110
|
+
var import_node_fs = require("fs");
|
|
111
|
+
var HandlebarsEngine = class extends AbstractEngine {
|
|
112
|
+
render;
|
|
113
|
+
constructor(name = "handlebars", extensions = ["handlebars", "hbs"]) {
|
|
114
|
+
super(name, extensions);
|
|
115
|
+
this.render = null;
|
|
116
|
+
}
|
|
117
|
+
async load() {
|
|
118
|
+
const Handlebars = await import("handlebars");
|
|
119
|
+
this.render = (input, opts) => {
|
|
120
|
+
return Handlebars.default.compile(input)(opts);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
renderNode(node, options = {}) {
|
|
124
|
+
const context = node.getNodeName();
|
|
125
|
+
return this.renderFile(this.templateList.get(context), options);
|
|
126
|
+
}
|
|
127
|
+
renderFile(filepath, options = {}) {
|
|
128
|
+
const fileContents = (0, import_node_fs.readFileSync)(filepath, { encoding: "utf8" });
|
|
129
|
+
return this.renderString(fileContents, options);
|
|
130
|
+
}
|
|
131
|
+
renderString(str, options = {}) {
|
|
132
|
+
if (this.render === null) {
|
|
133
|
+
throw new Error("This template doesn't have a render method!");
|
|
134
|
+
}
|
|
135
|
+
return this.render(str, options);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// src/lib/asciidoc/templates/engines/Nunjucks.ts
|
|
140
|
+
var import_node_fs2 = require("fs");
|
|
141
|
+
var NunjucksEngine = class extends AbstractEngine {
|
|
142
|
+
render;
|
|
143
|
+
constructor(name = "nunjucks", extensions = ["nunjucks", "njk"]) {
|
|
144
|
+
super(name, extensions);
|
|
145
|
+
this.render = null;
|
|
146
|
+
}
|
|
147
|
+
async load() {
|
|
148
|
+
const nunjucks = await import("nunjucks");
|
|
149
|
+
this.render = nunjucks.default.renderString;
|
|
150
|
+
}
|
|
151
|
+
renderNode(node, options = {}) {
|
|
152
|
+
const context = node.getNodeName();
|
|
153
|
+
return this.renderFile(this.templateList.get(context), options);
|
|
154
|
+
}
|
|
155
|
+
renderFile(filepath, options = {}) {
|
|
156
|
+
const fileContents = (0, import_node_fs2.readFileSync)(filepath, { encoding: "utf8" });
|
|
157
|
+
return this.renderString(fileContents, options);
|
|
158
|
+
}
|
|
159
|
+
renderString(str, options = {}) {
|
|
160
|
+
if (this.render === null) {
|
|
161
|
+
throw new Error("This template doesn't have a render method!");
|
|
162
|
+
}
|
|
163
|
+
return this.render(str, options);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/lib/asciidoc/templates/engines/Php.ts
|
|
168
|
+
var import_php_node = require("@platformatic/php-node");
|
|
169
|
+
var PhpEngine = class extends AbstractEngine {
|
|
170
|
+
server;
|
|
171
|
+
constructor(name = "php", extensions = ["php"], docroot) {
|
|
172
|
+
super(name, extensions);
|
|
173
|
+
this.server = new import_php_node.Php({ docroot });
|
|
174
|
+
}
|
|
175
|
+
renderFile(filepath, options) {
|
|
176
|
+
const request = new import_php_node.Request({
|
|
177
|
+
method: "POST",
|
|
178
|
+
url: "http://localhost/" + filepath,
|
|
179
|
+
body: Buffer.from(JSON.stringify(options))
|
|
180
|
+
});
|
|
181
|
+
const response = this.server.handleRequestSync(request);
|
|
182
|
+
return response.body.toString();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
186
|
+
0 && (module.exports = {
|
|
187
|
+
AbstractEngine,
|
|
188
|
+
HandlebarsEngine,
|
|
189
|
+
NunjucksEngine,
|
|
190
|
+
PhpEngine
|
|
191
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-Cf7MF6tZ.cjs';
|
|
2
|
+
import { AbstractNode } from 'asciidoctor';
|
|
3
|
+
import 'shiki';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
7
|
+
private render;
|
|
8
|
+
constructor(name?: string, extensions?: string[]);
|
|
9
|
+
load(): Promise<void>;
|
|
10
|
+
renderNode(node: AbstractNode, options?: Record<string, unknown>): string;
|
|
11
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
12
|
+
renderString(str: string, options?: Record<string, unknown>): string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class NunjucksEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
16
|
+
private render;
|
|
17
|
+
constructor(name?: string, extensions?: string[]);
|
|
18
|
+
load(): Promise<void>;
|
|
19
|
+
renderNode(node: AbstractNode, options?: Record<string, unknown>): string;
|
|
20
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
21
|
+
renderString(str: string, options?: Record<string, unknown>): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class PhpEngine extends AbstractEngine implements FilesystemTemplate {
|
|
25
|
+
private server;
|
|
26
|
+
constructor(name: string | undefined, extensions: string[] | undefined, docroot: string);
|
|
27
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { AbstractEngine, HandlebarsEngine, NunjucksEngine, PhpEngine };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { b as AbstractEngine, a as AsciidocTemplate, T as TemplateModule, F as FilesystemTemplate, R as RawTemplate } from '../../../../index-Cf7MF6tZ.js';
|
|
2
|
+
import { AbstractNode } from 'asciidoctor';
|
|
3
|
+
import 'shiki';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
declare class HandlebarsEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
7
|
+
private render;
|
|
8
|
+
constructor(name?: string, extensions?: string[]);
|
|
9
|
+
load(): Promise<void>;
|
|
10
|
+
renderNode(node: AbstractNode, options?: Record<string, unknown>): string;
|
|
11
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
12
|
+
renderString(str: string, options?: Record<string, unknown>): string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class NunjucksEngine extends AbstractEngine implements AsciidocTemplate, TemplateModule, FilesystemTemplate, RawTemplate {
|
|
16
|
+
private render;
|
|
17
|
+
constructor(name?: string, extensions?: string[]);
|
|
18
|
+
load(): Promise<void>;
|
|
19
|
+
renderNode(node: AbstractNode, options?: Record<string, unknown>): string;
|
|
20
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
21
|
+
renderString(str: string, options?: Record<string, unknown>): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class PhpEngine extends AbstractEngine implements FilesystemTemplate {
|
|
25
|
+
private server;
|
|
26
|
+
constructor(name: string | undefined, extensions: string[] | undefined, docroot: string);
|
|
27
|
+
renderFile(filepath: string, options?: Record<string, unknown>): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { AbstractEngine, HandlebarsEngine, NunjucksEngine, PhpEngine };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractEngine,
|
|
3
|
+
HandlebarsEngine,
|
|
4
|
+
NunjucksEngine
|
|
5
|
+
} from "../../../../chunk-2F52PMNV.js";
|
|
6
|
+
|
|
7
|
+
// src/lib/asciidoc/templates/engines/Php.ts
|
|
8
|
+
import { Php, Request } from "@platformatic/php-node";
|
|
9
|
+
var PhpEngine = class extends AbstractEngine {
|
|
10
|
+
server;
|
|
11
|
+
constructor(name = "php", extensions = ["php"], docroot) {
|
|
12
|
+
super(name, extensions);
|
|
13
|
+
this.server = new Php({ docroot });
|
|
14
|
+
}
|
|
15
|
+
renderFile(filepath, options) {
|
|
16
|
+
const request = new Request({
|
|
17
|
+
method: "POST",
|
|
18
|
+
url: "http://localhost/" + filepath,
|
|
19
|
+
body: Buffer.from(JSON.stringify(options))
|
|
20
|
+
});
|
|
21
|
+
const response = this.server.handleRequestSync(request);
|
|
22
|
+
return response.body.toString();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
AbstractEngine,
|
|
27
|
+
HandlebarsEngine,
|
|
28
|
+
NunjucksEngine,
|
|
29
|
+
PhpEngine
|
|
30
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/shiki/transformers/index.ts
|
|
21
|
+
var transformers_exports = {};
|
|
22
|
+
__export(transformers_exports, {
|
|
23
|
+
transformAsciidocCallout: () => transformAsciidocCallout,
|
|
24
|
+
transformConsoleCodeBlock: () => transformConsoleCodeBlock
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(transformers_exports);
|
|
27
|
+
|
|
28
|
+
// src/lib/utils.ts
|
|
29
|
+
function escapeRegexCharacters(str) {
|
|
30
|
+
const re = /[-\\^$*+?.()|\[\]{}]/g;
|
|
31
|
+
return str.replace(re, "\\$&");
|
|
32
|
+
}
|
|
33
|
+
|
|
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
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
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") {
|
|
113
|
+
return html.split("\n").map((line) => {
|
|
114
|
+
return line.replace(
|
|
115
|
+
splitPrompt,
|
|
116
|
+
unselectablePrompt + "<span $1>$2"
|
|
117
|
+
).replace(trimWhitespace, unselectablePrompt).replace(trimWhitespaceAhead, "$1");
|
|
118
|
+
}).join("\n");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
transformAsciidocCallout,
|
|
126
|
+
transformConsoleCodeBlock
|
|
127
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Block } from 'asciidoctor';
|
|
2
|
+
import { ShikiTransformer } from 'shiki';
|
|
3
|
+
import { ShikiTransformer as ShikiTransformer$1 } from 'shiki/types';
|
|
4
|
+
|
|
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
|
+
*/
|
|
17
|
+
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;
|
|
24
|
+
|
|
25
|
+
type TransformOptions = {
|
|
26
|
+
/**
|
|
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.
|
|
30
|
+
*
|
|
31
|
+
* @default pointer-events-none select-none mr-2 opacity-50
|
|
32
|
+
*/
|
|
33
|
+
cssClasses?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
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.
|
|
39
|
+
*
|
|
40
|
+
* Likewise, the leading spaces before the actual command are deleted
|
|
41
|
+
* from the span elements generated by Shiki to avoid accidentally
|
|
42
|
+
* running commands that would not appear in the shell history.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* before: <span>$ npm run dev</span>
|
|
46
|
+
* after: <span>$</span><span>npm run dev</span>
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* before: <span> $ </span><span> </span>
|
|
50
|
+
* before: <span> $ </span>
|
|
51
|
+
* after: <span>$</span>
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* before: <span>$</span><span> npm run dev</span>
|
|
55
|
+
* after: <span>$</span><span>npm run dev</span>
|
|
56
|
+
*/
|
|
57
|
+
declare function transformConsoleCodeBlock(options?: TransformOptions): ShikiTransformer$1;
|
|
58
|
+
|
|
59
|
+
export { transformAsciidocCallout, transformConsoleCodeBlock };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Block } from 'asciidoctor';
|
|
2
|
+
import { ShikiTransformer } from 'shiki';
|
|
3
|
+
import { ShikiTransformer as ShikiTransformer$1 } from 'shiki/types';
|
|
4
|
+
|
|
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
|
+
*/
|
|
17
|
+
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;
|
|
24
|
+
|
|
25
|
+
type TransformOptions = {
|
|
26
|
+
/**
|
|
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.
|
|
30
|
+
*
|
|
31
|
+
* @default pointer-events-none select-none mr-2 opacity-50
|
|
32
|
+
*/
|
|
33
|
+
cssClasses?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
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.
|
|
39
|
+
*
|
|
40
|
+
* Likewise, the leading spaces before the actual command are deleted
|
|
41
|
+
* from the span elements generated by Shiki to avoid accidentally
|
|
42
|
+
* running commands that would not appear in the shell history.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* before: <span>$ npm run dev</span>
|
|
46
|
+
* after: <span>$</span><span>npm run dev</span>
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* before: <span> $ </span><span> </span>
|
|
50
|
+
* before: <span> $ </span>
|
|
51
|
+
* after: <span>$</span>
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* before: <span>$</span><span> npm run dev</span>
|
|
55
|
+
* after: <span>$</span><span>npm run dev</span>
|
|
56
|
+
*/
|
|
57
|
+
declare function transformConsoleCodeBlock(options?: TransformOptions): ShikiTransformer$1;
|
|
58
|
+
|
|
59
|
+
export { transformAsciidocCallout, transformConsoleCodeBlock };
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@d10f/asciidoc-astro-loader",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An Astro collections loader for Asciidoc files",
|
|
5
|
+
"author": "D10f",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://codeberg.org/d10f/asciidoc-astro-loader",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://codeberg.org/d10f/asciidoc-astro-loader.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://codeberg.org/d10f/asciidoc-astro-loader/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"asciidoc",
|
|
17
|
+
"asciidoctor",
|
|
18
|
+
"astro",
|
|
19
|
+
"loader",
|
|
20
|
+
"collections"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"dev": "vitest"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.js",
|
|
34
|
+
"./engines": "./dist/lib/asciidoc/templates/engines/index.js",
|
|
35
|
+
"./converters": "./dist/lib/asciidoc/converters/index.js",
|
|
36
|
+
"./transformers": "./dist/lib/shiki/transformers/index.js"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"eslint": "^9.36.0",
|
|
40
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
41
|
+
"globals": "^16.4.0",
|
|
42
|
+
"jiti": "^2.6.1",
|
|
43
|
+
"memfs": "^4.49.0",
|
|
44
|
+
"prettier": "^3.6.2",
|
|
45
|
+
"tsup": "^8.5.0",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"typescript-eslint": "^8.45.0",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@shikijs/transformers": "^3.13.0",
|
|
52
|
+
"asciidoctor": "^3.0.4",
|
|
53
|
+
"astro": "^5.14.6",
|
|
54
|
+
"shiki": "^3.13.0",
|
|
55
|
+
"ventojs": "^2.2.0",
|
|
56
|
+
"zod": "^4.1.12"
|
|
57
|
+
}
|
|
58
|
+
}
|