@tamagui/code-to-html 3.0.0-beta.669.1 → 3.0.0-beta.728.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/highlightLine.cjs +0 -1
- package/dist/cjs/highlightLine.native.cjs +0 -1
- package/dist/cjs/highlightLine.native.js +0 -1
- package/dist/cjs/highlightLine.native.js.map +1 -1
- package/dist/cjs/highlightWord.cjs +0 -1
- package/dist/cjs/highlightWord.native.cjs +0 -1
- package/dist/cjs/highlightWord.native.js +0 -1
- package/dist/cjs/highlightWord.native.js.map +1 -1
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/index.native.cjs +0 -1
- package/dist/cjs/index.native.js +0 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/highlightLine.mjs.map +1 -1
- package/dist/esm/highlightLine.native.js.map +1 -1
- package/dist/esm/highlightWord.mjs.map +1 -1
- package/dist/esm/highlightWord.native.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightLine.native.js","names":[],"sources":["cjs/highlightLine.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar highlightLine_exports = {};\n__export(highlightLine_exports, {\n highlightLine: () => highlightLine\n});\nmodule.exports = __toCommonJS(highlightLine_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_rehype_parse = __toESM(require(\"rehype-parse\"));\nvar import_unified = require(\"unified\");\nvar lineNumberify = function lineNumberify2(ast) {\n var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;\n var lineNumber = lineNum;\n return ast.reduce(function(result, node) {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n var lines = node.value.split(\"\\n\");\n for (var i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n var processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n }, {\n nodes: [],\n lineNumber\n });\n};\nvar wrapLines = function wrapLines2(ast, linesToHighlight) {\n var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n var allLines = Array.from(new Set(ast.map(function(x) {\n return x.lineNumber;\n })));\n var i = 0;\n var wrapped = allLines.reduce(function(nodes, marker) {\n var line = marker;\n var children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nvar MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nvar applyMultilineFix = function(ast) {\n var html = (0, import_hast_util_to_html.toHtml)(ast);\n html = html.replace(MULTILINE_TOKEN_SPAN, function(match, token) {\n return match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`);\n });\n var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {\n emitParseErrors: true,\n fragment: true\n }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n var formattedAst = applyMultilineFix(ast);\n var numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlightLine.native.js","names":[],"sources":["cjs/highlightLine.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar highlightLine_exports = {};\n__export(highlightLine_exports, {\n highlightLine: () => highlightLine\n});\nmodule.exports = __toCommonJS(highlightLine_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_rehype_parse = __toESM(require(\"rehype-parse\"));\nvar import_unified = require(\"unified\");\nvar lineNumberify = function lineNumberify2(ast) {\n var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;\n var lineNumber = lineNum;\n return ast.reduce(function(result, node) {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n var lines = node.value.split(\"\\n\");\n for (var i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n var processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n }, {\n nodes: [],\n lineNumber\n });\n};\nvar wrapLines = function wrapLines2(ast, linesToHighlight) {\n var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n var allLines = Array.from(new Set(ast.map(function(x) {\n return x.lineNumber;\n })));\n var i = 0;\n var wrapped = allLines.reduce(function(nodes, marker) {\n var line = marker;\n var children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nvar MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nvar applyMultilineFix = function(ast) {\n var html = (0, import_hast_util_to_html.toHtml)(ast);\n html = html.replace(MULTILINE_TOKEN_SPAN, function(match, token) {\n return match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`);\n });\n var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {\n emitParseErrors: true,\n fragment: true\n }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n var formattedAst = applyMultilineFix(ast);\n var numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE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,OAAO;AACT;AACA,IAAI,uBAAuB;AAC3B,IAAI,oBAAoB,SAAS,KAAK;CACpC,IAAI,QAAQ,GAAG,yBAAyB,OAAM,CAAE,GAAG;CACnD,OAAO,KAAK,QAAQ,sBAAsB,SAAS,OAAO,OAAO;EAC/D,OAAO,MAAM,QAAQ,OAAO;qBACX,MAAM,GAAG;CAC5B,CAAC;CACD,IAAI,QAAQ,GAAG,eAAe,QAAO,CAAE,CAAC,CAAC,IAAI,oBAAoB,SAAS;EACxE,iBAAiB;EACjB,UAAU;CACZ,CAAC,CAAC,CAAC,MAAM,IAAI;CACb,OAAO,KAAK;AACd;AACA,SAAS,cAAc,KAAK,OAAO;CACjC,IAAI,eAAe,kBAAkB,GAAG;CACxC,IAAI,WAAW,cAAc,YAAY,CAAC,CAAC;CAC3C,OAAO,UAAU,UAAU,KAAK;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightWord.native.js","names":[],"sources":["cjs/highlightWord.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar highlightWord_exports = {};\n__export(highlightWord_exports, {\n highlightWord: () => highlightWord\n});\nmodule.exports = __toCommonJS(highlightWord_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_rehype_parse = __toESM(require(\"rehype-parse\"));\nvar import_unified = require(\"unified\");\nvar CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n var html = (0, import_hast_util_to_html.toHtml)(code);\n var result = html.replace(CALLOUT, function(_, text) {\n return `<span class=\"highlight-word\">${text}</span>`;\n });\n var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {\n emitParseErrors: true,\n fragment: true\n }).parse(result);\n return hast[\"children\"];\n}\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlightWord.native.js","names":[],"sources":["cjs/highlightWord.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar highlightWord_exports = {};\n__export(highlightWord_exports, {\n highlightWord: () => highlightWord\n});\nmodule.exports = __toCommonJS(highlightWord_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_rehype_parse = __toESM(require(\"rehype-parse\"));\nvar import_unified = require(\"unified\");\nvar CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n var html = (0, import_hast_util_to_html.toHtml)(code);\n var result = html.replace(CALLOUT, function(_, text) {\n return `<span class=\"highlight-word\">${text}</span>`;\n });\n var hast = (0, import_unified.unified)().use(import_rehype_parse.default, {\n emitParseErrors: true,\n fragment: true\n }).parse(result);\n return hast[\"children\"];\n}\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB,EAC9B,qBAAqB,cACvB,CAAC;AACD,OAAO,UAAU,aAAa,qBAAqB;AACnD,IAAI,2BAA2B,QAAQ,mBAAmB;AAC1D,IAAI,sBAAsB,QAAQ,QAAQ,cAAc,CAAC;AACzD,IAAI,iBAAiB,QAAQ,SAAS;AACtC,IAAI,UAAU;AACd,SAAS,cAAc,MAAM;CAC3B,IAAI,QAAQ,GAAG,yBAAyB,OAAM,CAAE,IAAI;CACpD,IAAI,SAAS,KAAK,QAAQ,SAAS,SAAS,GAAG,MAAM;EACnD,OAAO,gCAAgC,KAAK;CAC9C,CAAC;CACD,IAAI,QAAQ,GAAG,eAAe,QAAO,CAAE,CAAC,CAAC,IAAI,oBAAoB,SAAS;EACxE,iBAAiB;EACjB,UAAU;CACZ,CAAC,CAAC,CAAC,MAAM,MAAM;CACf,OAAO,KAAK;AACd"}
|
package/dist/cjs/index.cjs
CHANGED
package/dist/cjs/index.native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n codeToHTML: () => codeToHTML\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_parse_numeric_range = __toESM(require(\"parse-numeric-range\"));\nvar import_refractor = require(\"refractor\");\nvar import_css = __toESM(require(\"refractor/lang/css.js\"));\nvar import_tsx = __toESM(require(\"refractor/lang/tsx.js\"));\nvar import_highlightLine = require(\"./highlightLine\");\nvar import_highlightWord = require(\"./highlightWord\");\nimport_refractor.refractor.register(import_tsx.default);\nimport_refractor.refractor.register(import_css.default);\nfunction codeToHTML(source, language) {\n var line = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : \"0\";\n var result = import_refractor.refractor.highlight(source, language);\n result = (0, import_highlightLine.highlightLine)(result, (0, import_parse_numeric_range.default)(line));\n result = (0, import_highlightWord.highlightWord)(result);\n result = (0, import_hast_util_to_html.toHtml)(result);\n return result;\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n codeToHTML: () => codeToHTML\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_hast_util_to_html = require(\"hast-util-to-html\");\nvar import_parse_numeric_range = __toESM(require(\"parse-numeric-range\"));\nvar import_refractor = require(\"refractor\");\nvar import_css = __toESM(require(\"refractor/lang/css.js\"));\nvar import_tsx = __toESM(require(\"refractor/lang/tsx.js\"));\nvar import_highlightLine = require(\"./highlightLine\");\nvar import_highlightWord = require(\"./highlightWord\");\nimport_refractor.refractor.register(import_tsx.default);\nimport_refractor.refractor.register(import_css.default);\nfunction codeToHTML(source, language) {\n var line = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : \"0\";\n var result = import_refractor.refractor.highlight(source, language);\n result = (0, import_highlightLine.highlightLine)(result, (0, import_parse_numeric_range.default)(line));\n result = (0, import_highlightWord.highlightWord)(result);\n result = (0, import_hast_util_to_html.toHtml)(result);\n return result;\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe,EACtB,kBAAkB,WACpB,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,2BAA2B,QAAQ,mBAAmB;AAC1D,IAAI,6BAA6B,QAAQ,QAAQ,qBAAqB,CAAC;AACvE,IAAI,mBAAmB,QAAQ,WAAW;AAC1C,IAAI,aAAa,QAAQ,QAAQ,uBAAuB,CAAC;AACzD,IAAI,aAAa,QAAQ,QAAQ,uBAAuB,CAAC;AACzD,IAAI,uBAAuB,QAAQ,2BAAiB;AACpD,IAAI,uBAAuB,QAAQ,2BAAiB;AACpD,iBAAiB,UAAU,SAAS,WAAW,OAAO;AACtD,iBAAiB,UAAU,SAAS,WAAW,OAAO;AACtD,SAAS,WAAW,QAAQ,UAAU;CACpC,IAAI,OAAO,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC5E,IAAI,SAAS,iBAAiB,UAAU,UAAU,QAAQ,QAAQ;CAClE,UAAU,GAAG,qBAAqB,cAAa,CAAE,SAAS,GAAG,2BAA2B,QAAO,CAAE,IAAI,CAAC;CACtG,UAAU,GAAG,qBAAqB,cAAa,CAAE,MAAM;CACvD,UAAU,GAAG,yBAAyB,OAAM,CAAE,MAAM;CACpD,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightLine.js","names":[],"sources":["esm/highlightLine.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nconst lineNumberify = function lineNumberify2(ast, lineNum = 1) {\n let lineNumber = lineNum;\n return ast.reduce(\n (result, node) => {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n const lines = node.value.split(\"\\n\");\n for (let i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n const processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n },\n { nodes: [], lineNumber }\n );\n};\nconst wrapLines = function wrapLines2(ast, linesToHighlight) {\n const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n const allLines = Array.from(new Set(ast.map((x) => x.lineNumber)));\n let i = 0;\n const wrapped = allLines.reduce((nodes, marker) => {\n const line = marker;\n const children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nconst MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nconst applyMultilineFix = (ast) => {\n let html = toHtml(ast);\n html = html.replace(\n MULTILINE_TOKEN_SPAN,\n (match, token) => match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`)\n );\n const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n const formattedAst = applyMultilineFix(ast);\n const numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\nexport {\n highlightLine\n};\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":";;;;;AAGA,MAAM,gBAAgB,SAAS,eAAe,KAAK,UAAU,GAAG;CAC9D,IAAI,aAAa;CACjB,OAAO,IAAI,QACR,QAAQ,SAAS;EAChB,IAAI,KAAK,SAAS,QAAQ;GACxB,IAAI,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,GAAG;IACnC,KAAK,aAAa;IAClB,OAAO,MAAM,KAAK,IAAI;IACtB,OAAO;GACT;GACA,MAAM,QAAQ,KAAK,MAAM,MAAM,IAAI;GACnC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,IAAI,MAAM,GAAG,EAAE;IACf,IAAI,MAAM,MAAM,SAAS,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"highlightLine.js","names":[],"sources":["esm/highlightLine.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nconst lineNumberify = function lineNumberify2(ast, lineNum = 1) {\n let lineNumber = lineNum;\n return ast.reduce(\n (result, node) => {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n const lines = node.value.split(\"\\n\");\n for (let i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n const processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n },\n { nodes: [], lineNumber }\n );\n};\nconst wrapLines = function wrapLines2(ast, linesToHighlight) {\n const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n const allLines = Array.from(new Set(ast.map((x) => x.lineNumber)));\n let i = 0;\n const wrapped = allLines.reduce((nodes, marker) => {\n const line = marker;\n const children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nconst MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nconst applyMultilineFix = (ast) => {\n let html = toHtml(ast);\n html = html.replace(\n MULTILINE_TOKEN_SPAN,\n (match, token) => match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`)\n );\n const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n const formattedAst = applyMultilineFix(ast);\n const numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\nexport {\n highlightLine\n};\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":";;;;;AAGA,MAAM,gBAAgB,SAAS,eAAe,KAAK,UAAU,GAAG;CAC9D,IAAI,aAAa;CACjB,OAAO,IAAI,QACR,QAAQ,SAAS;EAChB,IAAI,KAAK,SAAS,QAAQ;GACxB,IAAI,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,GAAG;IACnC,KAAK,aAAa;IAClB,OAAO,MAAM,KAAK,IAAI;IACtB,OAAO;GACT;GACA,MAAM,QAAQ,KAAK,MAAM,MAAM,IAAI;GACnC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,IAAI,MAAM,GAAG,EAAE;IACf,IAAI,MAAM,MAAM,SAAS,KAAK,MAAM,EAAE,CAAC,WAAW,GAAG;IACrD,OAAO,MAAM,KAAK;KAChB,MAAM;KACN,OAAO,MAAM,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,MAAM,GAAG;;KAEvD;IACF,CAAC;GACH;GACA,OAAO,aAAa;GAC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AAC,CAAC,IAAI,OAAO;EAAE,iBAAiB;EAAM,UAAU;CAAK,CAAC,CAAC,CAAC,MAAM,IAAI;CACvF,OAAO,KAAK;AACd;AACA,SAAS,cAAc,KAAK,OAAO;CACjC,MAAM,eAAe,kBAAkB,GAAG;CAC1C,MAAM,WAAW,cAAc,YAAY,CAAC,CAAC;CAC7C,OAAO,UAAU,UAAU,KAAK;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightLine.native.js","names":[],"sources":["esm/highlightLine.native.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nvar lineNumberify = function lineNumberify2(ast) {\n var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;\n var lineNumber = lineNum;\n return ast.reduce(function(result, node) {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n var lines = node.value.split(\"\\n\");\n for (var i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n var processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n }, {\n nodes: [],\n lineNumber\n });\n};\nvar wrapLines = function wrapLines2(ast, linesToHighlight) {\n var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n var allLines = Array.from(new Set(ast.map(function(x) {\n return x.lineNumber;\n })));\n var i = 0;\n var wrapped = allLines.reduce(function(nodes, marker) {\n var line = marker;\n var children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nvar MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nvar applyMultilineFix = function(ast) {\n var html = toHtml(ast);\n html = html.replace(MULTILINE_TOKEN_SPAN, function(match, token) {\n return match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`);\n });\n var hast = unified().use(parse, {\n emitParseErrors: true,\n fragment: true\n }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n var formattedAst = applyMultilineFix(ast);\n var numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\nexport {\n highlightLine\n};\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":";;;;;AAGA,IAAI,gBAAgB,SAAS,eAAe,KAAK;CAC/C,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC/E,IAAI,aAAa;CACjB,OAAO,IAAI,OAAO,SAAS,QAAQ,MAAM;EACvC,IAAI,KAAK,SAAS,QAAQ;GACxB,IAAI,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,GAAG;IACnC,KAAK,aAAa;IAClB,OAAO,MAAM,KAAK,IAAI;IACtB,OAAO;GACT;GACA,IAAI,QAAQ,KAAK,MAAM,MAAM,IAAI;GACjC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,IAAI,MAAM,GAAG,EAAE;IACf,IAAI,MAAM,MAAM,SAAS,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"highlightLine.native.js","names":[],"sources":["esm/highlightLine.native.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nvar lineNumberify = function lineNumberify2(ast) {\n var lineNum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;\n var lineNumber = lineNum;\n return ast.reduce(function(result, node) {\n if (node.type === \"text\") {\n if (node.value.indexOf(\"\\n\") === -1) {\n node.lineNumber = lineNumber;\n result.nodes.push(node);\n return result;\n }\n var lines = node.value.split(\"\\n\");\n for (var i = 0; i < lines.length; i++) {\n if (i !== 0) ++lineNumber;\n if (i === lines.length - 1 && lines[i].length === 0) continue;\n result.nodes.push({\n type: \"text\",\n value: i === lines.length - 1 ? lines[i] : `${lines[i]}\n`,\n lineNumber\n });\n }\n result.lineNumber = lineNumber;\n return result;\n }\n if (node.children) {\n node.lineNumber = lineNumber;\n var processed = lineNumberify2(node.children, lineNumber);\n node.children = processed.nodes;\n result.lineNumber = processed.lineNumber;\n result.nodes.push(node);\n return result;\n }\n result.nodes.push(node);\n return result;\n }, {\n nodes: [],\n lineNumber\n });\n};\nvar wrapLines = function wrapLines2(ast, linesToHighlight) {\n var highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;\n var allLines = Array.from(new Set(ast.map(function(x) {\n return x.lineNumber;\n })));\n var i = 0;\n var wrapped = allLines.reduce(function(nodes, marker) {\n var line = marker;\n var children = [];\n for (; i < ast.length; i++) {\n if (ast[i].lineNumber < line) {\n nodes.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber === line) {\n children.push(ast[i]);\n continue;\n }\n if (ast[i].lineNumber > line) {\n break;\n }\n }\n nodes.push({\n type: \"element\",\n tagName: \"div\",\n properties: {\n dataLine: line,\n className: \"highlight-line\",\n dataHighlighted: linesToHighlight.includes(line) || highlightAll ? \"true\" : \"false\"\n },\n children,\n lineNumber: line\n });\n return nodes;\n }, []);\n return wrapped;\n};\nvar MULTILINE_TOKEN_SPAN = /<span class=\"token ([^\"]+)\">[^<]*\\n[^<]*<\\/span>/g;\nvar applyMultilineFix = function(ast) {\n var html = toHtml(ast);\n html = html.replace(MULTILINE_TOKEN_SPAN, function(match, token) {\n return match.replace(/\\n/g, `</span>\n<span class=\"token ${token}\">`);\n });\n var hast = unified().use(parse, {\n emitParseErrors: true,\n fragment: true\n }).parse(html);\n return hast[\"children\"];\n};\nfunction highlightLine(ast, lines) {\n var formattedAst = applyMultilineFix(ast);\n var numbered = lineNumberify(formattedAst).nodes;\n return wrapLines(numbered, lines);\n}\nexport {\n highlightLine\n};\n//# sourceMappingURL=highlightLine.js.map\n"],"mappings":";;;;;AAGA,IAAI,gBAAgB,SAAS,eAAe,KAAK;CAC/C,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC/E,IAAI,aAAa;CACjB,OAAO,IAAI,OAAO,SAAS,QAAQ,MAAM;EACvC,IAAI,KAAK,SAAS,QAAQ;GACxB,IAAI,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,GAAG;IACnC,KAAK,aAAa;IAClB,OAAO,MAAM,KAAK,IAAI;IACtB,OAAO;GACT;GACA,IAAI,QAAQ,KAAK,MAAM,MAAM,IAAI;GACjC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,IAAI,MAAM,GAAG,EAAE;IACf,IAAI,MAAM,MAAM,SAAS,KAAK,MAAM,EAAE,CAAC,WAAW,GAAG;IACrD,OAAO,MAAM,KAAK;KAChB,MAAM;KACN,OAAO,MAAM,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,MAAM,GAAG;;KAEvD;IACF,CAAC;GACH;GACA,OAAO,aAAa;GACpB,OAAO;EACT;EACA,IAAI,KAAK,UAAU;GACjB,KAAK,aAAa;GAClB,IAAI,YAAY,eAAe,KAAK,UAAU,UAAU;GACxD,KAAK,WAAW,UAAU;GAC1B,OAAO,aAAa,UAAU;GAC9B,OAAO,MAAM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ACA,SAAS,cAAc,KAAK,OAAO;CACjC,IAAI,eAAe,kBAAkB,GAAG;CACxC,IAAI,WAAW,cAAc,YAAY,CAAC,CAAC;CAC3C,OAAO,UAAU,UAAU,KAAK;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightWord.js","names":[],"sources":["esm/highlightWord.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nconst CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n const html = toHtml(code);\n const result = html.replace(\n CALLOUT,\n (_, text) => `<span class=\"highlight-word\">${text}</span>`\n );\n const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(result);\n return hast[\"children\"];\n}\nexport {\n highlightWord\n};\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":";;;;;AAGA,MAAM,UAAU;AAChB,SAAS,cAAc,MAAM;CAC3B,MAAM,OAAO,OAAO,IAAI;CACxB,MAAM,SAAS,KAAK,QAClB,UACC,GAAG,SAAS,gCAAgC,KAAK,QACpD;CACA,MAAM,OAAO,QAAQ,
|
|
1
|
+
{"version":3,"file":"highlightWord.js","names":[],"sources":["esm/highlightWord.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nconst CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n const html = toHtml(code);\n const result = html.replace(\n CALLOUT,\n (_, text) => `<span class=\"highlight-word\">${text}</span>`\n );\n const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(result);\n return hast[\"children\"];\n}\nexport {\n highlightWord\n};\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":";;;;;AAGA,MAAM,UAAU;AAChB,SAAS,cAAc,MAAM;CAC3B,MAAM,OAAO,OAAO,IAAI;CACxB,MAAM,SAAS,KAAK,QAClB,UACC,GAAG,SAAS,gCAAgC,KAAK,QACpD;CACA,MAAM,OAAO,QAAQ,CAAC,CAAC,IAAI,OAAO;EAAE,iBAAiB;EAAM,UAAU;CAAK,CAAC,CAAC,CAAC,MAAM,MAAM;CACzF,OAAO,KAAK;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlightWord.native.js","names":[],"sources":["esm/highlightWord.native.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nvar CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n var html = toHtml(code);\n var result = html.replace(CALLOUT, function(_, text) {\n return `<span class=\"highlight-word\">${text}</span>`;\n });\n var hast = unified().use(parse, {\n emitParseErrors: true,\n fragment: true\n }).parse(result);\n return hast[\"children\"];\n}\nexport {\n highlightWord\n};\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":";;;;;AAGA,IAAI,UAAU;AACd,SAAS,cAAc,MAAM;CAC3B,IAAI,OAAO,OAAO,IAAI;CACtB,IAAI,SAAS,KAAK,QAAQ,SAAS,SAAS,GAAG,MAAM;EACnD,OAAO,gCAAgC,KAAK;CAC9C,CAAC;CACD,IAAI,OAAO,QAAQ,
|
|
1
|
+
{"version":3,"file":"highlightWord.native.js","names":[],"sources":["esm/highlightWord.native.js"],"sourcesContent":["import { toHtml } from \"hast-util-to-html\";\nimport parse from \"rehype-parse\";\nimport { unified } from \"unified\";\nvar CALLOUT = /__(.*?)__/g;\nfunction highlightWord(code) {\n var html = toHtml(code);\n var result = html.replace(CALLOUT, function(_, text) {\n return `<span class=\"highlight-word\">${text}</span>`;\n });\n var hast = unified().use(parse, {\n emitParseErrors: true,\n fragment: true\n }).parse(result);\n return hast[\"children\"];\n}\nexport {\n highlightWord\n};\n//# sourceMappingURL=highlightWord.js.map\n"],"mappings":";;;;;AAGA,IAAI,UAAU;AACd,SAAS,cAAc,MAAM;CAC3B,IAAI,OAAO,OAAO,IAAI;CACtB,IAAI,SAAS,KAAK,QAAQ,SAAS,SAAS,GAAG,MAAM;EACnD,OAAO,gCAAgC,KAAK;CAC9C,CAAC;CACD,IAAI,OAAO,QAAQ,CAAC,CAAC,IAAI,OAAO;EAC9B,iBAAiB;EACjB,UAAU;CACZ,CAAC,CAAC,CAAC,MAAM,MAAM;CACf,OAAO,KAAK;AACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/code-to-html",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.728.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "^0.11.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tamagui/build": "3.0.0-beta.
|
|
43
|
+
"@tamagui/build": "3.0.0-beta.728.1"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|