vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
396 lines (395 loc) • 8.76 kB
JavaScript
var o, N;
function x() {
if (N) return o;
N = 1;
function A(e) {
const t = e.regex, b = "([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)", _ = t.either(
/\b([A-Z]+[a-z0-9]+)+/,
// ends in caps
/\b([A-Z]+[a-z0-9]+)+[A-Z]+/
), a = t.concat(_, /(::\w+)*/), n = {
"variable.constant": [
"__FILE__",
"__LINE__",
"__ENCODING__"
],
"variable.language": [
"self",
"super"
],
keyword: [
"alias",
"and",
"begin",
"BEGIN",
"break",
"case",
"class",
"defined",
"do",
"else",
"elsif",
"end",
"END",
"ensure",
"for",
"if",
"in",
"module",
"next",
"not",
"or",
"redo",
"require",
"rescue",
"retry",
"return",
"then",
"undef",
"unless",
"until",
"when",
"while",
"yield",
...[
"include",
"extend",
"prepend",
"public",
"private",
"protected",
"raise",
"throw"
]
],
built_in: [
"proc",
"lambda",
"attr_accessor",
"attr_reader",
"attr_writer",
"define_method",
"private_constant",
"module_function"
],
literal: [
"true",
"false",
"nil"
]
}, E = {
className: "doctag",
begin: "@[A-Za-z]+"
}, r = {
begin: "#<",
end: ">"
}, i = [
e.COMMENT(
"#",
"$",
{ contains: [E] }
),
e.COMMENT(
"^=begin",
"^=end",
{
contains: [E],
relevance: 10
}
),
e.COMMENT("^__END__", e.MATCH_NOTHING_RE)
], c = {
className: "subst",
begin: /#\{/,
end: /\}/,
keywords: n
}, d = {
className: "string",
contains: [
e.BACKSLASH_ESCAPE,
c
],
variants: [
{
begin: /'/,
end: /'/
},
{
begin: /"/,
end: /"/
},
{
begin: /`/,
end: /`/
},
{
begin: /%[qQwWx]?\(/,
end: /\)/
},
{
begin: /%[qQwWx]?\[/,
end: /\]/
},
{
begin: /%[qQwWx]?\{/,
end: /\}/
},
{
begin: /%[qQwWx]?</,
end: />/
},
{
begin: /%[qQwWx]?\//,
end: /\//
},
{
begin: /%[qQwWx]?%/,
end: /%/
},
{
begin: /%[qQwWx]?-/,
end: /-/
},
{
begin: /%[qQwWx]?\|/,
end: /\|/
},
// in the following expressions, \B in the beginning suppresses recognition of ?-sequences
// where ? is the last character of a preceding identifier, as in: `func?4`
{ begin: /\B\?(\\\d{1,3})/ },
{ begin: /\B\?(\\x[A-Fa-f0-9]{1,2})/ },
{ begin: /\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/ },
{ begin: /\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/ },
{ begin: /\B\?\\(c|C-)[\x20-\x7e]/ },
{ begin: /\B\?\\?\S/ },
// heredocs
{
// this guard makes sure that we have an entire heredoc and not a false
// positive (auto-detect, etc.)
begin: t.concat(
/<<[-~]?'?/,
t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)
),
contains: [
e.END_SAME_AS_BEGIN({
begin: /(\w+)/,
end: /(\w+)/,
contains: [
e.BACKSLASH_ESCAPE,
c
]
})
]
}
]
}, u = "[1-9](_?[0-9])*|0", l = "[0-9](_?[0-9])*", S = {
className: "number",
relevance: 0,
variants: [
// decimal integer/float, optionally exponential or rational, optionally imaginary
{ begin: `\\b(${u})(\\.(${l}))?([eE][+-]?(${l})|r)?i?\\b` },
// explicit decimal/binary/octal/hexadecimal integer,
// optionally rational and/or imaginary
{ begin: "\\b0[dD][0-9](_?[0-9])*r?i?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*r?i?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*r?i?\\b" },
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b" },
// 0-prefixed implicit octal integer, optionally rational and/or imaginary
{ begin: "\\b0(_?[0-7])+r?i?\\b" }
]
}, g = {
variants: [
{
match: /\(\)/
},
{
className: "params",
begin: /\(/,
end: /(?=\))/,
excludeBegin: !0,
endsParent: !0,
keywords: n
}
]
}, s = [
d,
{
variants: [
{
match: [
/class\s+/,
a,
/\s+<\s+/,
a
]
},
{
match: [
/\b(class|module)\s+/,
a
]
}
],
scope: {
2: "title.class",
4: "title.class.inherited"
},
keywords: n
},
{
match: [
/(include|extend)\s+/,
a
],
scope: {
2: "title.class"
},
keywords: n
},
{
relevance: 0,
match: [
a,
/\.new[. (]/
],
scope: {
1: "title.class"
}
},
{
relevance: 0,
match: /\b[A-Z][A-Z_0-9]+\b/,
className: "variable.constant"
},
{
relevance: 0,
match: _,
scope: "title.class"
},
{
match: [
/def/,
/\s+/,
b
],
scope: {
1: "keyword",
3: "title.function"
},
contains: [
g
]
},
{
// swallow namespace qualifiers before symbols
begin: e.IDENT_RE + "::"
},
{
className: "symbol",
begin: e.UNDERSCORE_IDENT_RE + "(!|\\?)?:",
relevance: 0
},
{
className: "symbol",
begin: ":(?!\\s)",
contains: [
d,
{ begin: b }
],
relevance: 0
},
S,
{
// negative-look forward attempts to prevent false matches like:
// @ident@ or $ident$ that might indicate this is not ruby at all
className: "variable",
begin: "(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"
},
{
className: "params",
begin: /\|/,
end: /\|/,
excludeBegin: !0,
excludeEnd: !0,
relevance: 0,
// this could be a lot of things (in other languages) other than params
keywords: n
},
{
// regexp container
begin: "(" + e.RE_STARTERS_RE + "|unless)\\s*",
keywords: "unless",
contains: [
{
className: "regexp",
contains: [
e.BACKSLASH_ESCAPE,
c
],
illegal: /\n/,
variants: [
{
begin: "/",
end: "/[a-z]*"
},
{
begin: /%r\{/,
end: /\}[a-z]*/
},
{
begin: "%r\\(",
end: "\\)[a-z]*"
},
{
begin: "%r!",
end: "![a-z]*"
},
{
begin: "%r\\[",
end: "\\][a-z]*"
}
]
}
].concat(r, i),
relevance: 0
}
].concat(r, i);
c.contains = s, g.contains = s;
const T = [
{
begin: /^\s*=>/,
starts: {
end: "$",
contains: s
}
},
{
className: "meta.prompt",
begin: "^(" + "[>?]>" + "|" + "[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]" + "|" + "(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>" + ")(?=[ ])",
starts: {
end: "$",
keywords: n,
contains: s
}
}
];
return i.unshift(r), {
name: "Ruby",
aliases: [
"rb",
"gemspec",
"podspec",
"thor",
"irb"
],
keywords: n,
illegal: /\/\*/,
contains: [e.SHEBANG({ binary: "ruby" })].concat(T).concat(i).concat(s)
};
}
return o = A, o;
}
export {
x as __require
};
//# sourceMappingURL=ruby.mjs.map