@tamagui/code-to-html 2.0.0-rc.35 → 2.0.0-rc.36-1775243248161
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 +104 -85
- package/dist/cjs/highlightLine.native.js +109 -90
- package/dist/cjs/highlightLine.native.js.map +1 -1
- package/dist/cjs/highlightWord.cjs +34 -30
- package/dist/cjs/highlightWord.native.js +37 -35
- package/dist/cjs/highlightWord.native.js.map +1 -1
- package/dist/cjs/index.cjs +35 -30
- package/dist/cjs/index.native.js +37 -32
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/highlightLine.mjs +77 -60
- package/dist/esm/highlightLine.mjs.map +1 -1
- package/dist/esm/highlightLine.native.js +81 -64
- package/dist/esm/highlightLine.native.js.map +1 -1
- package/dist/esm/highlightWord.mjs +7 -5
- package/dist/esm/highlightWord.mjs.map +1 -1
- package/dist/esm/highlightWord.native.js +9 -9
- package/dist/esm/highlightWord.native.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +6 -3
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,110 +2,129 @@ 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
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var highlightLine_exports = {};
|
|
33
35
|
__export(highlightLine_exports, {
|
|
34
36
|
highlightLine: () => highlightLine
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(highlightLine_exports);
|
|
37
|
-
var import_hast_util_to_html = require("hast-util-to-html")
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
var import_hast_util_to_html = require("hast-util-to-html");
|
|
40
|
+
var import_rehype_parse = __toESM(require("rehype-parse"));
|
|
41
|
+
var import_unified = require("unified");
|
|
40
42
|
const lineNumberify = function lineNumberify2(ast, lineNum = 1) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
let lineNumber = lineNum;
|
|
44
|
+
return ast.reduce((result, node) => {
|
|
45
|
+
if (node.type === "text") {
|
|
46
|
+
if (node.value.indexOf("\n") === -1) {
|
|
47
|
+
node.lineNumber = lineNumber;
|
|
48
|
+
result.nodes.push(node);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
const lines = node.value.split("\n");
|
|
52
|
+
for (let i = 0; i < lines.length; i++) {
|
|
53
|
+
if (i !== 0) ++lineNumber;
|
|
54
|
+
if (i === lines.length - 1 && lines[i].length === 0) continue;
|
|
55
|
+
result.nodes.push({
|
|
49
56
|
type: "text",
|
|
50
57
|
value: i === lines.length - 1 ? lines[i] : `${lines[i]}
|
|
51
58
|
`,
|
|
52
59
|
lineNumber
|
|
53
60
|
});
|
|
54
|
-
return result.lineNumber = lineNumber, result;
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
result.lineNumber = lineNumber;
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
if (node.children) {
|
|
66
|
+
node.lineNumber = lineNumber;
|
|
67
|
+
const processed = lineNumberify2(node.children, lineNumber);
|
|
68
|
+
node.children = processed.nodes;
|
|
69
|
+
result.lineNumber = processed.lineNumber;
|
|
70
|
+
result.nodes.push(node);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
result.nodes.push(node);
|
|
74
|
+
return result;
|
|
75
|
+
}, {
|
|
76
|
+
nodes: [],
|
|
77
|
+
lineNumber
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const wrapLines = function wrapLines2(ast, linesToHighlight) {
|
|
81
|
+
const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;
|
|
82
|
+
const allLines = Array.from(new Set(ast.map(x => x.lineNumber)));
|
|
83
|
+
let i = 0;
|
|
84
|
+
const wrapped = allLines.reduce((nodes, marker) => {
|
|
85
|
+
const line = marker;
|
|
86
|
+
const children = [];
|
|
87
|
+
for (; i < ast.length; i++) {
|
|
88
|
+
if (ast[i].lineNumber < line) {
|
|
89
|
+
nodes.push(ast[i]);
|
|
90
|
+
continue;
|
|
60
91
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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;
|
|
92
|
+
if (ast[i].lineNumber === line) {
|
|
93
|
+
children.push(ast[i]);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (ast[i].lineNumber > line) {
|
|
97
|
+
break;
|
|
84
98
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
}
|
|
100
|
+
nodes.push({
|
|
101
|
+
type: "element",
|
|
102
|
+
tagName: "div",
|
|
103
|
+
properties: {
|
|
104
|
+
dataLine: line,
|
|
105
|
+
className: "highlight-line",
|
|
106
|
+
dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
|
|
107
|
+
},
|
|
108
|
+
children,
|
|
109
|
+
lineNumber: line
|
|
110
|
+
});
|
|
111
|
+
return nodes;
|
|
112
|
+
}, []);
|
|
113
|
+
return wrapped;
|
|
114
|
+
};
|
|
115
|
+
const MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g;
|
|
116
|
+
const applyMultilineFix = ast => {
|
|
117
|
+
let html = (0, import_hast_util_to_html.toHtml)(ast);
|
|
118
|
+
html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) => match.replace(/\n/g, `</span>
|
|
119
|
+
<span class="token ${token}">`));
|
|
120
|
+
const hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
121
|
+
emitParseErrors: true,
|
|
122
|
+
fragment: true
|
|
123
|
+
}).parse(html);
|
|
124
|
+
return hast["children"];
|
|
125
|
+
};
|
|
107
126
|
function highlightLine(ast, lines) {
|
|
108
|
-
const formattedAst = applyMultilineFix(ast)
|
|
109
|
-
|
|
127
|
+
const formattedAst = applyMultilineFix(ast);
|
|
128
|
+
const numbered = lineNumberify(formattedAst).nodes;
|
|
110
129
|
return wrapLines(numbered, lines);
|
|
111
130
|
}
|
|
@@ -4,116 +4,135 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var highlightLine_exports = {};
|
|
35
37
|
__export(highlightLine_exports, {
|
|
36
38
|
highlightLine: () => highlightLine
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(highlightLine_exports);
|
|
39
|
-
var import_hast_util_to_html = require("hast-util-to-html")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
var import_hast_util_to_html = require("hast-util-to-html");
|
|
42
|
+
var import_rehype_parse = __toESM(require("rehype-parse"));
|
|
43
|
+
var import_unified = require("unified");
|
|
44
|
+
var lineNumberify = function lineNumberify2(ast) {
|
|
45
|
+
var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
46
|
+
var lineNumber = lineNum;
|
|
47
|
+
return ast.reduce(function (result, node) {
|
|
48
|
+
if (node.type === "text") {
|
|
49
|
+
if (node.value.indexOf("\n") === -1) {
|
|
50
|
+
node.lineNumber = lineNumber;
|
|
51
|
+
result.nodes.push(node);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
var lines = node.value.split("\n");
|
|
55
|
+
for (var i = 0; i < lines.length; i++) {
|
|
56
|
+
if (i !== 0) ++lineNumber;
|
|
57
|
+
if (i === lines.length - 1 && lines[i].length === 0) continue;
|
|
58
|
+
result.nodes.push({
|
|
51
59
|
type: "text",
|
|
52
60
|
value: i === lines.length - 1 ? lines[i] : `${lines[i]}
|
|
53
61
|
`,
|
|
54
62
|
lineNumber
|
|
55
63
|
});
|
|
56
|
-
return result.lineNumber = lineNumber, result;
|
|
57
64
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
result.lineNumber = lineNumber;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
if (node.children) {
|
|
69
|
+
node.lineNumber = lineNumber;
|
|
70
|
+
var processed = lineNumberify2(node.children, lineNumber);
|
|
71
|
+
node.children = processed.nodes;
|
|
72
|
+
result.lineNumber = processed.lineNumber;
|
|
73
|
+
result.nodes.push(node);
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
result.nodes.push(node);
|
|
77
|
+
return result;
|
|
78
|
+
}, {
|
|
79
|
+
nodes: [],
|
|
80
|
+
lineNumber
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
var wrapLines = function wrapLines2(ast, linesToHighlight) {
|
|
84
|
+
var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;
|
|
85
|
+
var allLines = Array.from(new Set(ast.map(function (x) {
|
|
86
|
+
return x.lineNumber;
|
|
87
|
+
})));
|
|
88
|
+
var i = 0;
|
|
89
|
+
var wrapped = allLines.reduce(function (nodes, marker) {
|
|
90
|
+
var line = marker;
|
|
91
|
+
var children = [];
|
|
92
|
+
for (; i < ast.length; i++) {
|
|
93
|
+
if (ast[i].lineNumber < line) {
|
|
94
|
+
nodes.push(ast[i]);
|
|
95
|
+
continue;
|
|
62
96
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
97
|
+
if (ast[i].lineNumber === line) {
|
|
98
|
+
children.push(ast[i]);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (ast[i].lineNumber > line) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
nodes.push({
|
|
106
|
+
type: "element",
|
|
107
|
+
tagName: "div",
|
|
108
|
+
properties: {
|
|
109
|
+
dataLine: line,
|
|
110
|
+
className: "highlight-line",
|
|
111
|
+
dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
|
|
112
|
+
},
|
|
113
|
+
children,
|
|
114
|
+
lineNumber: line
|
|
67
115
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (ast[i].lineNumber < line) {
|
|
78
|
-
nodes.push(ast[i]);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (ast[i].lineNumber === line) {
|
|
82
|
-
children.push(ast[i]);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (ast[i].lineNumber > line) break;
|
|
86
|
-
}
|
|
87
|
-
return nodes.push({
|
|
88
|
-
type: "element",
|
|
89
|
-
tagName: "div",
|
|
90
|
-
properties: {
|
|
91
|
-
dataLine: line,
|
|
92
|
-
className: "highlight-line",
|
|
93
|
-
dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
|
|
94
|
-
},
|
|
95
|
-
children,
|
|
96
|
-
lineNumber: line
|
|
97
|
-
}), nodes;
|
|
98
|
-
}, []);
|
|
99
|
-
return wrapped;
|
|
100
|
-
},
|
|
101
|
-
MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g,
|
|
102
|
-
applyMultilineFix = function (ast) {
|
|
103
|
-
var html = (0, import_hast_util_to_html.toHtml)(ast);
|
|
104
|
-
html = html.replace(MULTILINE_TOKEN_SPAN, function (match, token) {
|
|
105
|
-
return match.replace(/\n/g, `</span>
|
|
116
|
+
return nodes;
|
|
117
|
+
}, []);
|
|
118
|
+
return wrapped;
|
|
119
|
+
};
|
|
120
|
+
var MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g;
|
|
121
|
+
var applyMultilineFix = function (ast) {
|
|
122
|
+
var html = (0, import_hast_util_to_html.toHtml)(ast);
|
|
123
|
+
html = html.replace(MULTILINE_TOKEN_SPAN, function (match, token) {
|
|
124
|
+
return match.replace(/\n/g, `</span>
|
|
106
125
|
<span class="token ${token}">`);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
126
|
+
});
|
|
127
|
+
var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
128
|
+
emitParseErrors: true,
|
|
129
|
+
fragment: true
|
|
130
|
+
}).parse(html);
|
|
131
|
+
return hast["children"];
|
|
132
|
+
};
|
|
114
133
|
function highlightLine(ast, lines) {
|
|
115
|
-
var formattedAst = applyMultilineFix(ast)
|
|
116
|
-
|
|
134
|
+
var formattedAst = applyMultilineFix(ast);
|
|
135
|
+
var numbered = lineNumberify(formattedAst).nodes;
|
|
117
136
|
return wrapLines(numbered, lines);
|
|
118
137
|
}
|
|
119
138
|
//# sourceMappingURL=highlightLine.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","highlightLine_exports","__export","highlightLine","module","exports","import_hast_util_to_html","require","import_rehype_parse","__toESM","import_unified","lineNumberify","lineNumberify2","ast","lineNum","arguments","length","lineNumber","reduce","result","node","type","indexOf","nodes","push","lines","split","i","children","processed","wrapLines","linesToHighlight","highlightAll","allLines","Array","from","Set","map","x","wrapped","marker","line","tagName","properties","dataLine","className","dataHighlighted","includes","MULTILINE_TOKEN_SPAN","applyMultilineFix","html","toHtml","replace","match","token","hast","unified","use","default","emitParseErrors","fragment","parse"],"sources":["../../src/highlightLine.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","highlightLine_exports","__export","highlightLine","module","exports","import_hast_util_to_html","require","import_rehype_parse","__toESM","import_unified","lineNumberify","lineNumberify2","ast","lineNum","arguments","length","lineNumber","reduce","result","node","type","indexOf","nodes","push","lines","split","i","children","processed","wrapLines","wrapLines2","linesToHighlight","highlightAll","allLines","Array","from","Set","map","x","wrapped","marker","line","tagName","properties","dataLine","className","dataHighlighted","includes","MULTILINE_TOKEN_SPAN","applyMultilineFix","html","toHtml","replace","match","token","hast","unified","use","default","emitParseErrors","fragment","parse"],"sources":["../../src/highlightLine.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAA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GAAAyB,IAAA;QACT;MACA;IAAS;IACGnB,KACV,CAAAC,IAAA;MAAUH,IACV,WAAW;MAAAsB,OACX;MAEFC,UAAA;QACAC,QAAA,EAAAH,IAAA;QACAI,SAAA,EAAY;QACbC,eAAA,EAAAf,gBAAA,CAAAgB,QAAA,CAAAN,IAAA,KAAAT,YAAA;MAED;MACEL,QAAC;MAELX,UAAO,EAAAyB;IACT;IAGA,OAAMnB,KAAA;EAEN,KAAM;EAEJ,OAAIiB,OAAA;AAGJ;AAAY,IAAQS,oBAAA;AAAA,IAAsBC,iBAAQ,GAChD,SAAAA,CAAMrC,GAAQ;EAAO,IAAAsC,IAAA,OAAA7C,wBAAwC,CAAA8C,MAAA,EAAAvC,GAAA;EAC/DsC,IAAA,GAAAA,IAAA,CAAAE,OAAA,CAAAJ,oBAAA,YAAAK,KAAA,EAAAC,KAAA;IAGA,OAAMD,KAAA,CAAAD,OAAO;AAEb,qBAAYE,KAAU;EACxB;EAEO,IAAAC,IAAS,OAAA9C,cAAmB,CAAA+C,OAAO,IAAAC,GAAA,CAAAlD,mBAAA,CAAAmD,OAAA;IACxCC,eAAM,MAAe;IACrBC,QAAM;EACN,GAAAC,KAAO,CAAAX,IAAA;EACT,OAAAK,IAAA","ignoreList":[]}
|
|
@@ -2,46 +2,50 @@ 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
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var highlightWord_exports = {};
|
|
33
35
|
__export(highlightWord_exports, {
|
|
34
36
|
highlightWord: () => highlightWord
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(highlightWord_exports);
|
|
37
|
-
var import_hast_util_to_html = require("hast-util-to-html")
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
var import_hast_util_to_html = require("hast-util-to-html");
|
|
40
|
+
var import_rehype_parse = __toESM(require("rehype-parse"));
|
|
41
|
+
var import_unified = require("unified");
|
|
40
42
|
const CALLOUT = /__(.*?)__/g;
|
|
41
43
|
function highlightWord(code) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const html = (0, import_hast_util_to_html.toHtml)(code);
|
|
45
|
+
const result = html.replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`);
|
|
46
|
+
const hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
47
|
+
emitParseErrors: true,
|
|
48
|
+
fragment: true
|
|
49
|
+
}).parse(result);
|
|
50
|
+
return hast["children"];
|
|
47
51
|
}
|
|
@@ -4,51 +4,53 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var highlightWord_exports = {};
|
|
35
37
|
__export(highlightWord_exports, {
|
|
36
38
|
highlightWord: () => highlightWord
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(highlightWord_exports);
|
|
39
|
-
var import_hast_util_to_html = require("hast-util-to-html")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
var import_hast_util_to_html = require("hast-util-to-html");
|
|
42
|
+
var import_rehype_parse = __toESM(require("rehype-parse"));
|
|
43
|
+
var import_unified = require("unified");
|
|
44
|
+
var CALLOUT = /__(.*?)__/g;
|
|
43
45
|
function highlightWord(code) {
|
|
44
|
-
var html = (0, import_hast_util_to_html.toHtml)(code)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return hast
|
|
46
|
+
var html = (0, import_hast_util_to_html.toHtml)(code);
|
|
47
|
+
var result = html.replace(CALLOUT, function (_, text) {
|
|
48
|
+
return `<span class="highlight-word">${text}</span>`;
|
|
49
|
+
});
|
|
50
|
+
var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
|
|
51
|
+
emitParseErrors: true,
|
|
52
|
+
fragment: true
|
|
53
|
+
}).parse(result);
|
|
54
|
+
return hast["children"];
|
|
53
55
|
}
|
|
54
56
|
//# sourceMappingURL=highlightWord.native.js.map
|