UNPKG

prism-code-editor

Version:

Lightweight, extensible code editor component for the web using Prism

50 lines (49 loc) 1.74 kB
import { l as languages, a as tokenize, w as withoutTokenizer } from "../../index-C1_GGQ8y.js"; import { b as braces } from "../../jsx-shared-Dd7t2otl.js"; import { a as astroTag, b as addInlined } from "../../markup-shared-D_TTcCGm.js"; import { r as re } from "../../shared-Sq5P6lf6.js"; import { e as entity, x as xmlComment } from "../../xml-shared-D4vCmq1i.js"; var currentLang; var expression = { pattern: RegExp(braces, "g"), greedy: true }; var tag = astroTag(expression); var tagInside = tag.inside; var blockInside = { "punctuation": /^\W|\}$/, "keyword": /^\w+|\bthen\b(?!\s*[^\s[{$\w\xa0-\uffff])/ }; var blockLang = { pattern: /[^]+/ }; tagInside["attr-value"].inside["expression"] = expression; languages.svelte = { "comment": xmlComment, "script": addInlined("script", tagInside, (code) => { return /^[^>]+?[\s"'}]lang\s*=\s*(["'])ts\1/.test(code) ? "ts" : "js"; }), "style": addInlined("style", tagInside, (code) => { return /^[^>]+?[\s"'}]lang\s*=\s*(["'])(less|s[ac]ss|stylus)\1/.exec(code)?.[2] || "css"; }), "block": { pattern: re("\\{[#@:/]\\w*(?:\\s(?:[^{}]|<0>)*)?\\}", [braces], "g"), greedy: true, inside: blockInside }, "tag": tag, "expression": expression, "entity": entity, "punctuation": /[()[\]{}]/, [tokenize](code, grammar) { var lang = /<script\s(?:[^>]*?[\s"'}])?lang\s*=\s*(["'])ts\1/.test(code) ? "ts" : "js"; if (lang != currentLang) { expression.alias = "language-" + lang; delete blockInside["language-" + currentLang]; blockInside["language-" + lang] = blockLang; expression.inside = blockLang.inside = currentLang = lang; } return withoutTokenizer(code, grammar); } }; //# sourceMappingURL=svelte.js.map