vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
407 lines (406 loc) • 8.82 kB
JavaScript
var b, g;
function A() {
if (g) return b;
g = 1;
function S(e) {
const u = e.regex, s = new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*", "u"), d = [
"and",
"as",
"assert",
"async",
"await",
"break",
"case",
"class",
"continue",
"def",
"del",
"elif",
"else",
"except",
"finally",
"for",
"from",
"global",
"if",
"import",
"in",
"is",
"lambda",
"match",
"nonlocal|10",
"not",
"or",
"pass",
"raise",
"return",
"try",
"while",
"with",
"yield"
], r = {
$pattern: /[A-Za-z]\w+|__\w+__/,
keyword: d,
built_in: [
"__import__",
"abs",
"all",
"any",
"ascii",
"bin",
"bool",
"breakpoint",
"bytearray",
"bytes",
"callable",
"chr",
"classmethod",
"compile",
"complex",
"delattr",
"dict",
"dir",
"divmod",
"enumerate",
"eval",
"exec",
"filter",
"float",
"format",
"frozenset",
"getattr",
"globals",
"hasattr",
"hash",
"help",
"hex",
"id",
"input",
"int",
"isinstance",
"issubclass",
"iter",
"len",
"list",
"locals",
"map",
"max",
"memoryview",
"min",
"next",
"object",
"oct",
"open",
"ord",
"pow",
"print",
"property",
"range",
"repr",
"reversed",
"round",
"set",
"setattr",
"slice",
"sorted",
"staticmethod",
"str",
"sum",
"super",
"tuple",
"type",
"vars",
"zip"
],
literal: [
"__debug__",
"Ellipsis",
"False",
"None",
"NotImplemented",
"True"
],
type: [
"Any",
"Callable",
"Coroutine",
"Dict",
"List",
"Literal",
"Generic",
"Optional",
"Sequence",
"Set",
"Tuple",
"Type",
"Union"
]
}, n = {
className: "meta",
begin: /^(>>>|\.\.\.) /
}, i = {
className: "subst",
begin: /\{/,
end: /\}/,
keywords: r,
illegal: /#/
}, o = {
begin: /\{\{/,
relevance: 0
}, c = {
className: "string",
contains: [e.BACKSLASH_ESCAPE],
variants: [
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,
end: /'''/,
contains: [
e.BACKSLASH_ESCAPE,
n
],
relevance: 10
},
{
begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,
end: /"""/,
contains: [
e.BACKSLASH_ESCAPE,
n
],
relevance: 10
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'''/,
end: /'''/,
contains: [
e.BACKSLASH_ESCAPE,
n,
o,
i
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"""/,
end: /"""/,
contains: [
e.BACKSLASH_ESCAPE,
n,
o,
i
]
},
{
begin: /([uU]|[rR])'/,
end: /'/,
relevance: 10
},
{
begin: /([uU]|[rR])"/,
end: /"/,
relevance: 10
},
{
begin: /([bB]|[bB][rR]|[rR][bB])'/,
end: /'/
},
{
begin: /([bB]|[bB][rR]|[rR][bB])"/,
end: /"/
},
{
begin: /([fF][rR]|[rR][fF]|[fF])'/,
end: /'/,
contains: [
e.BACKSLASH_ESCAPE,
o,
i
]
},
{
begin: /([fF][rR]|[rR][fF]|[fF])"/,
end: /"/,
contains: [
e.BACKSLASH_ESCAPE,
o,
i
]
},
e.APOS_STRING_MODE,
e.QUOTE_STRING_MODE
]
}, t = "[0-9](_?[0-9])*", _ = `(\\b(${t}))?\\.(${t})|\\b(${t})\\.`, a = `\\b|${d.join("|")}`, l = {
className: "number",
relevance: 0,
variants: [
// exponentfloat, pointfloat
// https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals
// optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
// Note: no leading \b because floats can start with a decimal point
// and we don't want to mishandle e.g. `fn(.5)`,
// no trailing \b for pointfloat because it can end with a decimal point
// and we don't want to mishandle e.g. `0..hex()`; this should be safe
// because both MUST contain a decimal point and so cannot be confused with
// the interior part of an identifier
{
begin: `(\\b(${t})|(${_}))[eE][+-]?(${t})[jJ]?(?=${a})`
},
{
begin: `(${_})[jJ]?`
},
// decinteger, bininteger, octinteger, hexinteger
// https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals
// optionally "long" in Python 2
// https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals
// decinteger is optionally imaginary
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${a})`
},
{
begin: `\\b0[bB](_?[01])+[lL]?(?=${a})`
},
{
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${a})`
},
{
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${a})`
},
// imagnumber (digitpart-based)
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
{
begin: `\\b(${t})[jJ](?=${a})`
}
]
}, m = {
className: "comment",
begin: u.lookahead(/# type:/),
end: /$/,
keywords: r,
contains: [
{
// prevent keywords from coloring `type`
begin: /# type:/
},
// comment within a datatype comment includes no keywords
{
begin: /#/,
end: /\b\B/,
endsWithParent: !0
}
]
}, p = {
className: "params",
variants: [
// Exclude params in functions without params
{
className: "",
begin: /\(\s*\)/,
skip: !0
},
{
begin: /\(/,
end: /\)/,
excludeBegin: !0,
excludeEnd: !0,
keywords: r,
contains: [
"self",
n,
l,
c,
e.HASH_COMMENT_MODE
]
}
]
};
return i.contains = [
c,
l,
n
], {
name: "Python",
aliases: [
"py",
"gyp",
"ipython"
],
unicodeRegex: !0,
keywords: r,
illegal: /(<\/|\?)|=>/,
contains: [
n,
l,
{
// very common convention
scope: "variable.language",
match: /\bself\b/
},
{
// eat "if" prior to string so that it won't accidentally be
// labeled as an f-string
beginKeywords: "if",
relevance: 0
},
{ match: /\bor\b/, scope: "keyword" },
c,
m,
e.HASH_COMMENT_MODE,
{
match: [
/\bdef/,
/\s+/,
s
],
scope: {
1: "keyword",
3: "title.function"
},
contains: [p]
},
{
variants: [
{
match: [
/\bclass/,
/\s+/,
s,
/\s*/,
/\(\s*/,
s,
/\s*\)/
]
},
{
match: [
/\bclass/,
/\s+/,
s
]
}
],
scope: {
1: "keyword",
3: "title.class",
6: "title.class.inherited"
}
},
{
className: "meta",
begin: /^[\t ]*@/,
end: /(?=#)|$/,
contains: [
l,
p,
c
]
}
]
};
}
return b = S, b;
}
export {
A as __require
};
//# sourceMappingURL=python.mjs.map