@hanzogui/code-to-html 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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,119 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
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, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ 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);
34
+ var highlightLine_exports = {};
35
+ __export(highlightLine_exports, {
36
+ highlightLine: () => highlightLine
37
+ });
38
+ 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({
51
+ type: "text",
52
+ value: i === lines.length - 1 ? lines[i] : `${lines[i]}
53
+ `,
54
+ lineNumber
55
+ });
56
+ return result.lineNumber = lineNumber, result;
57
+ }
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;
62
+ }
63
+ return result.nodes.push(node), result;
64
+ }, {
65
+ nodes: [],
66
+ lineNumber
67
+ });
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>
106
+ <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
+ };
114
+ function highlightLine(ast, lines) {
115
+ var formattedAst = applyMultilineFix(ast),
116
+ numbered = lineNumberify(formattedAst).nodes;
117
+ return wrapLines(numbered, lines);
118
+ }
119
+ //# sourceMappingURL=highlightLine.native.js.map
@@ -0,0 +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,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X,IAAA;IACd,OAAMK,IAAA,CAAA3B,QAAA;EAEN;AACF,SAAAzB,cAAAU,GAAA,EAAAY,KAAA","ignoreList":[]}
@@ -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
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
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, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ 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);
34
+ var highlightWord_exports = {};
35
+ __export(highlightWord_exports, {
36
+ highlightWord: () => highlightWord
37
+ });
38
+ 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;
43
+ 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;
53
+ }
54
+ //# sourceMappingURL=highlightWord.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","highlightWord_exports","__export","highlightWord","module","exports","import_hast_util_to_html","require","import_rehype_parse","__toESM","import_unified","CALLOUT","code","html","toHtml","result","replace","_","text","hast","unified","use","default","emitParseErrors","fragment","parse"],"sources":["../../src/highlightWord.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;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,qBAAuB;AAIvB,IAAAK,wBAAgB,GAAAC,OAAA;EAAAC,mBAAA,GAAAC,OAAA,CAAAF,OAAA;EAAAG,cAAA,GAAAH,OAAA;EAAAI,OAAA;AAET,SAASR,cAAcS,IAAA,EAAM;EAElC,IAAAC,IAAM,OAAAP,wBADO,CAAAQ,MAAA,EAAAF,IAAO;IAAAG,MACA,GAAAF,IAAA,CAAAG,OAAA,CAAAL,OAAA,YAAAM,CAAA,EAAAC,IAAA;MAClB,uCAAAA,IAAA;IAAA,EACA;IAACC,IAAG,OAAST,cAAA,CAAAU,OAAA,IAAAC,GAAA,CAAAb,mBAAoC,CAAAc,OAAA;MACnDC,eAAA;MAIAC,QAAA,EAHa;IAIf,GAAAC,KAAA,CAAAV,MAAA","ignoreList":[]}
@@ -0,0 +1,49 @@
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 index_exports = {};
33
+ __export(index_exports, {
34
+ codeToHTML: () => codeToHTML
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
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");
44
+ import_refractor.refractor.register(import_tsx.default);
45
+ import_refractor.refractor.register(import_css.default);
46
+ function codeToHTML(source, language, line = "0") {
47
+ let result = import_refractor.refractor.highlight(source, language);
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;
49
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
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, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ 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);
34
+ var index_exports = {};
35
+ __export(index_exports, {
36
+ codeToHTML: () => codeToHTML
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+ var import_hast_util_to_html = require("hast-util-to-html"),
40
+ import_parse_numeric_range = __toESM(require("parse-numeric-range")),
41
+ import_refractor = require("refractor"),
42
+ import_css = __toESM(require("refractor/lang/css")),
43
+ import_tsx = __toESM(require("refractor/lang/tsx")),
44
+ import_highlightLine = require("./highlightLine.native.js"),
45
+ import_highlightWord = require("./highlightWord.native.js");
46
+ import_refractor.refractor.register(import_tsx.default);
47
+ import_refractor.refractor.register(import_css.default);
48
+ function codeToHTML(source, language) {
49
+ var line = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "0",
50
+ result = import_refractor.refractor.highlight(source, language);
51
+ 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;
52
+ }
53
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","codeToHTML","module","exports","import_hast_util_to_html","require","import_parse_numeric_range","__toESM","import_refractor","import_css","import_tsx","import_highlightLine","import_highlightWord","refractor","register","default","source","language","line","arguments","length","result","highlight","highlightLine","highlightWord","toHtml"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,aAAuB;AASvB,IAAAK,wBAAU,GAAAC,OAAS,oBAAG;EAAAC,0BAAA,GAAAC,OAAA,CAAAF,OAAA;EAAAG,gBAAA,GAAAH,OAAA;EAAAI,UAAA,GAAAF,OAAA,CAAAF,OAAA;EAAAK,UAAA,GAAAH,OAAA,CAAAF,OAAA;EAAAM,oBAAA,GAAAN,OAAA;EAAAO,oBAAA,GAAAP,OAAA;AACtBG,gBAAA,CAAAK,SAAA,CAAUC,QAAA,CAASJ,UAAA,CAAAK,OAAG;AAEfP,gBAAS,CAAAK,SAAW,CAAAC,QAAgB,CAAAL,UAAyC,CAAAM,OAAK;AACvF,SAAId,UAAcA,CAAAe,MAAA,EAAAC,QAAA;EAClB,IAAAC,IAAA,GAAAC,SAAS,CAAAC,MAAA,QAAAD,SAAA,aAAc,IAAAA,SAAQ;IAAAE,MAAA,GAAAb,gBAAY,CAAAK,SAC3C,CAAAS,SAAS,CAAAN,MAAA,EAAAC,QAAA;EAGX,OAAAI,MAAA,OAAAV,oBAAA,CAAAY,aAAA,EAAAF,MAAA,MAAAf,0BAAA,CAAAS,OAAA,EAAAG,IAAA,IAAAG,MAAA,OAAAT,oBAAA,CAAAY,aAAA,EAAAH,MAAA,GAAAA,MAAA,OAAAjB,wBAAA,CAAAqB,MAAA,EAAAJ,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,77 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import parse from "rehype-parse";
3
+ import { unified } from "unified";
4
+ const lineNumberify = function lineNumberify2(ast, lineNum = 1) {
5
+ let lineNumber = lineNum;
6
+ return ast.reduce((result, node) => {
7
+ if (node.type === "text") {
8
+ if (node.value.indexOf(`
9
+ `) === -1) return node.lineNumber = lineNumber, result.nodes.push(node), result;
10
+ const lines = node.value.split(`
11
+ `);
12
+ for (let i = 0; i < lines.length; i++) i !== 0 && ++lineNumber, !(i === lines.length - 1 && lines[i].length === 0) && result.nodes.push({
13
+ type: "text",
14
+ value: i === lines.length - 1 ? lines[i] : `${lines[i]}
15
+ `,
16
+ lineNumber
17
+ });
18
+ return result.lineNumber = lineNumber, result;
19
+ }
20
+ if (node.children) {
21
+ node.lineNumber = lineNumber;
22
+ const processed = lineNumberify2(node.children, lineNumber);
23
+ return node.children = processed.nodes, result.lineNumber = processed.lineNumber, result.nodes.push(node), result;
24
+ }
25
+ return result.nodes.push(node), result;
26
+ }, {
27
+ nodes: [],
28
+ lineNumber
29
+ });
30
+ },
31
+ wrapLines = function (ast, linesToHighlight) {
32
+ const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0,
33
+ allLines = Array.from(new Set(ast.map(x => x.lineNumber)));
34
+ let i = 0;
35
+ return allLines.reduce((nodes, marker) => {
36
+ const line = marker,
37
+ children = [];
38
+ for (; i < ast.length; i++) {
39
+ if (ast[i].lineNumber < line) {
40
+ nodes.push(ast[i]);
41
+ continue;
42
+ }
43
+ if (ast[i].lineNumber === line) {
44
+ children.push(ast[i]);
45
+ continue;
46
+ }
47
+ if (ast[i].lineNumber > line) break;
48
+ }
49
+ return nodes.push({
50
+ type: "element",
51
+ tagName: "div",
52
+ properties: {
53
+ dataLine: line,
54
+ className: "highlight-line",
55
+ dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
56
+ },
57
+ children,
58
+ lineNumber: line
59
+ }), nodes;
60
+ }, []);
61
+ },
62
+ MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g,
63
+ applyMultilineFix = ast => {
64
+ let html = toHtml(ast);
65
+ return html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) => match.replace(/\n/g, `</span>
66
+ <span class="token ${token}">`)), unified().use(parse, {
67
+ emitParseErrors: !0,
68
+ fragment: !0
69
+ }).parse(html).children;
70
+ };
71
+ function highlightLine(ast, lines) {
72
+ const formattedAst = applyMultilineFix(ast),
73
+ numbered = lineNumberify(formattedAst).nodes;
74
+ return wrapLines(numbered, lines);
75
+ }
76
+ export { highlightLine };
77
+ //# sourceMappingURL=highlightLine.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","parse","unified","lineNumberify","lineNumberify2","ast","lineNum","lineNumber","reduce","result","node","type","value","indexOf","nodes","push","lines","split","i","length","children","processed","wrapLines","linesToHighlight","highlightAll","allLines","Array","from","Set","map","x","marker","line","tagName","properties","dataLine","className","dataHighlighted","includes","MULTILINE_TOKEN_SPAN","applyMultilineFix","html","replace","match","token","use","emitParseErrors","fragment","highlightLine","formattedAst","numbered"],"sources":["../../src/highlightLine.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,MAAA,QAAc;AACvB,OAAOC,KAAA,MAAW;AAClB,SAASC,OAAA,QAAe;AAExB,MAAMC,aAAA,GAAgB,SAASC,eAAcC,GAAA,EAAKC,OAAA,GAAU,GAAG;IAC7D,IAAIC,UAAA,GAAaD,OAAA;IACjB,OAAOD,GAAA,CAAIG,MAAA,CACT,CAACC,MAAA,EAAQC,IAAA,KAAS;MAChB,IAAIA,IAAA,CAAKC,IAAA,KAAS,QAAQ;QACxB,IAAID,IAAA,CAAKE,KAAA,CAAMC,OAAA,CAAQ;AAAA,CAAI,MAAM,IAC/B,OAAAH,IAAA,CAAKH,UAAA,GAAaA,UAAA,EAClBE,MAAA,CAAOK,KAAA,CAAMC,IAAA,CAAKL,IAAI,GACfD,MAAA;QAGT,MAAMO,KAAA,GAAQN,IAAA,CAAKE,KAAA,CAAMK,KAAA,CAAM;AAAA,CAAI;QACnC,SAASC,CAAA,GAAI,GAAGA,CAAA,GAAIF,KAAA,CAAMG,MAAA,EAAQD,CAAA,IAC5BA,CAAA,KAAM,KAAG,EAAEX,UAAA,EACX,EAAAW,CAAA,KAAMF,KAAA,CAAMG,MAAA,GAAS,KAAKH,KAAA,CAAME,CAAC,EAAEC,MAAA,KAAW,MAClDV,MAAA,CAAOK,KAAA,CAAMC,IAAA,CAAK;UAChBJ,IAAA,EAAM;UACNC,KAAA,EAAOM,CAAA,KAAMF,KAAA,CAAMG,MAAA,GAAS,IAAIH,KAAA,CAAME,CAAC,IAAI,GAAGF,KAAA,CAAME,CAAC,CAAC;AAAA;UACtDX;QACF,CAAC;QAGH,OAAAE,MAAA,CAAOF,UAAA,GAAaA,UAAA,EACbE,MAAA;MACT;MAEA,IAAIC,IAAA,CAAKU,QAAA,EAAU;QACjBV,IAAA,CAAKH,UAAA,GAAaA,UAAA;QAClB,MAAMc,SAAA,GA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MAEA,OAAAlB,KAAA,CAAMC,IAAA,CAAK;QACTJ,IAAA,EAAM;QACNsB,OAAA,EAAS;QACTC,UAAA,EAAY;UACVC,QAAA,EAAUH,IAAA;UACVI,SAAA,EAAW;UACXC,eAAA,EACEd,gBAAA,CAAiBe,QAAA,CAASN,IAAI,KAAKR,YAAA,GAAe,SAAS;QAC/D;QACAJ,QAAA;QACAb,UAAA,EAAYyB;MACd,CAAC,GAEMlB,KAAA;IACT,GAAG,EAAE;EAGP;EAGMyB,oBAAA,GAAuB;EAEvBC,iBAAA,GAAqBnC,GAAA,IAAQ;IAEjC,IAAIoC,IAAA,GAAOzC,MAAA,CAAOK,GAAG;IAGrB,OAAAoC,IAAA,GAAOA,IAAA,CAAKC,OAAA,CAAQH,oBAAA,EAAsB,CAACI,KAAA,EAAOC,KAAA,KAChDD,KAAA,CAAMD,OAAA,CAAQ,OAAO;AAAA,qBAA+BE,KAAK,IAAI,CAC/D,GAGa1C,OAAA,CAAQ,EAAE2C,GAAA,CAAI5C,KAAA,EAAO;MAAE6C,eAAA,EAAiB;MAAMC,QAAA,EAAU;IAAK,CAAC,EAAE9C,KAAA,CAAMwC,IAAI,EAE3ErB,QAAA;EACd;AAEO,SAAS4B,cAAc3C,GAAA,EAAKW,KAAA,EAAO;EACxC,MAAMiC,YAAA,GAAeT,iBAAA,CAAkBnC,GAAG;IACpC6C,QAAA,GAAW/C,aAAA,CAAc8C,YAAY,EAAEnC,KAAA;EAC7C,OAAOQ,SAAA,CAAU4B,QAAA,EAAUlC,KAAK;AAClC","ignoreList":[]}
@@ -0,0 +1,82 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import parse from "rehype-parse";
3
+ import { unified } from "unified";
4
+ var lineNumberify = function lineNumberify2(ast) {
5
+ var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1,
6
+ lineNumber = lineNum;
7
+ return ast.reduce(function (result, node) {
8
+ if (node.type === "text") {
9
+ if (node.value.indexOf(`
10
+ `) === -1) return node.lineNumber = lineNumber, result.nodes.push(node), result;
11
+ for (var lines = node.value.split(`
12
+ `), i = 0; i < lines.length; i++) i !== 0 && ++lineNumber, !(i === lines.length - 1 && lines[i].length === 0) && result.nodes.push({
13
+ type: "text",
14
+ value: i === lines.length - 1 ? lines[i] : `${lines[i]}
15
+ `,
16
+ lineNumber
17
+ });
18
+ return result.lineNumber = lineNumber, result;
19
+ }
20
+ if (node.children) {
21
+ node.lineNumber = lineNumber;
22
+ var processed = lineNumberify2(node.children, lineNumber);
23
+ return node.children = processed.nodes, result.lineNumber = processed.lineNumber, result.nodes.push(node), result;
24
+ }
25
+ return result.nodes.push(node), result;
26
+ }, {
27
+ nodes: [],
28
+ lineNumber
29
+ });
30
+ },
31
+ wrapLines = function (ast, linesToHighlight) {
32
+ var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0,
33
+ allLines = Array.from(new Set(ast.map(function (x) {
34
+ return x.lineNumber;
35
+ }))),
36
+ i = 0,
37
+ wrapped = allLines.reduce(function (nodes, marker) {
38
+ for (var line = marker, children = []; i < ast.length; i++) {
39
+ if (ast[i].lineNumber < line) {
40
+ nodes.push(ast[i]);
41
+ continue;
42
+ }
43
+ if (ast[i].lineNumber === line) {
44
+ children.push(ast[i]);
45
+ continue;
46
+ }
47
+ if (ast[i].lineNumber > line) break;
48
+ }
49
+ return nodes.push({
50
+ type: "element",
51
+ tagName: "div",
52
+ properties: {
53
+ dataLine: line,
54
+ className: "highlight-line",
55
+ dataHighlighted: linesToHighlight.includes(line) || highlightAll ? "true" : "false"
56
+ },
57
+ children,
58
+ lineNumber: line
59
+ }), nodes;
60
+ }, []);
61
+ return wrapped;
62
+ },
63
+ MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g,
64
+ applyMultilineFix = function (ast) {
65
+ var html = toHtml(ast);
66
+ html = html.replace(MULTILINE_TOKEN_SPAN, function (match, token) {
67
+ return match.replace(/\n/g, `</span>
68
+ <span class="token ${token}">`);
69
+ });
70
+ var hast = unified().use(parse, {
71
+ emitParseErrors: !0,
72
+ fragment: !0
73
+ }).parse(html);
74
+ return hast.children;
75
+ };
76
+ function highlightLine(ast, lines) {
77
+ var formattedAst = applyMultilineFix(ast),
78
+ numbered = lineNumberify(formattedAst).nodes;
79
+ return wrapLines(numbered, lines);
80
+ }
81
+ export { highlightLine };
82
+ //# sourceMappingURL=highlightLine.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","parse","unified","lineNumberify","lineNumberify2","ast","lineNum","arguments","length","lineNumber","reduce","result","node","type","value","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","replace","match","token","hast","use","emitParseErrors","fragment","highlightLine"],"sources":["../../src/highlightLine.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,MAAA,QAAc;AACvB,OAAOC,KAAA,MAAW;AAClB,SAASC,OAAA,QAAe;AAExB,IAAAC,aAAM,YAAgBC,cAASA,CAAAC,GAAc;IAC3C,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,CAAKE,KAAA,CAAAC,OAAS;AAChB,WAAiC,OAAAH,IAAA,CAAAH,UAAA,GAAAA,UAAA,EAAAE,MAAA,CAAAK,KAAA,CAAAC,IAAA,CAAAL,IAAA,GAAAD,MAAA;QAC/B,SAAAO,KAAA,GAAKN,IAAA,CAAAE,KAAA,CAAAK,KAAa;AAKpB,IAAAC,CAAA,MAAAA,CAAA,GAAMF,KAAA,CAAAV,MAAa,EAAAY,CAAA,IAAgBA,CAAA,YAAAX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AA,EAAAY,CAAA;UACjD,IAAMf,GAAA,CAAAe,CAAA,EAAOX,UACP,GAAAyB,IAAA,EAAkB;YACxBlB,KAAO,CAAAC,IAAI,CAAIZ,GAAA,CAAAe,CAAA;YACb;UACE;UACA,IAAAf,GAAA,CAAAe,CAAA,EAAAX,UAAA,KAAAyB,IAAA;YACFb,QAAA,CAAAJ,IAAA,CAAAZ,GAAA,CAAAe,CAAA;YAEA;UACE;UACA,IAAAf,GAAA,CAAAe,CAAA,EAAAX,UAAA,GAAAyB,IAAA,EACF;QAEA;QACE,OAAAlB,KAAA,CAAAC,IAAA;UAEJJ,IAAA;UAEAsB,OAAA,OAAM;UACJC,UAAM;YACNC,QAAS,EAAAH,IAAA;YACTI,SAAA,EAAY;YACVC,eAAU,EAAAf,gBAAA,CAAAgB,QAAA,CAAAN,IAAA,KAAAT,YAAA;UAAA;UACCJ,QACX;UAEFZ,UAAA,EAAAyB;QAAA,EACA,EAAAlB,KAAA;MAAA,KACA;IAAY,OAGPgB,OAAA;EAAA;EACTS,oBAAK;EAAAC,iBAAA,YAAAA,CAAArC,GAAA;IAGP,IAGMsC,IAAA,GAAA3C,MAAA,CAAAK,GAAA;IAIJsC,IAAI,GAAAA,IAAO,CAAAC,OAAO,CAAAH,oBAAG,YAAAI,KAAA,EAAAC,KAAA;MAGrB,OAAAD,KAAO,CAAAD,OAAK;AAAA,qBAAQE,KAAA;IAAA,EAAsB;IACnB,IAAAC,IAAA,GAAA7C,OAAA,CAA+B,EAAA8C,GAAK,CAAA/C,KAAI;MAC/DgD,eAG2B;MAG7BC,QAAA;IAEO,GAAAjD,KAAS,CAAA0C,IAAA;IACd,OAAMI,IAAA,CAAA1B,QAAA;EAEN;AACF,SAAA8B,cAAA9C,GAAA,EAAAa,KAAA","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import parse from "rehype-parse";
3
+ import { unified } from "unified";
4
+ const CALLOUT = /__(.*?)__/g;
5
+ function highlightWord(code) {
6
+ const result = toHtml(code).replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`);
7
+ return unified().use(parse, {
8
+ emitParseErrors: !0,
9
+ fragment: !0
10
+ }).parse(result).children;
11
+ }
12
+ export { highlightWord };
13
+ //# sourceMappingURL=highlightWord.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","parse","unified","CALLOUT","highlightWord","code","result","replace","_","text","use","emitParseErrors","fragment","children"],"sources":["../../src/highlightWord.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,MAAA,QAAc;AACvB,OAAOC,KAAA,MAAW;AAClB,SAASC,OAAA,QAAe;AAExB,MAAMC,OAAA,GAAU;AAET,SAASC,cAAcC,IAAA,EAAM;EAElC,MAAMC,MAAA,GADON,MAAA,CAAOK,IAAI,EACJE,OAAA,CAClBJ,OAAA,EACA,CAACK,CAAA,EAAGC,IAAA,KAAS,gCAAgCA,IAAI,SACnD;EAIA,OAHaP,OAAA,CAAQ,EAClBQ,GAAA,CAAIT,KAAA,EAAO;IAAEU,eAAA,EAAiB;IAAMC,QAAA,EAAU;EAAK,CAAC,EACpDX,KAAA,CAAMK,MAAM,EACHO,QAAA;AACd","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import parse from "rehype-parse";
3
+ import { unified } from "unified";
4
+ var CALLOUT = /__(.*?)__/g;
5
+ function highlightWord(code) {
6
+ var html = toHtml(code),
7
+ result = html.replace(CALLOUT, function (_, text) {
8
+ return `<span class="highlight-word">${text}</span>`;
9
+ }),
10
+ hast = unified().use(parse, {
11
+ emitParseErrors: !0,
12
+ fragment: !0
13
+ }).parse(result);
14
+ return hast.children;
15
+ }
16
+ export { highlightWord };
17
+ //# sourceMappingURL=highlightWord.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","parse","unified","CALLOUT","highlightWord","code","html","result","replace","_","text","hast","use","emitParseErrors","fragment"],"sources":["../../src/highlightWord.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,MAAA,QAAc;AACvB,OAAOC,KAAA,MAAW;AAClB,SAASC,OAAA,QAAe;AAExB,IAAAC,OAAM,eAAU;AAET,SAASC,cAAcC,IAAA,EAAM;EAElC,IAAAC,IAAM,GAAAN,MADO,CAAAK,IAAO;IAAAE,MACA,GAAAD,IAAA,CAAAE,OAAA,CAAAL,OAAA,YAAAM,CAAA,EAAAC,IAAA;MAClB,uCAAAA,IAAA;IAAA,EACA;IAACC,IAAG,GAAAT,OAAS,GAAAU,GAAA,CAAAX,KAAA;MACfY,eAAA;MAIAC,QAHa;IAIf,GAAAb,KAAA,CAAAM,MAAA","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import rangeParser from "parse-numeric-range";
3
+ import { refractor } from "refractor";
4
+ import css from "refractor/lang/css";
5
+ import tsx from "refractor/lang/tsx";
6
+ import { highlightLine } from "./highlightLine.mjs";
7
+ import { highlightWord } from "./highlightWord.mjs";
8
+ refractor.register(tsx);
9
+ refractor.register(css);
10
+ function codeToHTML(source, language, line = "0") {
11
+ let result = refractor.highlight(source, language);
12
+ return result = highlightLine(result, rangeParser(line)), result = highlightWord(result), result = toHtml(result), result;
13
+ }
14
+ export { codeToHTML };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","rangeParser","refractor","css","tsx","highlightLine","highlightWord","register","codeToHTML","source","language","line","result","highlight"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AACvB,OAAOC,WAAA,MAAiB;AACxB,SAASC,SAAA,QAAiB;AAC1B,OAAOC,GAAA,MAAS;AAChB,OAAOC,GAAA,MAAS;AAEhB,SAASC,aAAA,QAAqB;AAC9B,SAASC,aAAA,QAAqB;AAE9BJ,SAAA,CAAUK,QAAA,CAASH,GAAG;AACtBF,SAAA,CAAUK,QAAA,CAASJ,GAAG;AAEf,SAASK,WAAWC,MAAA,EAAgBC,QAAA,EAAkCC,IAAA,GAAO,KAAK;EACvF,IAAIC,MAAA,GAAcV,SAAA,CAAUW,SAAA,CAAUJ,MAAA,EAAQC,QAAQ;EACtD,OAAAE,MAAA,GAASP,aAAA,CAAcO,MAAA,EAAQX,WAAA,CAAYU,IAAI,CAAC,GAChDC,MAAA,GAASN,aAAA,CAAcM,MAAM,GAC7BA,MAAA,GAASZ,MAAA,CAAOY,MAAM,GACfA,MAAA;AACT","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import rangeParser from "parse-numeric-range";
3
+ import { refractor } from "refractor";
4
+ import css from "refractor/lang/css";
5
+ import tsx from "refractor/lang/tsx";
6
+ import { highlightLine } from "./highlightLine.mjs";
7
+ import { highlightWord } from "./highlightWord.mjs";
8
+ refractor.register(tsx);
9
+ refractor.register(css);
10
+ function codeToHTML(source, language, line = "0") {
11
+ let result = refractor.highlight(source, language);
12
+ return result = highlightLine(result, rangeParser(line)), result = highlightWord(result), result = toHtml(result), result;
13
+ }
14
+ export { codeToHTML };
15
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","rangeParser","refractor","css","tsx","highlightLine","highlightWord","register","codeToHTML","source","language","line","result","highlight"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AACvB,OAAOC,WAAA,MAAiB;AACxB,SAASC,SAAA,QAAiB;AAC1B,OAAOC,GAAA,MAAS;AAChB,OAAOC,GAAA,MAAS;AAEhB,SAASC,aAAA,QAAqB;AAC9B,SAASC,aAAA,QAAqB;AAE9BJ,SAAA,CAAUK,QAAA,CAASH,GAAG;AACtBF,SAAA,CAAUK,QAAA,CAASJ,GAAG;AAEf,SAASK,WAAWC,MAAA,EAAgBC,QAAA,EAAkCC,IAAA,GAAO,KAAK;EACvF,IAAIC,MAAA,GAAcV,SAAA,CAAUW,SAAA,CAAUJ,MAAA,EAAQC,QAAQ;EACtD,OAAAE,MAAA,GAASP,aAAA,CAAcO,MAAA,EAAQX,WAAA,CAAYU,IAAI,CAAC,GAChDC,MAAA,GAASN,aAAA,CAAcM,MAAM,GAC7BA,MAAA,GAASZ,MAAA,CAAOY,MAAM,GACfA,MAAA;AACT","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import { toHtml } from "hast-util-to-html";
2
+ import rangeParser from "parse-numeric-range";
3
+ import { refractor } from "refractor";
4
+ import css from "refractor/lang/css";
5
+ import tsx from "refractor/lang/tsx";
6
+ import { highlightLine } from "./highlightLine.native.js";
7
+ import { highlightWord } from "./highlightWord.native.js";
8
+ refractor.register(tsx);
9
+ refractor.register(css);
10
+ function codeToHTML(source, language) {
11
+ var line = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "0",
12
+ result = refractor.highlight(source, language);
13
+ return result = highlightLine(result, rangeParser(line)), result = highlightWord(result), result = toHtml(result), result;
14
+ }
15
+ export { codeToHTML };
16
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toHtml","rangeParser","refractor","css","tsx","highlightLine","highlightWord","register","codeToHTML","source","language","line","arguments","length","result","highlight"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AACvB,OAAOC,WAAA,MAAiB;AACxB,SAASC,SAAA,QAAiB;AAC1B,OAAOC,GAAA,MAAS;AAChB,OAAOC,GAAA,MAAS;AAEhB,SAASC,aAAA,QAAqB;AAC9B,SAASC,aAAA,QAAqB;AAE9BJ,SAAA,CAAUK,QAAA,CAASH,GAAG;AACtBF,SAAA,CAAUK,QAAA,CAASJ,GAAG;AAEf,SAASK,WAAWC,MAAA,EAAgBC,QAAA,EAAkC;EAC3E,IAAIC,IAAA,GAAAC,SAAc,CAAAC,MAAU,QAAUD,SAAQ,QAAQ,SAAAA,SAAA;IAAAE,MAAA,GAAAZ,SAAA,CAAAa,SAAA,CAAAN,MAAA,EAAAC,QAAA;EACtD,OAAAI,MAAA,GAAST,aAAA,CAAcS,MAAA,EAAQb,WAAA,CAAYU,IAAI,CAAC,GAChDG,MAAA,GAASR,aAAA,CAAcQ,MAAM,GAC7BA,MAAA,GAASd,MAAA,CAAOc,MAAM,GACfA,MAAA;AACT","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@hanzogui/code-to-html",
3
+ "version": "2.0.0",
4
+ "source": "src/index.ts",
5
+ "files": [
6
+ "src",
7
+ "types",
8
+ "dist"
9
+ ],
10
+ "main": "dist/cjs",
11
+ "module": "dist/esm",
12
+ "types": "./types/index.d.ts",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "hanzo-gui-build",
18
+ "watch": "hanzo-gui-build --watch",
19
+ "clean": "hanzo-gui-build clean",
20
+ "clean:build": "hanzo-gui-build clean:build"
21
+ },
22
+ "dependencies": {
23
+ "hast-util-to-html": "^8.0.3",
24
+ "hast-util-to-string": "^2.0.0",
25
+ "parse-numeric-range": "^1.3.0",
26
+ "refractor": "^4.7.0",
27
+ "rehype": "^12.0.1",
28
+ "rehype-parse": "^8.0.4",
29
+ "rehype-slug": "^5.0.1",
30
+ "unified": "^10.1.2",
31
+ "url": "^0.11.0"
32
+ },
33
+ "devDependencies": {
34
+ "@hanzogui/build": "workspace:*"
35
+ }
36
+ }
@@ -0,0 +1,113 @@
1
+ // Inspired by https://github.com/j0lv3r4/mdx-prism
2
+
3
+ import { toHtml } from 'hast-util-to-html'
4
+ import parse from 'rehype-parse'
5
+ import { unified } from 'unified'
6
+
7
+ const lineNumberify = function lineNumberify(ast, lineNum = 1) {
8
+ let lineNumber = lineNum
9
+ return ast.reduce(
10
+ (result, node) => {
11
+ if (node.type === 'text') {
12
+ if (node.value.indexOf('\n') === -1) {
13
+ node.lineNumber = lineNumber
14
+ result.nodes.push(node)
15
+ return result
16
+ }
17
+
18
+ const lines = node.value.split('\n')
19
+ for (let i = 0; i < lines.length; i++) {
20
+ if (i !== 0) ++lineNumber
21
+ if (i === lines.length - 1 && lines[i].length === 0) continue
22
+ result.nodes.push({
23
+ type: 'text',
24
+ value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,
25
+ lineNumber: lineNumber,
26
+ })
27
+ }
28
+
29
+ result.lineNumber = lineNumber
30
+ return result
31
+ }
32
+
33
+ if (node.children) {
34
+ node.lineNumber = lineNumber
35
+ const processed = lineNumberify(node.children, lineNumber)
36
+ node.children = processed.nodes
37
+ result.lineNumber = processed.lineNumber
38
+ result.nodes.push(node)
39
+ return result
40
+ }
41
+
42
+ result.nodes.push(node)
43
+ return result
44
+ },
45
+ { nodes: [], lineNumber: lineNumber }
46
+ )
47
+ }
48
+
49
+ const wrapLines = function wrapLines(ast: any[], linesToHighlight) {
50
+ const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0
51
+ const allLines: any[] = Array.from(new Set(ast.map((x) => x.lineNumber)))
52
+ let i = 0
53
+ const wrapped = allLines.reduce((nodes, marker) => {
54
+ const line = marker
55
+ const children: any[] = []
56
+ for (; i < ast.length; i++) {
57
+ if (ast[i].lineNumber < line) {
58
+ nodes.push(ast[i])
59
+ continue
60
+ }
61
+
62
+ if (ast[i].lineNumber === line) {
63
+ children.push(ast[i])
64
+ continue
65
+ }
66
+
67
+ if (ast[i].lineNumber > line) {
68
+ break
69
+ }
70
+ }
71
+
72
+ nodes.push({
73
+ type: 'element',
74
+ tagName: 'div',
75
+ properties: {
76
+ dataLine: line,
77
+ className: 'highlight-line',
78
+ dataHighlighted:
79
+ linesToHighlight.includes(line) || highlightAll ? 'true' : 'false',
80
+ },
81
+ children,
82
+ lineNumber: line,
83
+ })
84
+
85
+ return nodes
86
+ }, [])
87
+
88
+ return wrapped
89
+ }
90
+
91
+ // https://github.com/gatsbyjs/gatsby/pull/26161/files
92
+ const MULTILINE_TOKEN_SPAN = /<span class="token ([^"]+)">[^<]*\n[^<]*<\/span>/g
93
+
94
+ const applyMultilineFix = (ast) => {
95
+ // AST to HTML
96
+ let html = toHtml(ast)
97
+
98
+ // Fix JSX issue
99
+ html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) =>
100
+ match.replace(/\n/g, `</span>\n<span class="token ${token}">`)
101
+ )
102
+
103
+ // HTML to AST
104
+ const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(html)
105
+
106
+ return hast['children']
107
+ }
108
+
109
+ export function highlightLine(ast, lines) {
110
+ const formattedAst = applyMultilineFix(ast)
111
+ const numbered = lineNumberify(formattedAst).nodes
112
+ return wrapLines(numbered, lines)
113
+ }
@@ -0,0 +1,18 @@
1
+ // const visit = require('unist-util-visit')
2
+ import { toHtml } from 'hast-util-to-html'
3
+ import parse from 'rehype-parse'
4
+ import { unified } from 'unified'
5
+
6
+ const CALLOUT = /__(.*?)__/g
7
+
8
+ export function highlightWord(code) {
9
+ const html = toHtml(code)
10
+ const result = html.replace(
11
+ CALLOUT,
12
+ (_, text) => `<span class="highlight-word">${text}</span>`
13
+ )
14
+ const hast = unified()
15
+ .use(parse, { emitParseErrors: true, fragment: true })
16
+ .parse(result)
17
+ return hast['children']
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { toHtml } from 'hast-util-to-html'
2
+ import rangeParser from 'parse-numeric-range'
3
+ import { refractor } from 'refractor'
4
+ import css from 'refractor/lang/css'
5
+ import tsx from 'refractor/lang/tsx'
6
+
7
+ import { highlightLine } from './highlightLine'
8
+ import { highlightWord } from './highlightWord'
9
+
10
+ refractor.register(tsx)
11
+ refractor.register(css)
12
+
13
+ export function codeToHTML(source: string, language: 'tsx' | 'css' | string, line = '0') {
14
+ let result: any = refractor.highlight(source, language)
15
+ result = highlightLine(result, rangeParser(line))
16
+ result = highlightWord(result)
17
+ result = toHtml(result)
18
+ return result as string
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare function highlightLine(ast: any, lines: any): any;
2
+ //# sourceMappingURL=highlightLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlightLine.d.ts","sourceRoot":"","sources":["../src/highlightLine.ts"],"names":[],"mappings":"AA4GA,wBAAgB,aAAa,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,OAIvC"}
@@ -0,0 +1,2 @@
1
+ export declare function highlightWord(code: any): import("hast").RootContent[];
2
+ //# sourceMappingURL=highlightWord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlightWord.d.ts","sourceRoot":"","sources":["../src/highlightWord.ts"],"names":[],"mappings":"AAOA,wBAAgB,aAAa,CAAC,IAAI,KAAA,gCAUjC"}
@@ -0,0 +1,2 @@
1
+ export declare function codeToHTML(source: string, language: 'tsx' | 'css' | string, line?: string): string;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,EAAE,IAAI,SAAM,GAKpE,MAAM,CACxB"}