prism-code-editor
Version:
Lightweight, extensible code editor component for the web using Prism
19 lines (18 loc) • 981 B
JavaScript
import { l as c } from "../index-fa58cb3b.js";
import { c as e, i as g } from "../patterns-9129a01c.js";
import "../prismCore-5c7f03d0.js";
const o = /(?:^|[^\w$]|(?=<\/))(?:<(?:([\w.:-]+)(?:(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"\/>=]+|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})))?|(?:\{(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)*\.{3}(?:[^{}]|(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\}))*\})))*(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)*)?>)[ \t]*$/, m = /^<\/[\w.:-]*\s*>/;
c.jsx = c.tsx = {
comments: {
line: "//",
block: ["/*", "*/"]
},
autoIndent: [
([s], t) => o.test(t = t.substring(s - 999, s)) || e.test(t),
([s, t], n) => g.test(n[s - 1] + n[t]) || o.test(n.substring(s - 999, s)) && m.test(n.slice(t, t + 999))
],
autoCloseTags([s, t], n) {
const i = s == t ? (n.slice(0, s) + ">").match(o) : null;
return i != null ? `</${i[1] || ""}>` : "";
}
};