highlight.js
Advanced tools
Comparing version 10.4.0-beta0 to 10.4.0-beta1
@@ -116,2 +116,3 @@ /* | ||
className: 'number', | ||
relevance: 0, | ||
begin: '(-?)(\\b0[xXbBoOdD][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)' | ||
@@ -118,0 +119,0 @@ } |
@@ -5,3 +5,2 @@ /* | ||
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com> | ||
Category: common, system | ||
*/ | ||
@@ -22,3 +21,3 @@ | ||
} | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// not include such support nor can we be sure all the grammars depending | ||
@@ -25,0 +24,0 @@ // on it would desire this behavior |
@@ -0,1 +1,26 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -26,3 +51,6 @@ Language: Bash | ||
variants: [ | ||
{begin: /\$[\w\d#@][\w\d_]*/}, | ||
{begin: concat(/\$[\w\d#@][\w\d_]*/, | ||
// negative look-ahead tries to avoid matching patterns that are not | ||
// Perl at all like $ident$, @ident@, etc. | ||
`(?![\\w\\d])(?![$])`) }, | ||
BRACED_VAR | ||
@@ -29,0 +57,0 @@ ] |
@@ -5,3 +5,2 @@ /* | ||
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com> | ||
Category: common, system | ||
*/ | ||
@@ -22,3 +21,3 @@ | ||
} | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// not include such support nor can we be sure all the grammars depending | ||
@@ -25,0 +24,0 @@ // on it would desire this behavior |
@@ -5,3 +5,2 @@ /* | ||
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com> | ||
Category: common, system | ||
*/ | ||
@@ -22,3 +21,3 @@ | ||
} | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// not include such support nor can we be sure all the grammars depending | ||
@@ -25,0 +24,0 @@ // on it would desire this behavior |
@@ -19,3 +19,3 @@ /* | ||
globals + ' ' + | ||
'cond apply if-not if-let if not not= = < > <= >= == + / * - rem ' + | ||
'cond apply if-not if-let if not not= =|0 <|0 >|0 <=|0 >=|0 ==|0 +|0 /|0 *|0 -|0 rem ' + | ||
'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? ' + | ||
@@ -92,3 +92,5 @@ 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? ' + | ||
keywords: keywords, | ||
className: 'name', begin: SYMBOL_RE, | ||
className: 'name', | ||
begin: SYMBOL_RE, | ||
relevance: 0, | ||
starts: BODY | ||
@@ -95,0 +97,0 @@ }; |
@@ -5,3 +5,2 @@ /* | ||
Contributors: Evgeny Stepanischev <imbolk@gmail.com>, Zaven Muradyan <megalivoithos@gmail.com>, Roel Deckers <admin@codingcat.nl>, Sam Wu <samsam2310@gmail.com>, Jordi Petit <jordi.petit@gmail.com>, Pieter Vantorre <pietervantorre@gmail.com>, Google Inc. (David Benjamin) <davidben@google.com> | ||
Category: common, system | ||
*/ | ||
@@ -22,3 +21,3 @@ | ||
} | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
// not include such support nor can we be sure all the grammars depending | ||
@@ -25,0 +24,0 @@ // on it would desire this behavior |
@@ -161,3 +161,3 @@ /* | ||
], | ||
relevance: 5 | ||
relevance: 2 | ||
}, | ||
@@ -164,0 +164,0 @@ { |
@@ -142,3 +142,3 @@ /* | ||
'unmanaged', | ||
'value', | ||
'value|0', | ||
'var', | ||
@@ -278,3 +278,5 @@ 'when', | ||
{ | ||
beginKeywords: 'class interface', end: /[{;=]/, | ||
beginKeywords: 'class interface', | ||
relevance: 0, | ||
end: /[{;=]/, | ||
illegal: /[^\s:,]/, | ||
@@ -290,3 +292,5 @@ contains: [ | ||
{ | ||
beginKeywords: 'namespace', end: /[{;=]/, | ||
beginKeywords: 'namespace', | ||
relevance: 0, | ||
end: /[{;=]/, | ||
illegal: /[^\s:]/, | ||
@@ -300,3 +304,5 @@ contains: [ | ||
{ | ||
beginKeywords: 'record', end: /[{;=]/, | ||
beginKeywords: 'record', | ||
relevance: 0, | ||
end: /[{;=]/, | ||
illegal: /[^\s:]/, | ||
@@ -331,4 +337,7 @@ contains: [ | ||
// prevents these from being highlighted `title` | ||
{ beginKeywords: FUNCTION_MODIFIERS.join(" ")}, | ||
{ | ||
beginKeywords: FUNCTION_MODIFIERS.join(" "), | ||
relevance: 0 | ||
}, | ||
{ | ||
begin: hljs.IDENT_RE + '\\s*(<.+>)?\\s*\\(', returnBegin: true, | ||
@@ -335,0 +344,0 @@ contains: [ |
@@ -51,3 +51,3 @@ /* | ||
var RULE = { | ||
begin: /(?:[A-Z_.-]+|--[a-zA-Z0-9_-]+)\s*:/, returnBegin: true, end: ';', endsWithParent: true, | ||
begin: /([*]\s?)?(?:[A-Z_.\-\\]+|--[a-zA-Z0-9_-]+)\s*(\/\*\*\/)?:/, returnBegin: true, end: ';', endsWithParent: true, | ||
contains: [ | ||
@@ -61,3 +61,3 @@ ATTRIBUTE | ||
case_insensitive: true, | ||
illegal: /[=\/|'\$]/, | ||
illegal: /[=|'\$]/, | ||
contains: [ | ||
@@ -69,3 +69,3 @@ hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/ | ||
className: 'selector-class', begin: '\\.' + IDENT_RE | ||
}, | ||
@@ -130,2 +130,3 @@ { | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
{ begin: /;/ }, // empty ; rule | ||
RULE, | ||
@@ -132,0 +133,0 @@ ] |
@@ -112,3 +112,6 @@ /** | ||
contains: [ | ||
hljs.SHEBANG(), | ||
hljs.SHEBANG({ | ||
binary: "groovy", | ||
relevance: 10 | ||
}), | ||
COMMENT, | ||
@@ -128,3 +131,5 @@ STRING, | ||
{ | ||
className: 'meta', begin: '@[A-Za-z]+' | ||
className: 'meta', | ||
begin: '@[A-Za-z]+', | ||
relevance: 0 | ||
}, | ||
@@ -140,2 +145,3 @@ { | ||
end: /:/, | ||
relevance: 0, | ||
contains: [ | ||
@@ -142,0 +148,0 @@ COMMENT, |
@@ -89,4 +89,6 @@ /* | ||
var NAME = { | ||
className: 'name', | ||
relevance: 0, | ||
keywords: keywords, | ||
className: 'name', begin: SYMBOL_RE, | ||
begin: SYMBOL_RE, | ||
starts: BODY | ||
@@ -105,5 +107,5 @@ }; | ||
contains: [hljs.SHEBANG(), LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL] | ||
} | ||
}; | ||
} | ||
module.exports = hy; |
@@ -87,2 +87,8 @@ /* | ||
), | ||
// relevance boost | ||
{ | ||
begin: /import java\.[a-z]+\./, | ||
keywords: "import", | ||
relevance: 2 | ||
}, | ||
hljs.C_LINE_COMMENT_MODE, | ||
@@ -89,0 +95,0 @@ hljs.C_BLOCK_COMMENT_MODE, |
@@ -189,3 +189,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
const hasClosingTag = (match, { after }) => { | ||
const tag = match[0].replace("<", "</"); | ||
const tag = "</" + match[0].slice(1); | ||
const pos = match.input.indexOf(tag, after); | ||
@@ -428,5 +428,3 @@ return pos !== -1; | ||
// the first key:value pairing | ||
/(\/\/.*$)*/, | ||
/(\/\*(.|\n)*\*\/)*/, | ||
/\s*/, | ||
/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/, | ||
IDENT_RE$1 + '\\s*:'))), | ||
@@ -467,3 +465,4 @@ relevance: 0, | ||
{ | ||
begin: hljs.UNDERSCORE_IDENT_RE | ||
begin: hljs.UNDERSCORE_IDENT_RE, | ||
relevance: 0 | ||
}, | ||
@@ -470,0 +469,0 @@ { |
@@ -83,3 +83,6 @@ /* | ||
variants: [ | ||
{begin: LISP_IDENT_RE}, | ||
{ | ||
begin: LISP_IDENT_RE, | ||
relevance: 0, | ||
}, | ||
{begin: MEC_RE} | ||
@@ -86,0 +89,0 @@ ] |
@@ -253,3 +253,3 @@ const KEYWORDS = [ | ||
// regex can't start with *, and it supports an "illegal" in the main mode | ||
begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W)/ | ||
begin: /\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/ | ||
} | ||
@@ -256,0 +256,0 @@ ] |
@@ -27,2 +27,3 @@ /* | ||
className: 'number', | ||
relevance:0, | ||
begin: hljs.C_NUMBER_RE | ||
@@ -29,0 +30,0 @@ }; |
@@ -41,4 +41,4 @@ /* | ||
'triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute ' + | ||
'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i inf nan ' + | ||
'isnan isinf isfinite j why compan gallery hadamard hankel hilb invhilb magic pascal ' + | ||
'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i|0 inf nan ' + | ||
'isnan isinf isfinite j|0 why compan gallery hadamard hankel hilb invhilb magic pascal ' + | ||
'rosser toeplitz vander wilkinson max min nanmax nanmin mean nanmean type table ' + | ||
@@ -45,0 +45,0 @@ 'readtable writetable sortrows sort figure plot plot3 scatter scatter3 cellfun ' + |
@@ -55,4 +55,3 @@ /* | ||
begin: '\'', end: '\'', | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
relevance: 0 | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
}, | ||
@@ -62,4 +61,3 @@ { | ||
begin: '"', end: '"', | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
relevance: 0 | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
}, | ||
@@ -66,0 +64,0 @@ { |
@@ -76,3 +76,3 @@ /* | ||
{ | ||
begin: /[-=]>/ // relevance booster | ||
begin: /->/ // relevance booster | ||
} | ||
@@ -79,0 +79,0 @@ ] |
@@ -23,3 +23,3 @@ /* | ||
hljs.COMMENT( | ||
/\\^rem\{/, | ||
/\^rem\{/, | ||
/\}/, | ||
@@ -26,0 +26,0 @@ { |
@@ -0,1 +1,26 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -8,2 +33,3 @@ Language: Perl | ||
/** @type LanguageFn */ | ||
function perl(hljs) { | ||
@@ -44,3 +70,8 @@ var PERL_KEYWORDS = { | ||
{begin: /\$\d/}, | ||
{begin: /[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/}, | ||
{begin: concat( | ||
/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, | ||
// negative look-ahead tries to avoid matching patterns that are not | ||
// Perl at all like $ident$, @ident@, etc. | ||
`(?![A-Za-z])(?![@$%])` | ||
)}, | ||
{begin: /[$%@][^\s\w{]/, relevance: 0} | ||
@@ -47,0 +78,0 @@ ] |
@@ -16,3 +16,6 @@ /* | ||
className: 'variable', | ||
begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' | ||
begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' + | ||
// negative look-ahead tries to avoid matching patterns that are not | ||
// Perl at all like $ident$, @ident@, etc. | ||
`(?![A-Za-z0-9])(?![$])` | ||
}; | ||
@@ -75,3 +78,7 @@ const PREPROCESSOR = { | ||
// <https://www.php.net/manual/en/language.types.type-juggling.php> | ||
'array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list match new object or private protected public real return string switch throw trait try unset use var void while xor yield', | ||
'array abstract and as binary bool boolean break callable case catch class clone const continue declare ' + | ||
'default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval extends ' + | ||
'final finally float for foreach from global goto if implements instanceof insteadof int integer interface ' + | ||
'isset iterable list match|0 new object or private protected public real return string switch throw trait ' + | ||
'try unset use var void while xor yield', | ||
literal: 'false null true', | ||
@@ -128,2 +135,3 @@ built_in: | ||
className: 'function', | ||
relevance: 0, | ||
beginKeywords: 'fn function', end: /[;{]/, excludeEnd: true, | ||
@@ -134,2 +142,5 @@ illegal: '[$%\\[]', | ||
{ | ||
begin: '=>' // No markup, just a relevance booster | ||
}, | ||
{ | ||
className: 'params', | ||
@@ -152,3 +163,6 @@ begin: '\\(', end: '\\)', | ||
className: 'class', | ||
beginKeywords: 'class interface', end: /\{/, excludeEnd: true, | ||
beginKeywords: 'class interface', | ||
relevance: 0, | ||
end: /\{/, | ||
excludeEnd: true, | ||
illegal: /[:($"]/, | ||
@@ -161,3 +175,5 @@ contains: [ | ||
{ | ||
beginKeywords: 'namespace', end: ';', | ||
beginKeywords: 'namespace', | ||
relevance: 0, | ||
end: ';', | ||
illegal: /[.']/, | ||
@@ -167,8 +183,7 @@ contains: [hljs.UNDERSCORE_TITLE_MODE] | ||
{ | ||
beginKeywords: 'use', end: ';', | ||
beginKeywords: 'use', | ||
relevance: 0, | ||
end: ';', | ||
contains: [hljs.UNDERSCORE_TITLE_MODE] | ||
}, | ||
{ | ||
begin: '=>' // No markup, just a relevance booster | ||
}, | ||
STRING, | ||
@@ -175,0 +190,0 @@ NUMBER |
@@ -14,3 +14,5 @@ /* | ||
// delimiter | ||
var DELIM = '(' + WS0+'[:=]'+WS0+ '|' + WS1 + ')'; | ||
var EQUAL_DELIM = WS0+'[:=]'+WS0; | ||
var WS_DELIM = WS1; | ||
var DELIM = '(' + EQUAL_DELIM + '|' + WS_DELIM + ')'; | ||
var KEY_ALPHANUM = '([^\\\\\\W:= \\t\\f\\n]|\\\\.)+'; | ||
@@ -43,4 +45,7 @@ var KEY_OTHER = '([^\\\\:= \\t\\f\\n]|\\\\.)+'; | ||
{ | ||
begin: KEY_ALPHANUM + DELIM, | ||
returnBegin: true, | ||
variants: [ | ||
{ begin: KEY_ALPHANUM + EQUAL_DELIM, relevance: 1 }, | ||
{ begin: KEY_ALPHANUM + WS_DELIM, relevance: 0 } | ||
], | ||
contains: [ | ||
@@ -47,0 +52,0 @@ { |
@@ -39,5 +39,5 @@ /* | ||
}, | ||
{ | ||
begin: /^\s*[A-Z_]+/, | ||
end: /\s*=/, excludeEnd: true | ||
{ // match enum items (relevance) | ||
// BLAH = ...; | ||
begin: /^\s*[A-Z_]+(?=\s*=[^\n]+;$)/ | ||
} | ||
@@ -44,0 +44,0 @@ ] |
@@ -257,2 +257,3 @@ /* | ||
// labeled as an f-string as in: | ||
{ begin: /\bself\b/, }, // very common convention | ||
{ beginKeywords: "if", relevance: 0 }, | ||
@@ -259,0 +260,0 @@ STRING, |
@@ -0,1 +1,26 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -18,2 +43,3 @@ Language: R | ||
const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; | ||
const SIMPLE_IDENT = /[a-zA-Z][a-zA-Z_0-9]*/; | ||
@@ -23,2 +49,4 @@ return { | ||
// only in Haskell, not R | ||
illegal: /->/, | ||
keywords: { | ||
@@ -37,18 +65,18 @@ $pattern: IDENT_RE, | ||
// `.Primitive`, minus those functions that are also keywords. | ||
'abs acos acosh all any anyNA Arg as.call as.character' + | ||
'as.complex as.double as.environment as.integer as.logical' + | ||
'as.null.default as.numeric as.raw asin asinh atan atanh attr' + | ||
'attributes baseenv browser c call ceiling class Conj cos cosh' + | ||
'cospi cummax cummin cumprod cumsum digamma dim dimnames' + | ||
'emptyenv exp expression floor forceAndCall gamma gc.time' + | ||
'globalenv Im interactive invisible is.array is.atomic is.call' + | ||
'is.character is.complex is.double is.environment is.expression' + | ||
'is.finite is.function is.infinite is.integer is.language' + | ||
'is.list is.logical is.matrix is.na is.name is.nan is.null' + | ||
'is.numeric is.object is.pairlist is.raw is.recursive is.single' + | ||
'is.symbol lazyLoadDBfetch length lgamma list log max min' + | ||
'missing Mod names nargs nzchar oldClass on.exit pos.to.env' + | ||
'proc.time prod quote range Re rep retracemem return round' + | ||
'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt' + | ||
'standardGeneric substitute sum switch tan tanh tanpi tracemem' + | ||
'abs acos acosh all any anyNA Arg as.call as.character ' + | ||
'as.complex as.double as.environment as.integer as.logical ' + | ||
'as.null.default as.numeric as.raw asin asinh atan atanh attr ' + | ||
'attributes baseenv browser c call ceiling class Conj cos cosh ' + | ||
'cospi cummax cummin cumprod cumsum digamma dim dimnames ' + | ||
'emptyenv exp expression floor forceAndCall gamma gc.time ' + | ||
'globalenv Im interactive invisible is.array is.atomic is.call ' + | ||
'is.character is.complex is.double is.environment is.expression ' + | ||
'is.finite is.function is.infinite is.integer is.language ' + | ||
'is.list is.logical is.matrix is.na is.name is.nan is.null ' + | ||
'is.numeric is.object is.pairlist is.raw is.recursive is.single ' + | ||
'is.symbol lazyLoadDBfetch length lgamma list log max min ' + | ||
'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' + | ||
'proc.time prod quote range Re rep retracemem return round ' + | ||
'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' + | ||
'standardGeneric substitute sum switch tan tanh tanpi tracemem ' + | ||
'trigamma trunc unclass untracemem UseMethod xtfrm', | ||
@@ -174,4 +202,7 @@ }, | ||
}, | ||
// relevance boost for assignment | ||
{ | ||
begin: concat(SIMPLE_IDENT, "\\s+<-\\s+") | ||
}, | ||
{ | ||
// escaped identifier | ||
@@ -178,0 +209,0 @@ begin: '`', |
@@ -0,1 +1,34 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function lookahead(re) { | ||
return concat('(?=', re, ')'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -11,3 +44,3 @@ Language: Ruby | ||
function ruby(hljs) { | ||
var RUBY_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; | ||
var RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)'; | ||
var RUBY_KEYWORDS = { | ||
@@ -17,3 +50,5 @@ keyword: | ||
'next until do begin unless END rescue else break undef not super class case ' + | ||
'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor', | ||
'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor ' + | ||
'__FILE__', | ||
built_in: 'proc lambda', | ||
literal: | ||
@@ -117,3 +152,2 @@ 'true false nil' | ||
STRING, | ||
IRB_OBJECT, | ||
{ | ||
@@ -135,3 +169,8 @@ className: 'class', | ||
className: 'function', | ||
beginKeywords: 'def', end: '$|;', | ||
// def method_name( | ||
// def method_name; | ||
// def method_name (end of line) | ||
begin: concat(/def\s*/, lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")), | ||
keywords: "def", | ||
end: '$|;', | ||
contains: [ | ||
@@ -159,7 +198,12 @@ hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}), | ||
{ | ||
begin: '(\\$\\W)|((\\$|@@?)(\\w+))' // variables | ||
// negative-look forward attemps 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: /\|/, | ||
begin: /\|/, | ||
end: /\|/, | ||
relevance:0, // this could be a lot of things (in other languages) other than params | ||
keywords: RUBY_KEYWORDS | ||
@@ -171,3 +215,2 @@ }, | ||
contains: [ | ||
IRB_OBJECT, | ||
{ | ||
@@ -185,6 +228,6 @@ className: 'regexp', | ||
} | ||
].concat(COMMENT_MODES), | ||
].concat(IRB_OBJECT, COMMENT_MODES), | ||
relevance: 0 | ||
} | ||
].concat(COMMENT_MODES); | ||
].concat(IRB_OBJECT, COMMENT_MODES); | ||
@@ -194,3 +237,6 @@ SUBST.contains = RUBY_DEFAULT_CONTAINS; | ||
// >> | ||
// ?> | ||
var SIMPLE_PROMPT = "[>?]>"; | ||
// irb(main):001:0> | ||
var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>"; | ||
@@ -208,3 +254,3 @@ var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>"; | ||
className: 'meta', | ||
begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')', | ||
begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')(?=[ ])', | ||
starts: { | ||
@@ -216,2 +262,4 @@ end: '$', contains: RUBY_DEFAULT_CONTAINS | ||
COMMENT_MODES.unshift(IRB_OBJECT); | ||
return { | ||
@@ -222,3 +270,8 @@ name: 'Ruby', | ||
illegal: /\/\*/, | ||
contains: COMMENT_MODES.concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS) | ||
contains: [ | ||
hljs.SHEBANG({binary:"ruby"}), | ||
] | ||
.concat(IRB_DEFAULT) | ||
.concat(COMMENT_MODES) | ||
.concat(RUBY_DEFAULT_CONTAINS) | ||
}; | ||
@@ -225,0 +278,0 @@ } |
@@ -113,2 +113,3 @@ /* | ||
className: 'name', | ||
relevance: 0, | ||
begin: SCHEME_IDENT_RE, | ||
@@ -115,0 +116,0 @@ keywords: KEYWORDS |
@@ -159,3 +159,4 @@ /* | ||
beginKeywords: 'import', end: /$/, | ||
contains: [hljs.C_LINE_COMMENT_MODE, BLOCK_COMMENT] | ||
contains: [hljs.C_LINE_COMMENT_MODE, BLOCK_COMMENT], | ||
relevance: 0 | ||
} | ||
@@ -162,0 +163,0 @@ ] |
@@ -189,3 +189,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
const hasClosingTag = (match, { after }) => { | ||
const tag = match[0].replace("<", "</"); | ||
const tag = "</" + match[0].slice(1); | ||
const pos = match.input.indexOf(tag, after); | ||
@@ -428,5 +428,3 @@ return pos !== -1; | ||
// the first key:value pairing | ||
/(\/\/.*$)*/, | ||
/(\/\*(.|\n)*\*\/)*/, | ||
/\s*/, | ||
/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/, | ||
IDENT_RE$1 + '\\s*:'))), | ||
@@ -467,3 +465,4 @@ relevance: 0, | ||
{ | ||
begin: hljs.UNDERSCORE_IDENT_RE | ||
begin: hljs.UNDERSCORE_IDENT_RE, | ||
relevance: 0 | ||
}, | ||
@@ -470,0 +469,0 @@ { |
@@ -0,1 +1,38 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/** | ||
* Any of the passed expresssions may match | ||
* | ||
* Creates a huge this | this | that | that match | ||
* @param {(RegExp | string)[] } args | ||
* @returns {string} | ||
*/ | ||
function either(...args) { | ||
const joined = '(' + args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -10,3 +47,34 @@ Language: VBScript | ||
/** @type LanguageFn */ | ||
function vbscript(hljs) { | ||
const BUILT_IN_FUNCTIONS = ('lcase month vartype instrrev ubound setlocale getobject rgb getref string ' + | ||
'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' + | ||
'conversions csng timevalue second year space abs clng timeserial fixs len asc ' + | ||
'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' + | ||
'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' + | ||
'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' + | ||
'strcomp int createobject loadpicture tan formatnumber mid ' + | ||
'split cint sin datepart ltrim sqr ' + | ||
'time derived eval date formatpercent exp inputbox left ascw ' + | ||
'chrw regexp cstr err').split(" "); | ||
const BUILT_IN_OBJECTS = [ | ||
"server", | ||
"response", | ||
"request", | ||
// take no arguments so can be called without () | ||
"scriptengine", | ||
"scriptenginebuildversion", | ||
"scriptengineminorversion", | ||
"scriptenginemajorversion" | ||
]; | ||
const BUILT_IN_CALL = { | ||
begin: concat(either(...BUILT_IN_FUNCTIONS), "\\s*\\("), | ||
// relevance 0 because this is acting as a beginKeywords really | ||
relevance:0, | ||
keywords: { | ||
built_in: BUILT_IN_FUNCTIONS.join(" ") | ||
} | ||
}; | ||
return { | ||
@@ -22,13 +90,3 @@ name: 'VBScript', | ||
'class_initialize class_terminate default preserve in me byval byref step resume goto', | ||
built_in: | ||
'lcase month vartype instrrev ubound setlocale getobject rgb getref string ' + | ||
'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' + | ||
'conversions csng timevalue second year space abs clng timeserial fixs len asc ' + | ||
'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' + | ||
'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' + | ||
'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' + | ||
'strcomp int createobject loadpicture tan formatnumber mid scriptenginebuildversion ' + | ||
'scriptengine split scriptengineminorversion cint sin datepart ltrim sqr ' + | ||
'scriptenginemajorversion time derived eval date formatpercent exp inputbox left ascw ' + | ||
'chrw regexp server response request cstr err', | ||
built_in: BUILT_IN_OBJECTS.join(" "), | ||
literal: | ||
@@ -39,2 +97,3 @@ 'true false null nothing empty' | ||
contains: [ | ||
BUILT_IN_CALL, | ||
hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}), | ||
@@ -41,0 +100,0 @@ hljs.COMMENT( |
@@ -156,3 +156,4 @@ /* | ||
className: 'number', | ||
begin: hljs.C_NUMBER_RE + '\\b' | ||
begin: hljs.C_NUMBER_RE + '\\b', | ||
relevance: 0 | ||
}, | ||
@@ -159,0 +160,0 @@ OBJECT, |
@@ -9,3 +9,3 @@ { | ||
"homepage": "https://highlightjs.org/", | ||
"version": "10.4.0-beta0", | ||
"version": "10.4.0-beta1", | ||
"author": { | ||
@@ -1212,2 +1212,5 @@ "name": "Ivan Sagalaev", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^16.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.6.1", | ||
@@ -1219,2 +1222,3 @@ "@typescript-eslint/parser": "^4.6.1", | ||
"commander": "^6.2.0", | ||
"deep-freeze-es6": "^1.3.1", | ||
"del": "^6.0.0", | ||
@@ -1236,4 +1240,2 @@ "dependency-resolver": "^2.0.1", | ||
"rollup": "^2.33.1", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-json": "^4.0.0", | ||
"should": "^13.2.3", | ||
@@ -1240,0 +1242,0 @@ "terser": "^5.3.8", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1632921
43598
30