UNPKG

prism-react-editor

Version:

Lightweight, extensible code editor component for React apps

69 lines (68 loc) 2.1 kB
import { l as languages, a as tokenize, w as withoutTokenizer } from "../../index-k28m3HFc.js"; import { c as clone } from "../../language-gdIi4UL0-CMkpAmgk.js"; import { b as addInlined } from "../../markup-shared-D_TTcCGm-BO16p_bi.js"; import { e as entity, x as xmlComment, t as tag } from "../../xml-shared-D4vCmq1i-D4vCmq1i.js"; var vueTag = clone(tag); var tagInside = vueTag.inside; var currentLang; var expression = { pattern: /(\{\{)[^]+?(?=\}\})/g, lookbehind: true, greedy: true }; var attrLang = { pattern: /[^]+/ }; var attrInside = { "punctuation": /^["']|["']$/ }; tagInside["attr-value"].unshift( { pattern: /([\s"'](?::|@|v-)[^\s/=>]+\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s>]+)/g, lookbehind: true, greedy: true, alias: "script", inside: attrInside }, { pattern: /([\s"']style\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s>]+)/g, lookbehind: true, greedy: true, alias: "style", inside: { "punctuation": /^["']|["']$/, "language-css": { pattern: /[^]+/, inside: "css" } } } ); tagInside["attr-name"].inside = { "punctuation": /[[\].:@#]/ }; tagInside["tag"].inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/; languages.vue = { "comment": xmlComment, "script": addInlined("script", tagInside, (code) => { return /^[^>]+?[\s"']lang\s*=\s*(["'])([jt]sx?)\1/.exec(code)?.[2] || "js"; }), "style": addInlined("style", tagInside, (code) => { return /^[^>]+?[\s"']lang\s*=\s*(["'])(less|s[ac]ss|stylus)\1/.exec(code)?.[2] || "css"; }), "expression": expression, "tag": vueTag, "entity": entity, "punctuation": /\{\{|\}\}|[()[\]{}]/, [tokenize](code, grammar) { var lang = /<script\s(?:[^>]*?[\s"'])?lang\s*=\s*(["'])([jt]s)x?\1/.exec(code)?.[2] || "js"; if (lang != currentLang) { expression.alias = "language-" + lang; delete attrInside["language-" + currentLang]; attrInside["language-" + lang] = attrLang; expression.inside = attrLang.inside = currentLang = lang; } return withoutTokenizer(code, grammar); } }; //# sourceMappingURL=vue.js.map