@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.
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
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, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  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);
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
- import_rehype_parse = __toESM(require("rehype-parse")),
39
- import_unified = require("unified");
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
- 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({
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
- 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;
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
- 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;
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
- 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
- };
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
- numbered = lineNumberify(formattedAst).nodes;
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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
- import_rehype_parse = __toESM(require("rehype-parse")),
41
- import_unified = require("unified"),
42
- lineNumberify = function lineNumberify2(ast) {
43
- var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1,
44
- lineNumber = lineNum;
45
- return ast.reduce(function (result, node) {
46
- if (node.type === "text") {
47
- if (node.value.indexOf(`
48
- `) === -1) return node.lineNumber = lineNumber, result.nodes.push(node), result;
49
- for (var lines = node.value.split(`
50
- `), i = 0; i < lines.length; i++) i !== 0 && ++lineNumber, !(i === lines.length - 1 && lines[i].length === 0) && result.nodes.push({
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
- if (node.children) {
59
- node.lineNumber = lineNumber;
60
- var processed = lineNumberify2(node.children, lineNumber);
61
- return node.children = processed.nodes, result.lineNumber = processed.lineNumber, result.nodes.push(node), result;
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
- return result.nodes.push(node), result;
64
- }, {
65
- nodes: [],
66
- lineNumber
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
- wrapLines = function (ast, linesToHighlight) {
70
- var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0,
71
- allLines = Array.from(new Set(ast.map(function (x) {
72
- return x.lineNumber;
73
- }))),
74
- i = 0,
75
- wrapped = allLines.reduce(function (nodes, marker) {
76
- for (var line = marker, children = []; i < ast.length; i++) {
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
- var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
109
- emitParseErrors: !0,
110
- fragment: !0
111
- }).parse(html);
112
- return hast.children;
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
- numbered = lineNumberify(formattedAst).nodes;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,qBAAuB;AAIvB,IAAAK,wBAAsB,GAASC,OAAA,oBAAmB;EAAUC,mBAAG,GAAAC,OAAA,CAAAF,OAAA;EAAAG,cAAA,GAAAH,OAAA;EAAAI,aAAA,YAAAC,eAAAC,GAAA;IAC7D,IAAIC,OAAA,GAAAC,SAAa,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;MAAAE,UAAA,GAAAH,OAAA;IACjB,OAAOD,GAAA,CAAIK,MAAA,WAAAC,MAAA,EAAAC,IAAA;MACT,IAACA,IAAA,CAAQC,IAAA,KAAS;QAChB,IAAID,IAAA,CAAKpB,KAAA,CAAAsB,OAAS;AAChB,WAAiC,OAAAF,IAAA,CAAAH,UAAA,GAAAA,UAAA,EAAAE,MAAA,CAAAI,KAAA,CAAAC,IAAA,CAAAJ,IAAA,GAAAD,MAAA;QAC/B,SAAAM,KAAA,GAAKL,IAAA,CAAApB,KAAA,CAAA0B,KAAa;AAKpB,IAAAC,CAAA,MAAAA,CAAA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","__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,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,qBAAuB;AACvB,IAAAK,wBAAkB,GAAAC,OAAA;AAClB,IAAAC,mBAAwB,GAAAC,OAAA,CAAAF,OAAA;AAExB,IAAAG,cAAM,GAAAH,OAAgB,UAAS;AAC7B,IAAAI,aAAI,GAAa,SAAAC,eAAAC,GAAA;EACjB,IAAAC,OAAW,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;EAAA,IACRE,UAAQ,GAAAH,OAAS;EAChB,OAAAD,GAAI,CAAAK,MAAK,WAASC,MAAQ,EAAAC,IAAA;IACxB,IAAAA,IAAI,CAAAC,IAAK,WAAM;MACb,IAAAD,IAAA,CAAKpB,KAAA,CAAAsB,OAAa;QAClBF,IAAA,CAAAH,UAAa,GAAAA,UAAS;QACtBE,MAAA,CAAAI,KAAO,CAAAC,IAAA,CAAAJ,IAAA;QACT,OAAAD,MAAA;MAEA;MACA,IAAAM,KAAA,GAASL,IAAI,CAAApB,KA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,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
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
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, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  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);
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
- import_rehype_parse = __toESM(require("rehype-parse")),
39
- import_unified = require("unified");
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 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;
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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
- import_rehype_parse = __toESM(require("rehype-parse")),
41
- import_unified = require("unified"),
42
- CALLOUT = /__(.*?)__/g;
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
- result = html.replace(CALLOUT, function (_, text) {
46
- return `<span class="highlight-word">${text}</span>`;
47
- }),
48
- hast = (0, import_unified.unified)().use(import_rehype_parse.default, {
49
- emitParseErrors: !0,
50
- fragment: !0
51
- }).parse(result);
52
- return hast.children;
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