@tamagui/code-to-html 1.114.3 → 1.115.0
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/cjs/highlightLine.cjs +111 -0
- package/dist/cjs/highlightWord.cjs +47 -0
- package/dist/cjs/{index.js → index.cjs} +29 -15
- package/package.json +2 -2
- package/dist/cjs/highlightLine.js +0 -98
- package/dist/cjs/highlightWord.js +0 -37
- /package/dist/cjs/{highlightLine.js.map → highlightLine.cjs.map} +0 -0
- /package/dist/cjs/{highlightWord.js.map → highlightWord.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
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", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var highlightLine_exports = {};
|
|
33
|
+
__export(highlightLine_exports, {
|
|
34
|
+
highlightLine: () => highlightLine
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(highlightLine_exports);
|
|
37
|
+
var import_hast_util_to_html = require("hast-util-to-html"),
|
|
38
|
+
import_rehype_parse = __toESM(require("rehype-parse")),
|
|
39
|
+
import_unified = require("unified");
|
|
40
|
+
const lineNumberify = function lineNumberify2(ast, lineNum = 1) {
|
|
41
|
+
let lineNumber = lineNum;
|
|
42
|
+
return ast.reduce((result, node) => {
|
|
43
|
+
if (node.type === "text") {
|
|
44
|
+
if (node.value.indexOf(`
|
|
45
|
+
`) === -1) return node.lineNumber = lineNumber, result.nodes.push(node), result;
|
|
46
|
+
const lines = node.value.split(`
|
|
47
|
+
`);
|
|
48
|
+
for (let i = 0; i < lines.length; i++) i !== 0 && ++lineNumber, !(i === lines.length - 1 && lines[i].length === 0) && result.nodes.push({
|
|
49
|
+
type: "text",
|
|
50
|
+
value: i === lines.length - 1 ? lines[i] : `${lines[i]}
|
|
51
|
+
`,
|
|
52
|
+
lineNumber
|
|
53
|
+
});
|
|
54
|
+
return result.lineNumber = lineNumber, result;
|
|
55
|
+
}
|
|
56
|
+
if (node.children) {
|
|
57
|
+
node.lineNumber = lineNumber;
|
|
58
|
+
const processed = lineNumberify2(node.children, lineNumber);
|
|
59
|
+
return node.children = processed.nodes, result.lineNumber = processed.lineNumber, result.nodes.push(node), result;
|
|
60
|
+
}
|
|
61
|
+
return result.nodes.push(node), result;
|
|
62
|
+
}, {
|
|
63
|
+
nodes: [],
|
|
64
|
+
lineNumber
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
wrapLines = function (ast, linesToHighlight) {
|
|
68
|
+
const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0,
|
|
69
|
+
allLines = Array.from(new Set(ast.map(x => x.lineNumber)));
|
|
70
|
+
let i = 0;
|
|
71
|
+
return allLines.reduce((nodes, marker) => {
|
|
72
|
+
const line = marker,
|
|
73
|
+
children = [];
|
|
74
|
+
for (; i < ast.length; i++) {
|
|
75
|
+
if (ast[i].lineNumber < line) {
|
|
76
|
+
nodes.push(ast[i]);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (ast[i].lineNumber === line) {
|
|
80
|
+
children.push(ast[i]);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (ast[i].lineNumber > line) break;
|
|
84
|
+
}
|
|
85
|
+
return nodes.push({
|
|
86
|
+
type: "element",
|
|
87
|
+
tagName: "div",
|
|
88
|
+
properties: {
|
|
89
|
+
dataLine: line,
|
|
90
|
+
className: "highlight-line",
|
|
91
|
+
dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
|
|
92
|
+
},
|
|
93
|
+
children,
|
|
94
|
+
lineNumber: line
|
|
95
|
+
}), nodes;
|
|
96
|
+
}, []);
|
|
97
|
+
},
|
|
98
|
+
MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g,
|
|
99
|
+
applyMultilineFix = ast => {
|
|
100
|
+
let html = (0, import_hast_util_to_html.toHtml)(ast);
|
|
101
|
+
return html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) => match.replace(/\n/g, `</span>
|
|
102
|
+
<span class="token ${token}">`)), (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
103
|
+
emitParseErrors: !0,
|
|
104
|
+
fragment: !0
|
|
105
|
+
}).parse(html).children;
|
|
106
|
+
};
|
|
107
|
+
function highlightLine(ast, lines) {
|
|
108
|
+
const formattedAst = applyMultilineFix(ast),
|
|
109
|
+
numbered = lineNumberify(formattedAst).nodes;
|
|
110
|
+
return wrapLines(numbered, lines);
|
|
111
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
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", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var highlightWord_exports = {};
|
|
33
|
+
__export(highlightWord_exports, {
|
|
34
|
+
highlightWord: () => highlightWord
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(highlightWord_exports);
|
|
37
|
+
var import_hast_util_to_html = require("hast-util-to-html"),
|
|
38
|
+
import_rehype_parse = __toESM(require("rehype-parse")),
|
|
39
|
+
import_unified = require("unified");
|
|
40
|
+
const CALLOUT = /__(.*?)__/g;
|
|
41
|
+
function highlightWord(code) {
|
|
42
|
+
const result = (0, import_hast_util_to_html.toHtml)(code).replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`);
|
|
43
|
+
return (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
44
|
+
emitParseErrors: !0,
|
|
45
|
+
fragment: !0
|
|
46
|
+
}).parse(result).children;
|
|
47
|
+
}
|
|
@@ -2,34 +2,48 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
15
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
18
23
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
24
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
23
32
|
var src_exports = {};
|
|
24
33
|
__export(src_exports, {
|
|
25
34
|
codeToHTML: () => codeToHTML
|
|
26
35
|
});
|
|
27
36
|
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
var import_hast_util_to_html = require("hast-util-to-html"),
|
|
37
|
+
var import_hast_util_to_html = require("hast-util-to-html"),
|
|
38
|
+
import_parse_numeric_range = __toESM(require("parse-numeric-range")),
|
|
39
|
+
import_refractor = require("refractor"),
|
|
40
|
+
import_css = __toESM(require("refractor/lang/css")),
|
|
41
|
+
import_tsx = __toESM(require("refractor/lang/tsx")),
|
|
42
|
+
import_highlightLine = require("./highlightLine.cjs"),
|
|
43
|
+
import_highlightWord = require("./highlightWord.cjs");
|
|
29
44
|
import_refractor.refractor.register(import_tsx.default);
|
|
30
45
|
import_refractor.refractor.register(import_css.default);
|
|
31
46
|
function codeToHTML(source, language, line = "0") {
|
|
32
47
|
let result = import_refractor.refractor.highlight(source, language);
|
|
33
48
|
return result = (0, import_highlightLine.highlightLine)(result, (0, import_parse_numeric_range.default)(line)), result = (0, import_highlightWord.highlightWord)(result), result = (0, import_hast_util_to_html.toHtml)(result), result;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/code-to-html",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "^0.11.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tamagui/build": "1.
|
|
33
|
+
"@tamagui/build": "1.115.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var highlightLine_exports = {};
|
|
24
|
-
__export(highlightLine_exports, {
|
|
25
|
-
highlightLine: () => highlightLine
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(highlightLine_exports);
|
|
28
|
-
var import_hast_util_to_html = require("hast-util-to-html"), import_rehype_parse = __toESM(require("rehype-parse")), import_unified = require("unified");
|
|
29
|
-
const lineNumberify = function lineNumberify2(ast, lineNum = 1) {
|
|
30
|
-
let lineNumber = lineNum;
|
|
31
|
-
return ast.reduce(
|
|
32
|
-
(result, node) => {
|
|
33
|
-
if (node.type === "text") {
|
|
34
|
-
if (node.value.indexOf(`
|
|
35
|
-
`) === -1)
|
|
36
|
-
return node.lineNumber = lineNumber, result.nodes.push(node), result;
|
|
37
|
-
const lines = node.value.split(`
|
|
38
|
-
`);
|
|
39
|
-
for (let i = 0; i < lines.length; i++)
|
|
40
|
-
i !== 0 && ++lineNumber, !(i === lines.length - 1 && lines[i].length === 0) && result.nodes.push({
|
|
41
|
-
type: "text",
|
|
42
|
-
value: i === lines.length - 1 ? lines[i] : `${lines[i]}
|
|
43
|
-
`,
|
|
44
|
-
lineNumber
|
|
45
|
-
});
|
|
46
|
-
return result.lineNumber = lineNumber, result;
|
|
47
|
-
}
|
|
48
|
-
if (node.children) {
|
|
49
|
-
node.lineNumber = lineNumber;
|
|
50
|
-
const processed = lineNumberify2(node.children, lineNumber);
|
|
51
|
-
return node.children = processed.nodes, result.lineNumber = processed.lineNumber, result.nodes.push(node), result;
|
|
52
|
-
}
|
|
53
|
-
return result.nodes.push(node), result;
|
|
54
|
-
},
|
|
55
|
-
{ nodes: [], lineNumber }
|
|
56
|
-
);
|
|
57
|
-
}, wrapLines = function(ast, linesToHighlight) {
|
|
58
|
-
const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0, allLines = Array.from(new Set(ast.map((x) => x.lineNumber)));
|
|
59
|
-
let i = 0;
|
|
60
|
-
return allLines.reduce((nodes, marker) => {
|
|
61
|
-
const line = marker, children = [];
|
|
62
|
-
for (; i < ast.length; i++) {
|
|
63
|
-
if (ast[i].lineNumber < line) {
|
|
64
|
-
nodes.push(ast[i]);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (ast[i].lineNumber === line) {
|
|
68
|
-
children.push(ast[i]);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (ast[i].lineNumber > line)
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
return nodes.push({
|
|
75
|
-
type: "element",
|
|
76
|
-
tagName: "div",
|
|
77
|
-
properties: {
|
|
78
|
-
dataLine: line,
|
|
79
|
-
className: "highlight-line",
|
|
80
|
-
dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
|
|
81
|
-
},
|
|
82
|
-
children,
|
|
83
|
-
lineNumber: line
|
|
84
|
-
}), nodes;
|
|
85
|
-
}, []);
|
|
86
|
-
}, MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g, applyMultilineFix = (ast) => {
|
|
87
|
-
let html = (0, import_hast_util_to_html.toHtml)(ast);
|
|
88
|
-
return html = html.replace(
|
|
89
|
-
MULTILINE_TOKEN_SPAN,
|
|
90
|
-
(match, token) => match.replace(/\n/g, `</span>
|
|
91
|
-
<span class="token ${token}">`)
|
|
92
|
-
), (0, import_unified.unified)().use(import_rehype_parse.default, { emitParseErrors: !0, fragment: !0 }).parse(html).children;
|
|
93
|
-
};
|
|
94
|
-
function highlightLine(ast, lines) {
|
|
95
|
-
const formattedAst = applyMultilineFix(ast), numbered = lineNumberify(formattedAst).nodes;
|
|
96
|
-
return wrapLines(numbered, lines);
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=highlightLine.js.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var highlightWord_exports = {};
|
|
24
|
-
__export(highlightWord_exports, {
|
|
25
|
-
highlightWord: () => highlightWord
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(highlightWord_exports);
|
|
28
|
-
var import_hast_util_to_html = require("hast-util-to-html"), import_rehype_parse = __toESM(require("rehype-parse")), import_unified = require("unified");
|
|
29
|
-
const CALLOUT = /__(.*?)__/g;
|
|
30
|
-
function highlightWord(code) {
|
|
31
|
-
const result = (0, import_hast_util_to_html.toHtml)(code).replace(
|
|
32
|
-
CALLOUT,
|
|
33
|
-
(_, text) => `<span class="highlight-word">${text}</span>`
|
|
34
|
-
);
|
|
35
|
-
return (0, import_unified.unified)().use(import_rehype_parse.default, { emitParseErrors: !0, fragment: !0 }).parse(result).children;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=highlightWord.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|