highlight.js
Advanced tools
Comparing version 11.2.0 to 11.3.0
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards | ||
import hljs from '../lib/common.js'; | ||
export default hljs; | ||
import HighlightJS from '../lib/common.js'; | ||
export { HighlightJS }; | ||
export default HighlightJS; |
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards | ||
import hljs from '../lib/core.js'; | ||
export default hljs; | ||
import HighlightJS from '../lib/core.js'; | ||
export { HighlightJS }; | ||
export default HighlightJS; |
// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards | ||
import hljs from '../lib/index.js'; | ||
export default hljs; | ||
import HighlightJS from '../lib/index.js'; | ||
export { HighlightJS }; | ||
export default HighlightJS; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Augmented Backus-Naur Form | ||
function abnf(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT = /^[a-zA-Z][a-zA-Z0-9-]*/; | ||
@@ -81,3 +57,3 @@ | ||
scope: "attribute", | ||
match: concat(IDENT, /(?=\s*=)/) | ||
match: regex.concat(IDENT, /(?=\s*=)/) | ||
}; | ||
@@ -108,2 +84,2 @@ | ||
export default abnf; | ||
export { abnf as default }; |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,3 +11,4 @@ Language: Apache Access Log | ||
/** @type LanguageFn */ | ||
function accesslog(_hljs) { | ||
function accesslog(hljs) { | ||
const regex = hljs.regex; | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods | ||
@@ -94,3 +44,3 @@ const HTTP_VERBS = [ | ||
className: 'string', | ||
begin: concat(/"/, either(...HTTP_VERBS)), | ||
begin: regex.concat(/"/, regex.either(...HTTP_VERBS)), | ||
end: /"/, | ||
@@ -144,2 +94,2 @@ keywords: HTTP_VERBS, | ||
export default accesslog; | ||
export { accesslog as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,6 +10,7 @@ Language: ActionScript | ||
function actionscript(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/; | ||
const PKG_NAME_RE = concat( | ||
const PKG_NAME_RE = regex.concat( | ||
IDENT_RE, | ||
concat("(\\.", IDENT_RE, ")*") | ||
regex.concat("(\\.", IDENT_RE, ")*") | ||
); | ||
@@ -169,3 +145,3 @@ const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/; | ||
}, | ||
{ begin: concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) } | ||
{ begin: regex.concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) } | ||
] | ||
@@ -179,2 +155,2 @@ }, | ||
export default actionscript; | ||
export { actionscript as default }; |
@@ -263,2 +263,2 @@ /* | ||
export default ada; | ||
export { ada as default }; |
@@ -178,2 +178,2 @@ /* | ||
export default angelscript; | ||
export { angelscript as default }; |
@@ -103,2 +103,2 @@ /* | ||
export default apache; | ||
export { apache as default }; |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,2 +11,3 @@ Language: AppleScript | ||
function applescript(hljs) { | ||
const regex = hljs.regex; | ||
const STRING = hljs.inherit( | ||
@@ -167,5 +117,5 @@ hljs.QUOTE_STRING_MODE, { | ||
className: 'built_in', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
either(...BUILT_IN_PATTERNS), | ||
regex.either(...BUILT_IN_PATTERNS), | ||
/\b/ | ||
@@ -185,5 +135,5 @@ ) | ||
className: 'keyword', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
either(...KEYWORD_PATTERNS), | ||
regex.either(...KEYWORD_PATTERNS), | ||
/\b/ | ||
@@ -206,2 +156,2 @@ ) | ||
export default applescript; | ||
export { applescript as default }; |
@@ -165,2 +165,2 @@ /* | ||
export default arcade; | ||
export { arcade as default }; |
@@ -1,42 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -50,2 +9,3 @@ Language: C++ | ||
function cPlusPlus(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -66,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -144,7 +104,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -173,3 +133,2 @@ // https://en.cppreference.com/w/cpp/keyword | ||
'concept', | ||
'const', | ||
'const_cast|10', | ||
@@ -218,5 +177,3 @@ 'consteval', | ||
'return', | ||
'signed', | ||
'sizeof', | ||
'static', | ||
'static_assert', | ||
@@ -239,3 +196,2 @@ 'static_cast|10', | ||
'union', | ||
'unsigned', | ||
'using', | ||
@@ -246,3 +202,3 @@ 'virtual', | ||
'xor', | ||
'xor_eq,' | ||
'xor_eq' | ||
]; | ||
@@ -263,3 +219,7 @@ | ||
'void', | ||
'wchar_t' | ||
'wchar_t', | ||
'unsigned', | ||
'signed', | ||
'const', | ||
'static' | ||
]; | ||
@@ -456,3 +416,3 @@ | ||
}, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
@@ -462,5 +422,6 @@ /(?!decltype)/, | ||
/(?!for)/, | ||
/(?!switch)/, | ||
/(?!while)/, | ||
hljs.IDENT_RE, | ||
lookahead(/(<[^<>]+>|)\s*\(/)) | ||
regex.lookahead(/(<[^<>]+>|)\s*\(/)) | ||
}; | ||
@@ -1030,2 +991,2 @@ | ||
export default arduino; | ||
export { arduino as default }; |
@@ -131,2 +131,2 @@ /* | ||
export default armasm; | ||
export { armasm as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: AsciiDoc | ||
function asciidoc(hljs) { | ||
const regex = hljs.regex; | ||
const HORIZONTAL_RULE = { | ||
@@ -74,3 +50,3 @@ begin: '^\'{3,}[ \\t]*$', | ||
className: 'strong', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\*\*/, | ||
@@ -105,3 +81,3 @@ /((\*(?!\*)|\\[^\n]|[^*\n\\])+\n)+/, | ||
className: 'emphasis', | ||
begin: concat( | ||
begin: regex.concat( | ||
/__/, | ||
@@ -306,2 +282,2 @@ /((_(?!_)|\\[^\n]|[^_\n\\])+\n)+/, | ||
export default asciidoc; | ||
export { asciidoc as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: AspectJ | ||
function aspectj(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = [ | ||
@@ -189,3 +165,3 @@ "false", | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
returnBegin: true, | ||
@@ -206,3 +182,3 @@ contains: [ hljs.UNDERSCORE_TITLE_MODE ] | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
keywords: KEYWORDS.concat(SHORTKEYS), | ||
@@ -229,3 +205,3 @@ relevance: 0 | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
returnBegin: true, | ||
@@ -262,2 +238,2 @@ relevance: 0, | ||
export default aspectj; | ||
export { aspectj as default }; |
@@ -84,2 +84,2 @@ /* | ||
export default autohotkey; | ||
export { autohotkey as default }; |
@@ -182,2 +182,2 @@ /* | ||
export default autoit; | ||
export { autoit as default }; |
@@ -80,2 +80,2 @@ /* | ||
export default avrasm; | ||
export { avrasm as default }; |
@@ -73,2 +73,2 @@ /* | ||
export default awk; | ||
export { awk as default }; |
@@ -179,2 +179,2 @@ /* | ||
export default axapta; | ||
export { axapta as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: Bash | ||
function bash(hljs) { | ||
const regex = hljs.regex; | ||
const VAR = {}; | ||
@@ -52,3 +28,3 @@ const BRACED_VAR = { | ||
variants: [ | ||
{begin: concat(/\$[\w\d#@][\w\d_]*/, | ||
{begin: regex.concat(/\$[\w\d#@][\w\d_]*/, | ||
// negative look-ahead tries to avoid matching patterns that are not | ||
@@ -150,2 +126,230 @@ // Perl at all like $ident$, @ident@, etc. | ||
// to consume paths to prevent keyword matches inside them | ||
const PATH_MODE = { | ||
match: /(\/[a-z._-]+)+/ | ||
}; | ||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html | ||
const SHELL_BUILT_INS = [ | ||
"break", | ||
"cd", | ||
"continue", | ||
"eval", | ||
"exec", | ||
"exit", | ||
"export", | ||
"getopts", | ||
"hash", | ||
"pwd", | ||
"readonly", | ||
"return", | ||
"shift", | ||
"test", | ||
"times", | ||
"trap", | ||
"umask", | ||
"unset" | ||
]; | ||
const BASH_BUILT_INS = [ | ||
"alias", | ||
"bind", | ||
"builtin", | ||
"caller", | ||
"command", | ||
"declare", | ||
"echo", | ||
"enable", | ||
"help", | ||
"let", | ||
"local", | ||
"logout", | ||
"mapfile", | ||
"printf", | ||
"read", | ||
"readarray", | ||
"source", | ||
"type", | ||
"typeset", | ||
"ulimit", | ||
"unalias" | ||
]; | ||
const ZSH_BUILT_INS = [ | ||
"autoload", | ||
"bg", | ||
"bindkey", | ||
"bye", | ||
"cap", | ||
"chdir", | ||
"clone", | ||
"comparguments", | ||
"compcall", | ||
"compctl", | ||
"compdescribe", | ||
"compfiles", | ||
"compgroups", | ||
"compquote", | ||
"comptags", | ||
"comptry", | ||
"compvalues", | ||
"dirs", | ||
"disable", | ||
"disown", | ||
"echotc", | ||
"echoti", | ||
"emulate", | ||
"fc", | ||
"fg", | ||
"float", | ||
"functions", | ||
"getcap", | ||
"getln", | ||
"history", | ||
"integer", | ||
"jobs", | ||
"kill", | ||
"limit", | ||
"log", | ||
"noglob", | ||
"popd", | ||
"print", | ||
"pushd", | ||
"pushln", | ||
"rehash", | ||
"sched", | ||
"setcap", | ||
"setopt", | ||
"stat", | ||
"suspend", | ||
"ttyctl", | ||
"unfunction", | ||
"unhash", | ||
"unlimit", | ||
"unsetopt", | ||
"vared", | ||
"wait", | ||
"whence", | ||
"where", | ||
"which", | ||
"zcompile", | ||
"zformat", | ||
"zftp", | ||
"zle", | ||
"zmodload", | ||
"zparseopts", | ||
"zprof", | ||
"zpty", | ||
"zregexparse", | ||
"zsocket", | ||
"zstyle", | ||
"ztcp" | ||
]; | ||
const GNU_CORE_UTILS = [ | ||
"chcon", | ||
"chgrp", | ||
"chown", | ||
"chmod", | ||
"cp", | ||
"dd", | ||
"df", | ||
"dir", | ||
"dircolors", | ||
"ln", | ||
"ls", | ||
"mkdir", | ||
"mkfifo", | ||
"mknod", | ||
"mktemp", | ||
"mv", | ||
"realpath", | ||
"rm", | ||
"rmdir", | ||
"shred", | ||
"sync", | ||
"touch", | ||
"truncate", | ||
"vdir", | ||
"b2sum", | ||
"base32", | ||
"base64", | ||
"cat", | ||
"cksum", | ||
"comm", | ||
"csplit", | ||
"cut", | ||
"expand", | ||
"fmt", | ||
"fold", | ||
"head", | ||
"join", | ||
"md5sum", | ||
"nl", | ||
"numfmt", | ||
"od", | ||
"paste", | ||
"ptx", | ||
"pr", | ||
"sha1sum", | ||
"sha224sum", | ||
"sha256sum", | ||
"sha384sum", | ||
"sha512sum", | ||
"shuf", | ||
"sort", | ||
"split", | ||
"sum", | ||
"tac", | ||
"tail", | ||
"tr", | ||
"tsort", | ||
"unexpand", | ||
"uniq", | ||
"wc", | ||
"arch", | ||
"basename", | ||
"chroot", | ||
"date", | ||
"dirname", | ||
"du", | ||
"echo", | ||
"env", | ||
"expr", | ||
"factor", | ||
// "false", // keyword literal already | ||
"groups", | ||
"hostid", | ||
"id", | ||
"link", | ||
"logname", | ||
"nice", | ||
"nohup", | ||
"nproc", | ||
"pathchk", | ||
"pinky", | ||
"printenv", | ||
"printf", | ||
"pwd", | ||
"readlink", | ||
"runcon", | ||
"seq", | ||
"sleep", | ||
"stat", | ||
"stdbuf", | ||
"stty", | ||
"tee", | ||
"test", | ||
"timeout", | ||
// "true", // keyword literal already | ||
"tty", | ||
"uname", | ||
"unlink", | ||
"uptime", | ||
"users", | ||
"who", | ||
"whoami", | ||
"yes" | ||
]; | ||
return { | ||
@@ -158,19 +362,11 @@ name: 'Bash', | ||
literal: LITERALS, | ||
built_in: | ||
// Shell built-ins | ||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html | ||
'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' + | ||
'trap umask unset ' + | ||
// Bash built-ins | ||
'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' + | ||
'read readarray source type typeset ulimit unalias ' + | ||
built_in:[ | ||
...SHELL_BUILT_INS, | ||
...BASH_BUILT_INS, | ||
// Shell modifiers | ||
'set shopt ' + | ||
// Zsh built-ins | ||
'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' + | ||
'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' + | ||
'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' + | ||
'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' + | ||
'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' + | ||
'zpty zregexparse zsocket zstyle ztcp' | ||
"set", | ||
"shopt", | ||
...ZSH_BUILT_INS, | ||
...GNU_CORE_UTILS | ||
] | ||
}, | ||
@@ -184,2 +380,3 @@ contains: [ | ||
HERE_DOC, | ||
PATH_MODE, | ||
QUOTE_STRING, | ||
@@ -193,2 +390,2 @@ ESCAPED_QUOTE, | ||
export default bash; | ||
export { bash as default }; |
@@ -233,2 +233,2 @@ /* | ||
export default basic; | ||
export { basic as default }; |
@@ -38,2 +38,2 @@ /* | ||
export default bnf; | ||
export { bnf as default }; |
@@ -46,2 +46,2 @@ /* | ||
export default brainfuck; | ||
export { brainfuck as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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 optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -42,2 +9,3 @@ Language: C | ||
function c(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -58,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -141,7 +109,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -153,3 +121,2 @@ const C_KEYWORDS = [ | ||
"case", | ||
"const", | ||
"continue", | ||
@@ -170,3 +137,2 @@ "default", | ||
"sizeof", | ||
"static", | ||
"struct", | ||
@@ -211,2 +177,5 @@ "switch", | ||
"_Decimal128", | ||
// modifiers | ||
"const", | ||
"static", | ||
// aliases | ||
@@ -377,2 +346,2 @@ "complex", | ||
export default c; | ||
export { c as default }; |
@@ -104,2 +104,2 @@ /* | ||
export default cal; | ||
export { cal as default }; |
@@ -103,2 +103,2 @@ /* | ||
export default capnproto; | ||
export { capnproto as default }; |
@@ -141,2 +141,2 @@ /* | ||
export default ceylon; | ||
export { ceylon as default }; |
@@ -68,2 +68,2 @@ /* | ||
export default clean; | ||
export { clean as default }; |
@@ -27,2 +27,2 @@ /* | ||
export default clojureRepl; | ||
export { clojureRepl as default }; |
@@ -162,2 +162,2 @@ /* | ||
export default clojure; | ||
export { clojure as default }; |
@@ -64,2 +64,2 @@ /* | ||
export default cmake; | ||
export { cmake as default }; |
@@ -53,40 +53,57 @@ const KEYWORDS = [ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -345,2 +362,2 @@ "InternalError", | ||
export default coffeescript; | ||
export { coffeescript as default }; |
@@ -446,2 +446,2 @@ /* | ||
export default coq; | ||
export { coq as default }; |
@@ -138,2 +138,2 @@ /* | ||
export default cos; | ||
export { cos as default }; |
@@ -1,42 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -50,2 +9,3 @@ Language: C++ | ||
function cpp(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -66,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -144,7 +104,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -173,3 +133,2 @@ // https://en.cppreference.com/w/cpp/keyword | ||
'concept', | ||
'const', | ||
'const_cast|10', | ||
@@ -218,5 +177,3 @@ 'consteval', | ||
'return', | ||
'signed', | ||
'sizeof', | ||
'static', | ||
'static_assert', | ||
@@ -239,3 +196,2 @@ 'static_cast|10', | ||
'union', | ||
'unsigned', | ||
'using', | ||
@@ -246,3 +202,3 @@ 'virtual', | ||
'xor', | ||
'xor_eq,' | ||
'xor_eq' | ||
]; | ||
@@ -263,3 +219,7 @@ | ||
'void', | ||
'wchar_t' | ||
'wchar_t', | ||
'unsigned', | ||
'signed', | ||
'const', | ||
'static' | ||
]; | ||
@@ -456,3 +416,3 @@ | ||
}, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
@@ -462,5 +422,6 @@ /(?!decltype)/, | ||
/(?!for)/, | ||
/(?!switch)/, | ||
/(?!while)/, | ||
hljs.IDENT_RE, | ||
lookahead(/(<[^<>]+>|)\s*\(/)) | ||
regex.lookahead(/(<[^<>]+>|)\s*\(/)) | ||
}; | ||
@@ -638,2 +599,2 @@ | ||
export default cpp; | ||
export { cpp as default }; |
@@ -102,2 +102,2 @@ /* | ||
export default crmsh; | ||
export { crmsh as default }; |
@@ -334,2 +334,2 @@ /* | ||
export default crystal; | ||
export { crystal as default }; |
@@ -399,3 +399,3 @@ /* | ||
className: 'function', | ||
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', | ||
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', | ||
returnBegin: true, | ||
@@ -412,3 +412,3 @@ end: /\s*[{;=]/, | ||
{ | ||
begin: hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', | ||
begin: hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', | ||
returnBegin: true, | ||
@@ -422,2 +422,5 @@ contains: [ | ||
{ | ||
match: /\(\)/ | ||
}, | ||
{ | ||
className: 'params', | ||
@@ -445,2 +448,2 @@ begin: /\(/, | ||
export default csharp; | ||
export { csharp as default }; |
@@ -57,2 +57,2 @@ /* | ||
export default csp; | ||
export { csp as default }; |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -462,35 +572,2 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -504,7 +581,4 @@ Language: CSS | ||
function css(hljs) { | ||
const regex = hljs.regex; | ||
const modes = MODES(hljs); | ||
const FUNCTION_DISPATCH = { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}; | ||
const VENDOR_PREFIX = { | ||
@@ -534,3 +608,3 @@ begin: /-(webkit|moz|ms|o)-(?=[a-z])/ | ||
contains: [ | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
modes.BLOCK_COMMENT, | ||
VENDOR_PREFIX, | ||
@@ -558,3 +632,3 @@ // to recognize keyframe 40% etc which are outside the scope of our | ||
{ | ||
begin: '::(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
} | ||
@@ -576,5 +650,6 @@ ] | ||
{ | ||
begin: ':', | ||
end: '[;}]', | ||
begin: /:/, | ||
end: /[;}{]/, | ||
contains: [ | ||
modes.BLOCK_COMMENT, | ||
modes.HEXCOLOR, | ||
@@ -605,7 +680,7 @@ modes.IMPORTANT, | ||
}, | ||
FUNCTION_DISPATCH | ||
modes.FUNCTION_DISPATCH | ||
] | ||
}, | ||
{ | ||
begin: lookahead(/@/), | ||
begin: regex.lookahead(/@/), | ||
end: '[{;]', | ||
@@ -648,2 +723,2 @@ relevance: 0, | ||
export default css; | ||
export { css as default }; |
@@ -271,2 +271,2 @@ /* | ||
export default d; | ||
export { d as default }; |
@@ -262,2 +262,2 @@ /* | ||
export default dart; | ||
export { dart as default }; |
@@ -239,2 +239,2 @@ /* | ||
export default delphi; | ||
export { delphi as default }; |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -53,2 +11,3 @@ Language: Diff | ||
function diff(hljs) { | ||
const regex = hljs.regex; | ||
return { | ||
@@ -61,3 +20,3 @@ name: 'Diff', | ||
relevance: 10, | ||
match: either( | ||
match: regex.either( | ||
/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, | ||
@@ -72,3 +31,3 @@ /^\*\*\* +\d+,\d+ +\*\*\*\*$/, | ||
{ | ||
begin: either( | ||
begin: regex.either( | ||
/Index: /, | ||
@@ -108,2 +67,2 @@ /^index/, | ||
export default diff; | ||
export { diff as default }; |
@@ -77,2 +77,2 @@ /* | ||
export default django; | ||
export { django as default }; |
@@ -82,2 +82,2 @@ /* | ||
export default dns; | ||
export { dns as default }; |
@@ -44,2 +44,2 @@ /* | ||
export default dockerfile; | ||
export { dockerfile as default }; |
@@ -170,2 +170,2 @@ /* | ||
export default dos; | ||
export { dos as default }; |
@@ -66,2 +66,2 @@ /* | ||
export default dsconfig; | ||
export { dsconfig as default }; |
@@ -168,2 +168,2 @@ /* | ||
export default dts; | ||
export { dts as default }; |
@@ -45,2 +45,2 @@ /* | ||
export default dust; | ||
export { dust as default }; |
@@ -53,2 +53,2 @@ /* | ||
export default ebnf; | ||
export { ebnf as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: Elixir | ||
function elixir(hljs) { | ||
const regex = hljs.regex; | ||
const ELIXIR_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_.]*(!|\\?)?'; | ||
@@ -142,3 +118,3 @@ const ELIXIR_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; | ||
scope: "char.escape", | ||
begin: concat(/\\/, end), | ||
begin: regex.concat(/\\/, end), | ||
relevance: 0 | ||
@@ -178,3 +154,3 @@ }; | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
end: regex.concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ | ||
@@ -192,3 +168,3 @@ escapeSigilEnd(x.end), | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
end: regex.concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ escapeSigilEnd(x.end) ] | ||
@@ -308,2 +284,2 @@ }) | ||
export default elixir; | ||
export { elixir as default }; |
@@ -150,2 +150,2 @@ /* | ||
export default elm; | ||
export { elm as default }; |
@@ -29,2 +29,2 @@ /* | ||
export default erb; | ||
export { erb as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Erlang REPL | ||
function erlangRepl(hljs) { | ||
const regex = hljs.regex; | ||
return { | ||
@@ -60,3 +36,3 @@ name: 'Erlang REPL', | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/\?(::)?/, | ||
@@ -88,2 +64,2 @@ /([A-Z]\w*)/, // at least one identifier | ||
export default erlangRepl; | ||
export { erlangRepl as default }; |
@@ -199,2 +199,2 @@ /* | ||
export default erlang; | ||
export { erlang as default }; |
@@ -544,2 +544,2 @@ /* | ||
export default excel; | ||
export { excel as default }; |
@@ -37,2 +37,2 @@ /* | ||
export default fix; | ||
export { fix as default }; |
@@ -77,2 +77,2 @@ /* | ||
export default flix; | ||
export { flix as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Fortran | ||
function fortran(hljs) { | ||
const regex = hljs.regex; | ||
const PARAMS = { | ||
@@ -64,9 +40,9 @@ className: 'params', | ||
{ | ||
begin: concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
} | ||
@@ -613,2 +589,2 @@ ], | ||
export default fortran; | ||
export { fortran as default }; |
@@ -0,5 +1,69 @@ | ||
/** | ||
* @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; | ||
} | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* Any of the passed expresssions may match | ||
* | ||
* Creates a huge this | this | that | that match | ||
* @param {(RegExp | string)[] } args | ||
* @returns {string} | ||
*/ | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
Language: F# | ||
Author: Jonas Follesø <jonas@follesoe.no> | ||
Contributors: Troy Kershaw <hello@troykershaw.com>, Henrik Feldt <henrik@haf.se> | ||
Contributors: Troy Kershaw <hello@troykershaw.com>, Henrik Feldt <henrik@haf.se>, Melvyn Laïly <melvyn.laily@gmail.com> | ||
Website: https://docs.microsoft.com/en-us/dotnet/fsharp/ | ||
@@ -11,12 +75,2 @@ Category: functional | ||
function fsharp(hljs) { | ||
const TYPEPARAM = { | ||
begin: '<', | ||
end: '>', | ||
contains: [ | ||
hljs.inherit(hljs.TITLE_MODE, { | ||
begin: /'[a-zA-Z0-9_]+/ | ||
}) | ||
] | ||
}; | ||
const KEYWORDS = [ | ||
@@ -41,4 +95,5 @@ "abstract", | ||
"extern", | ||
"false", | ||
// "false", // literal | ||
"finally", | ||
"fixed", | ||
"for", | ||
@@ -62,3 +117,4 @@ "fun", | ||
"new", | ||
"null", | ||
// "not", // built_in | ||
// "null", // literal | ||
"of", | ||
@@ -72,3 +128,2 @@ "open", | ||
"return", | ||
"sig", | ||
"static", | ||
@@ -78,3 +133,3 @@ "struct", | ||
"to", | ||
"true", | ||
// "true", // literal | ||
"try", | ||
@@ -92,61 +147,362 @@ "type", | ||
return { | ||
name: 'F#', | ||
aliases: ['fs'], | ||
keywords: KEYWORDS, | ||
illegal: /\/\*/, | ||
const BANG_KEYWORD_MODE = { | ||
// monad builder keywords (matches before non-bang keywords) | ||
scope: 'keyword', | ||
match: /\b(yield|return|let|do|match|use)!/ | ||
}; | ||
const PREPROCESSOR_KEYWORDS = [ | ||
"if", | ||
"else", | ||
"endif", | ||
"line", | ||
"nowarn", | ||
"light", | ||
"r", | ||
"i", | ||
"I", | ||
"load", | ||
"time", | ||
"help", | ||
"quit" | ||
]; | ||
const LITERALS = [ | ||
"true", | ||
"false", | ||
"null", | ||
"Some", | ||
"None", | ||
"Ok", | ||
"Error", | ||
"infinity", | ||
"infinityf", | ||
"nan", | ||
"nanf" | ||
]; | ||
const SPECIAL_IDENTIFIERS = [ | ||
"__LINE__", | ||
"__SOURCE_DIRECTORY__", | ||
"__SOURCE_FILE__" | ||
]; | ||
const TYPES = [ | ||
// basic types | ||
"bool", | ||
"byte", | ||
"sbyte", | ||
"int8", | ||
"int16", | ||
"int32", | ||
"uint8", | ||
"uint16", | ||
"uint32", | ||
"int", | ||
"uint", | ||
"int64", | ||
"uint64", | ||
"nativeint", | ||
"unativeint", | ||
"decimal", | ||
"float", | ||
"double", | ||
"float32", | ||
"single", | ||
"char", | ||
"string", | ||
"unit", | ||
"bigint", | ||
// other native types or lowercase aliases | ||
"option", | ||
"voption", | ||
"list", | ||
"array", | ||
"seq", | ||
"byref", | ||
"exn", | ||
"inref", | ||
"nativeptr", | ||
"obj", | ||
"outref", | ||
"voidptr" | ||
]; | ||
const BUILTINS = [ | ||
// Somewhat arbitrary list of builtin functions and values. | ||
// Most of them are declared in Microsoft.FSharp.Core | ||
// I tried to stay relevant by adding only the most idiomatic | ||
// and most used symbols that are not already declared as types. | ||
"not", | ||
"ref", | ||
"raise", | ||
"reraise", | ||
"dict", | ||
"readOnlyDict", | ||
"set", | ||
"enum", | ||
"sizeof", | ||
"typeof", | ||
"typedefof", | ||
"nameof", | ||
"nullArg", | ||
"invalidArg", | ||
"invalidOp", | ||
"id", | ||
"fst", | ||
"snd", | ||
"ignore", | ||
"lock", | ||
"using", | ||
"box", | ||
"unbox", | ||
"tryUnbox", | ||
"printf", | ||
"printfn", | ||
"sprintf", | ||
"eprintf", | ||
"eprintfn", | ||
"fprintf", | ||
"fprintfn", | ||
"failwith", | ||
"failwithf" | ||
]; | ||
const ALL_KEYWORDS = { | ||
type: TYPES, | ||
keyword: KEYWORDS, | ||
literal: LITERALS, | ||
built_in: BUILTINS, | ||
'variable.constant': SPECIAL_IDENTIFIERS | ||
}; | ||
// (* potentially multi-line Meta Language style comment *) | ||
const ML_COMMENT = | ||
hljs.COMMENT(/\(\*(?!\))/, /\*\)/, { | ||
contains: ["self"] | ||
}); | ||
// Either a multi-line (* Meta Language style comment *) or a single line // C style comment. | ||
const COMMENT = { | ||
variants: [ | ||
ML_COMMENT, | ||
hljs.C_LINE_COMMENT_MODE, | ||
] | ||
}; | ||
// 'a or ^a | ||
const GENERIC_TYPE_SYMBOL = { | ||
match: concat(/('|\^)/, hljs.UNDERSCORE_IDENT_RE), | ||
scope: 'symbol', | ||
relevance: 0 | ||
}; | ||
const COMPUTATION_EXPRESSION = { | ||
// computation expressions: | ||
scope: 'computation-expression', | ||
match: /\b[_a-z]\w*(?=\s*\{)/ | ||
}; | ||
const PREPROCESSOR = { | ||
// preprocessor directives and fsi commands: | ||
begin: [ | ||
/^\s*/, | ||
concat(/#/, either(...PREPROCESSOR_KEYWORDS)), | ||
/\b/ | ||
], | ||
beginScope: { 2: 'meta' }, | ||
end: lookahead(/\s|$/) | ||
}; | ||
// TODO: this definition is missing support for type suffixes and octal notation. | ||
// BUG: range operator without any space is wrongly interpreted as a single number (e.g. 1..10 ) | ||
const NUMBER = { | ||
variants: [ | ||
hljs.BINARY_NUMBER_MODE, | ||
hljs.C_NUMBER_MODE | ||
] | ||
}; | ||
// All the following string definitions are potentially multi-line. | ||
// BUG: these definitions are missing support for byte strings (suffixed with B) | ||
// "..." | ||
const QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /"/, | ||
end: /"/, | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE | ||
] | ||
}; | ||
// @"..." | ||
const VERBATIM_STRING = { | ||
scope: 'string', | ||
begin: /@"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
// monad builder keywords (matches before non-bang kws) | ||
className: 'keyword', | ||
begin: /\b(yield|return|let|do)!/ | ||
match: /""/ // escaped " | ||
}, | ||
hljs.BACKSLASH_ESCAPE | ||
] | ||
}; | ||
// """...""" | ||
const TRIPLE_QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /"""/, | ||
end: /"""/, | ||
relevance: 2 | ||
}; | ||
const SUBST = { | ||
scope: 'subst', | ||
begin: /\{/, | ||
end: /\}/, | ||
keywords: ALL_KEYWORDS | ||
}; | ||
// $"...{1+1}..." | ||
const INTERPOLATED_STRING = { | ||
scope: 'string', | ||
begin: /\$"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
className: 'string', | ||
begin: '@"', | ||
end: '"', | ||
contains: [ | ||
{ | ||
begin: '""' | ||
} | ||
] | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
className: 'string', | ||
begin: '"""', | ||
end: '"""' | ||
match: /\}\}/ // escaped } | ||
}, | ||
hljs.COMMENT('\\(\\*(\\s)', '\\*\\)', { | ||
contains: ["self"] | ||
}), | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
}; | ||
// $@"...{1+1}..." | ||
const INTERPOLATED_VERBATIM_STRING = { | ||
scope: 'string', | ||
begin: /(\$@|@\$)"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
className: 'class', | ||
beginKeywords: 'type', | ||
end: '\\(|=|$', | ||
excludeEnd: true, | ||
contains: [ | ||
hljs.UNDERSCORE_TITLE_MODE, | ||
TYPEPARAM | ||
] | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
className: 'meta', | ||
begin: '\\[<', | ||
end: '>\\]', | ||
relevance: 10 | ||
match: /\}\}/ // escaped } | ||
}, | ||
{ | ||
className: 'symbol', | ||
begin: '\\B(\'[A-Za-z])\\b', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
match: /""/ | ||
}, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.inherit(hljs.QUOTE_STRING_MODE, { | ||
illegal: null | ||
}), | ||
hljs.C_NUMBER_MODE | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
}; | ||
// $"""...{1+1}...""" | ||
const INTERPOLATED_TRIPLE_QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /\$"""/, | ||
end: /"""/, | ||
contains: [ | ||
{ | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
match: /\}\}/ // escaped } | ||
}, | ||
SUBST | ||
], | ||
relevance: 2 | ||
}; | ||
// '.' | ||
const CHAR_LITERAL = { | ||
scope: 'string', | ||
match: concat( | ||
/'/, | ||
either( | ||
/[^\\']/, // either a single non escaped char... | ||
/\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8})/ // ...or an escape sequence | ||
), | ||
/'/ | ||
) | ||
}; | ||
// F# allows a lot of things inside string placeholders. | ||
// Things that don't currently seem allowed by the compiler: types definition, attributes usage. | ||
// (Strictly speaking, some of the followings are only allowed inside triple quoted interpolated strings...) | ||
SUBST.contains = [ | ||
INTERPOLATED_VERBATIM_STRING, | ||
INTERPOLATED_STRING, | ||
VERBATIM_STRING, | ||
QUOTED_STRING, | ||
CHAR_LITERAL, | ||
BANG_KEYWORD_MODE, | ||
COMMENT, | ||
COMPUTATION_EXPRESSION, | ||
PREPROCESSOR, | ||
NUMBER, | ||
GENERIC_TYPE_SYMBOL | ||
]; | ||
const STRING = { | ||
variants: [ | ||
INTERPOLATED_TRIPLE_QUOTED_STRING, | ||
INTERPOLATED_VERBATIM_STRING, | ||
INTERPOLATED_STRING, | ||
TRIPLE_QUOTED_STRING, | ||
VERBATIM_STRING, | ||
QUOTED_STRING, | ||
CHAR_LITERAL | ||
] | ||
}; | ||
return { | ||
name: 'F#', | ||
aliases: [ | ||
'fs', | ||
'f#' | ||
], | ||
keywords: ALL_KEYWORDS, | ||
illegal: /\/\*/, | ||
classNameAliases: { | ||
'computation-expression': 'keyword' | ||
}, | ||
contains: [ | ||
BANG_KEYWORD_MODE, | ||
STRING, | ||
COMMENT, | ||
{ | ||
// type MyType<'a> = ... | ||
begin: [ | ||
/type/, | ||
/\s+/, | ||
hljs.UNDERSCORE_IDENT_RE | ||
], | ||
beginScope: { | ||
1: 'keyword', | ||
3: 'title.class' | ||
}, | ||
end: lookahead(/\(|=|$/), | ||
contains: [ | ||
GENERIC_TYPE_SYMBOL | ||
] | ||
}, | ||
{ | ||
// [<Attributes("")>] | ||
scope: 'meta', | ||
begin: /^\s*\[</, | ||
excludeBegin: true, | ||
end: lookahead(/>\]/), | ||
relevance: 2, | ||
contains: [ | ||
{ | ||
scope: 'string', | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
NUMBER | ||
] | ||
}, | ||
COMPUTATION_EXPRESSION, | ||
PREPROCESSOR, | ||
NUMBER, | ||
GENERIC_TYPE_SYMBOL | ||
] | ||
}; | ||
} | ||
export default fsharp; | ||
export { fsharp as default }; |
@@ -1,36 +0,13 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
/* | ||
Language: GAMS | ||
Author: Stefan Bechert <stefan.bechert@gmx.net> | ||
Contributors: Oleg Efimov <efimovov@gmail.com>, Mikko Kouhia <mikko.kouhia@iki.fi> | ||
Description: The General Algebraic Modeling System language | ||
Website: https://www.gams.com | ||
Category: scientific | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function anyNumberOfTimes(re) { | ||
return concat('(?:', re, ')*'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/** @type LanguageFn */ | ||
function gams(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
@@ -119,6 +96,6 @@ keyword: | ||
// one comment word, then possibly more | ||
begin: concat( | ||
begin: regex.concat( | ||
COMMENT_WORD, | ||
// [ ] because \s would be too broad (matching newlines) | ||
anyNumberOfTimes(concat(/[ ]+/, COMMENT_WORD)) | ||
regex.anyNumberOfTimes(regex.concat(/[ ]+/, COMMENT_WORD)) | ||
), | ||
@@ -209,2 +186,2 @@ relevance: 0 | ||
export default gams; | ||
export { gams as default }; |
@@ -316,2 +316,2 @@ /* | ||
export default gauss; | ||
export { gauss as default }; |
@@ -88,2 +88,2 @@ /* | ||
export default gcode; | ||
export { gcode as default }; |
@@ -49,2 +49,2 @@ /* | ||
export default gherkin; | ||
export { gherkin as default }; |
@@ -128,2 +128,2 @@ /* | ||
export default glsl; | ||
export { glsl as default }; |
@@ -34,28 +34,3 @@ /* | ||
]; | ||
const KWS = [ | ||
"break", | ||
"default", | ||
"func", | ||
"interface", | ||
"select", | ||
"case", | ||
"map", | ||
"struct", | ||
"chan", | ||
"else", | ||
"goto", | ||
"package", | ||
"switch", | ||
"const", | ||
"fallthrough", | ||
"if", | ||
"range", | ||
"type", | ||
"continue", | ||
"for", | ||
"import", | ||
"return", | ||
"var", | ||
"go", | ||
"defer", | ||
const TYPES = [ | ||
"bool", | ||
@@ -65,2 +40,3 @@ "byte", | ||
"complex128", | ||
"error", | ||
"float32", | ||
@@ -82,4 +58,32 @@ "float64", | ||
]; | ||
const KWS = [ | ||
"break", | ||
"case", | ||
"chan", | ||
"const", | ||
"continue", | ||
"default", | ||
"defer", | ||
"else", | ||
"fallthrough", | ||
"for", | ||
"func", | ||
"go", | ||
"goto", | ||
"if", | ||
"import", | ||
"interface", | ||
"map", | ||
"package", | ||
"range", | ||
"return", | ||
"select", | ||
"struct", | ||
"switch", | ||
"type", | ||
"var", | ||
]; | ||
const KEYWORDS = { | ||
keyword: KWS, | ||
type: TYPES, | ||
literal: LITERALS, | ||
@@ -131,2 +135,3 @@ built_in: BUILT_INS | ||
end: /\)/, | ||
endsParent: true, | ||
keywords: KEYWORDS, | ||
@@ -141,2 +146,2 @@ illegal: /["']/ | ||
export default go; | ||
export { go as default }; |
@@ -80,2 +80,2 @@ /* | ||
export default golo; | ||
export { golo as default }; |
@@ -189,2 +189,2 @@ /* | ||
export default gradle; | ||
export { gradle as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -47,2 +14,3 @@ Language: Groovy | ||
function groovy(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = '[A-Za-z0-9_$]+'; | ||
@@ -165,3 +133,3 @@ const COMMENT = variants([ | ||
className: 'symbol', | ||
begin: '^[ \t]*' + lookahead(IDENT_RE + ':'), | ||
begin: '^[ \t]*' + regex.lookahead(IDENT_RE + ':'), | ||
excludeBegin: true, | ||
@@ -176,2 +144,2 @@ end: IDENT_RE + ':', | ||
export default groovy; | ||
export { groovy as default }; |
@@ -115,2 +115,2 @@ /* | ||
export default haml; | ||
export { haml as default }; |
@@ -1,68 +0,1 @@ | ||
/** | ||
* @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 anyNumberOfTimes(re) { | ||
return concat('(?:', re, ')*'); | ||
} | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -78,2 +11,3 @@ Language: Handlebars | ||
function handlebars(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_INS = { | ||
@@ -133,3 +67,3 @@ $pattern: /[\w.\/]+/, | ||
const PATH_DELIMITER_REGEX = /(\.|\/)/; | ||
const ANY_ID = either( | ||
const ANY_ID = regex.either( | ||
DOUBLE_QUOTED_ID_REGEX, | ||
@@ -141,6 +75,6 @@ SINGLE_QUOTED_ID_REGEX, | ||
const IDENTIFIER_REGEX = concat( | ||
optional(/\.|\.\/|\//), // relative or absolute path | ||
const IDENTIFIER_REGEX = regex.concat( | ||
regex.optional(/\.|\.\/|\//), // relative or absolute path | ||
ANY_ID, | ||
anyNumberOfTimes(concat( | ||
regex.anyNumberOfTimes(regex.concat( | ||
PATH_DELIMITER_REGEX, | ||
@@ -152,3 +86,3 @@ ANY_ID | ||
// identifier followed by a equal-sign (without the equal sign) | ||
const HASH_PARAM_REGEX = concat( | ||
const HASH_PARAM_REGEX = regex.concat( | ||
'(', | ||
@@ -343,2 +277,2 @@ BRACKET_QUOTED_ID_REGEX, '|', | ||
export default handlebars; | ||
export { handlebars as default }; |
@@ -209,2 +209,2 @@ /* | ||
export default haskell; | ||
export { haskell as default }; |
@@ -157,2 +157,2 @@ /* | ||
export default haxe; | ||
export { haxe as default }; |
@@ -65,2 +65,2 @@ /* | ||
export default hsp; | ||
export { hsp as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: HTTP | ||
function http(hljs) { | ||
const regex = hljs.regex; | ||
const VERSION = 'HTTP/(2|1\\.[01])'; | ||
@@ -40,3 +16,3 @@ const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/; | ||
className: 'attribute', | ||
begin: concat('^', HEADER_NAME, '(?=\\:\\s)'), | ||
begin: regex.concat('^', HEADER_NAME, '(?=\\:\\s)'), | ||
starts: { | ||
@@ -123,2 +99,2 @@ contains: [ | ||
export default http; | ||
export { http as default }; |
@@ -141,2 +141,2 @@ /* | ||
export default hy; | ||
export { hy as default }; |
@@ -70,2 +70,2 @@ /* | ||
export default inform7; | ||
export { inform7 as default }; |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -69,2 +10,3 @@ Language: TOML, also INI | ||
function ini(hljs) { | ||
const regex = hljs.regex; | ||
const NUMBERS = { | ||
@@ -149,8 +91,8 @@ className: 'number', | ||
const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/; | ||
const ANY_KEY = either( | ||
const ANY_KEY = regex.either( | ||
BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE | ||
); | ||
const DOTTED_KEY = concat( | ||
const DOTTED_KEY = regex.concat( | ||
ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*', | ||
lookahead(/\s*=\s*[^#\s]/) | ||
regex.lookahead(/\s*=\s*[^#\s]/) | ||
); | ||
@@ -189,2 +131,2 @@ | ||
export default ini; | ||
export { ini as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: IRPF90 | ||
function irpf90(hljs) { | ||
const regex = hljs.regex; | ||
const PARAMS = { | ||
@@ -50,9 +26,9 @@ className: 'params', | ||
{ | ||
begin: concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
} | ||
@@ -143,2 +119,2 @@ ], | ||
export default irpf90; | ||
export { irpf90 as default }; |
@@ -64,2 +64,3 @@ // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10 | ||
function java(hljs) { | ||
hljs.regex; | ||
const JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; | ||
@@ -194,2 +195,8 @@ const GENERIC_IDENT_RE = JAVA_IDENT_RE + | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
begin: /"""/, | ||
end: /"""/, | ||
className: "string", | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
}, | ||
hljs.APOS_STRING_MODE, | ||
@@ -279,2 +286,2 @@ hljs.QUOTE_STRING_MODE, | ||
export default java; | ||
export { java as default }; |
@@ -54,40 +54,57 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -142,35 +159,2 @@ "InternalError", | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -185,2 +169,3 @@ Language: JavaScript | ||
function javascript(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -204,2 +189,4 @@ * Takes a string like "<Booger" and checks to see | ||
}; | ||
// to avoid some special cases inside isTrulyOpeningTag | ||
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; | ||
const XML_TAG = { | ||
@@ -215,11 +202,16 @@ begin: /<[A-Za-z0-9\\._:-]+/, | ||
const nextChar = match.input[afterMatchIndex]; | ||
// nested type? | ||
// HTML should not include another raw `<` inside a tag | ||
// But a type might: `<Array<Array<number>>`, etc. | ||
if (nextChar === "<") { | ||
if ( | ||
// HTML should not include another raw `<` inside a tag | ||
// nested type? | ||
// `<Array<Array<number>>`, etc. | ||
nextChar === "<" || | ||
// the , gives away that this is not HTML | ||
// `<T, A extends keyof T, V>` | ||
nextChar === ",") { | ||
response.ignoreMatch(); | ||
return; | ||
} | ||
// <something> | ||
// This is now either a tag or a type. | ||
// `<something>` | ||
// Quite possibly a tag, lets look for a matching closing tag... | ||
if (nextChar === ">") { | ||
@@ -232,2 +224,18 @@ // if we cannot find a matching closing tag, then we | ||
} | ||
// `<blah />` (self-closing) | ||
// handled by simpleSelfClosing rule | ||
// `<From extends string>` | ||
// technically this could be HTML, but it smells like a type | ||
let m; | ||
const afterMatch = match.input.substr(afterMatchIndex); | ||
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276 | ||
if ((m = afterMatch.match(/^\s+extends\s+/))) { | ||
if (m.index === 0) { | ||
response.ignoreMatch(); | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} | ||
} | ||
} | ||
@@ -368,3 +376,5 @@ }; | ||
NUMBER, | ||
hljs.REGEXP_MODE | ||
// This is intentional: | ||
// See https://github.com/highlightjs/highlight.js/issues/3288 | ||
// hljs.REGEXP_MODE | ||
]; | ||
@@ -405,2 +415,3 @@ SUBST.contains = SUBST_INTERNALS | ||
variants: [ | ||
// class Car extends vehicle | ||
{ | ||
@@ -410,20 +421,28 @@ match: [ | ||
/\s+/, | ||
IDENT_RE$1 | ||
IDENT_RE$1, | ||
/\s+/, | ||
/extends/, | ||
/\s+/, | ||
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class" | ||
3: "title.class", | ||
5: "keyword", | ||
7: "title.class.inherited" | ||
} | ||
}, | ||
// class Car | ||
{ | ||
match: [ | ||
/extends/, | ||
/class/, | ||
/\s+/, | ||
concat(IDENT_RE$1, "(", concat(/\./, IDENT_RE$1), ")*") | ||
IDENT_RE$1 | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class.inherited" | ||
3: "title.class" | ||
} | ||
} | ||
}, | ||
] | ||
@@ -434,3 +453,13 @@ }; | ||
relevance: 0, | ||
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/, | ||
match: | ||
regex.either( | ||
// Hard coded exceptions | ||
/\bJSON/, | ||
// Float32Array | ||
/\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/, | ||
// CSSFactory | ||
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+/, | ||
// BLAH | ||
// this will be flagged as a UPPER_CASE_CONSTANT instead | ||
), | ||
className: "title.class", | ||
@@ -487,7 +516,7 @@ keywords: { | ||
function noneOf(list) { | ||
return concat("(?!", list.join("|"), ")"); | ||
return regex.concat("(?!", list.join("|"), ")"); | ||
} | ||
const FUNCTION_CALL = { | ||
match: concat( | ||
match: regex.concat( | ||
/\b/, | ||
@@ -498,3 +527,3 @@ noneOf([ | ||
]), | ||
IDENT_RE$1, lookahead(/\(/)), | ||
IDENT_RE$1, regex.lookahead(/\(/)), | ||
className: "title.function", | ||
@@ -505,4 +534,4 @@ relevance: 0 | ||
const PROPERTY_ACCESS = { | ||
begin: concat(/\./, lookahead( | ||
concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
begin: regex.concat(/\./, regex.lookahead( | ||
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
)), | ||
@@ -548,3 +577,3 @@ end: IDENT_RE$1, | ||
/=\s*/, | ||
lookahead(FUNC_LEAD_IN_RE) | ||
regex.lookahead(FUNC_LEAD_IN_RE) | ||
], | ||
@@ -565,3 +594,3 @@ className: { | ||
// this will be extended by TypeScript | ||
exports: { PARAMS_CONTAINS }, | ||
exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, | ||
illegal: /#(?![$_A-z])/, | ||
@@ -585,3 +614,3 @@ contains: [ | ||
className: 'attr', | ||
begin: IDENT_RE$1 + lookahead(':'), | ||
begin: IDENT_RE$1 + regex.lookahead(':'), | ||
relevance: 0 | ||
@@ -641,2 +670,3 @@ }, | ||
{ begin: FRAGMENT.begin, end: FRAGMENT.end }, | ||
{ match: XML_SELF_CLOSING }, | ||
{ | ||
@@ -716,2 +746,2 @@ begin: XML_TAG.begin, | ||
export default javascript; | ||
export { javascript as default }; |
@@ -63,2 +63,2 @@ /* | ||
export default jbossCli; | ||
export { jbossCli as default }; |
@@ -48,2 +48,2 @@ /* | ||
export default json; | ||
export { json as default }; |
@@ -50,2 +50,2 @@ /* | ||
export default juliaRepl; | ||
export { juliaRepl as default }; |
@@ -416,2 +416,2 @@ /* | ||
export default julia; | ||
export { julia as default }; |
@@ -284,2 +284,2 @@ // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10 | ||
export default kotlin; | ||
export { kotlin as default }; |
@@ -187,2 +187,2 @@ /* | ||
export default lasso; | ||
export { lasso as default }; |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -52,3 +10,4 @@ Language: LaTeX | ||
function latex(hljs) { | ||
const KNOWN_CONTROL_WORDS = either(...[ | ||
const regex = hljs.regex; | ||
const KNOWN_CONTROL_WORDS = regex.either(...[ | ||
'(?:NeedsTeXFormat|RequirePackage|GetIdInfo)', | ||
@@ -291,2 +250,2 @@ 'Provides(?:Expl)?(?:Package|Class|File)', | ||
export default latex; | ||
export { latex as default }; |
@@ -31,2 +31,2 @@ /* | ||
export default ldif; | ||
export { ldif as default }; |
@@ -49,2 +49,2 @@ /* | ||
export default leaf; | ||
export { leaf as default }; |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -652,3 +762,4 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
}, | ||
IDENT_MODE('selector-tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags" | ||
modes.CSS_NUMBER_MODE, | ||
IDENT_MODE('selector-tag', INTERP_IDENT_RE, 0), | ||
IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE), | ||
@@ -664,3 +775,3 @@ IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE, 0), | ||
className: 'selector-pseudo', | ||
begin: '::(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
}, | ||
@@ -675,3 +786,4 @@ { | ||
begin: '!important' | ||
} // eat !important after mixin call or it will be colored as tag | ||
}, // eat !important after mixin call or it will be colored as tag | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -704,2 +816,2 @@ }; | ||
export default less; | ||
export { less as default }; |
@@ -111,2 +111,2 @@ /* | ||
export default lisp; | ||
export { lisp as default }; |
@@ -189,2 +189,2 @@ /* | ||
export default livecodeserver; | ||
export { livecodeserver as default }; |
@@ -53,40 +53,57 @@ const KEYWORDS = [ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -362,2 +379,2 @@ "InternalError", | ||
export default livescript; | ||
export { livescript as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: LLVM IR | ||
function llvm(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /([-a-zA-Z$._][\w$.-]*)/; | ||
@@ -71,3 +47,3 @@ const TYPE = { | ||
variants: [ | ||
{ begin: concat(/%/, IDENT_RE) }, | ||
{ begin: regex.concat(/%/, IDENT_RE) }, | ||
{ begin: /%\d+/ }, | ||
@@ -80,6 +56,6 @@ { begin: /#\d+/ }, | ||
variants: [ | ||
{ begin: concat(/@/, IDENT_RE) }, | ||
{ begin: regex.concat(/@/, IDENT_RE) }, | ||
{ begin: /@\d+/ }, | ||
{ begin: concat(/!/, IDENT_RE) }, | ||
{ begin: concat(/!\d+/, IDENT_RE) }, | ||
{ begin: regex.concat(/!/, IDENT_RE) }, | ||
{ begin: regex.concat(/!\d+/, IDENT_RE) }, | ||
// https://llvm.org/docs/LangRef.html#namedmetadatastructure | ||
@@ -157,2 +133,2 @@ // obviously a single digit can also be used in this fashion | ||
export default llvm; | ||
export { llvm as default }; |
@@ -95,2 +95,2 @@ /* | ||
export default lsl; | ||
export { lsl as default }; |
@@ -82,2 +82,2 @@ /* | ||
export default lua; | ||
export { lua as default }; |
@@ -92,2 +92,2 @@ /* | ||
export default makefile; | ||
export { makefile as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Markdown | ||
function markdown(hljs) { | ||
const regex = hljs.regex; | ||
const INLINE_HTML = { | ||
@@ -122,3 +98,3 @@ begin: /<\/?[A-Za-z_]/, | ||
{ | ||
begin: concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/), | ||
begin: regex.concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/), | ||
relevance: 2 | ||
@@ -264,2 +240,2 @@ }, | ||
export default markdown; | ||
export { markdown as default }; |
@@ -106,2 +106,2 @@ /* | ||
export default matlab; | ||
export { matlab as default }; |
@@ -417,2 +417,2 @@ /* | ||
export default maxima; | ||
export { maxima as default }; |
@@ -236,2 +236,2 @@ /* | ||
export default mel; | ||
export { mel as default }; |
@@ -121,2 +121,2 @@ /* | ||
export default mercury; | ||
export { mercury as default }; |
@@ -109,2 +109,2 @@ /* | ||
export default mipsasm; | ||
export { mipsasm as default }; |
@@ -29,2 +29,2 @@ /* | ||
export default mizar; | ||
export { mizar as default }; |
@@ -36,2 +36,2 @@ /* | ||
export default mojolicious; | ||
export { mojolicious as default }; |
@@ -89,2 +89,2 @@ /* | ||
export default monkey; | ||
export { monkey as default }; |
@@ -147,2 +147,2 @@ /* | ||
export default moonscript; | ||
export { moonscript as default }; |
@@ -364,2 +364,2 @@ /* | ||
export default n1ql; | ||
export { n1ql as default }; |
@@ -87,2 +87,2 @@ /* | ||
export default nestedtext; | ||
export { nestedtext as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,2 +11,3 @@ Language: Nginx config | ||
function nginx(hljs) { | ||
const regex = hljs.regex; | ||
const VAR = { | ||
@@ -55,3 +23,3 @@ className: 'variable', | ||
{ | ||
begin: concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) | ||
begin: regex.concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) | ||
} | ||
@@ -179,7 +147,7 @@ ] | ||
className: 'section', | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE + lookahead(/\s+\{/)), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE + regex.lookahead(/\s+\{/)), | ||
relevance: 0 | ||
}, | ||
{ | ||
begin: lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'), | ||
begin: regex.lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'), | ||
end: ';|\\{', | ||
@@ -200,2 +168,2 @@ contains: [ | ||
export default nginx; | ||
export { nginx as default }; |
@@ -197,2 +197,2 @@ /* | ||
export default nim; | ||
export { nim as default }; |
@@ -89,2 +89,2 @@ /* | ||
export default nix; | ||
export { nix as default }; |
@@ -37,2 +37,2 @@ /* | ||
export default nodeRepl; | ||
export { nodeRepl as default }; |
@@ -0,1 +1,57 @@ | ||
/** | ||
* @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; | ||
} | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* Any of the passed expresssions may match | ||
* | ||
* Creates a huge this | this | that | that match | ||
* @param {(RegExp | string)[] } args | ||
* @returns {string} | ||
*/ | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -9,5 +65,142 @@ Language: NSIS | ||
function nsis(hljs) { | ||
const LANGUAGE_CONSTANTS = [ | ||
"ADMINTOOLS", | ||
"APPDATA", | ||
"CDBURN_AREA", | ||
"CMDLINE", | ||
"COMMONFILES32", | ||
"COMMONFILES64", | ||
"COMMONFILES", | ||
"COOKIES", | ||
"DESKTOP", | ||
"DOCUMENTS", | ||
"EXEDIR", | ||
"EXEFILE", | ||
"EXEPATH", | ||
"FAVORITES", | ||
"FONTS", | ||
"HISTORY", | ||
"HWNDPARENT", | ||
"INSTDIR", | ||
"INTERNET_CACHE", | ||
"LANGUAGE", | ||
"LOCALAPPDATA", | ||
"MUSIC", | ||
"NETHOOD", | ||
"OUTDIR", | ||
"PICTURES", | ||
"PLUGINSDIR", | ||
"PRINTHOOD", | ||
"PROFILE", | ||
"PROGRAMFILES32", | ||
"PROGRAMFILES64", | ||
"PROGRAMFILES", | ||
"QUICKLAUNCH", | ||
"RECENT", | ||
"RESOURCES_LOCALIZED", | ||
"RESOURCES", | ||
"SENDTO", | ||
"SMPROGRAMS", | ||
"SMSTARTUP", | ||
"STARTMENU", | ||
"SYSDIR", | ||
"TEMP", | ||
"TEMPLATES", | ||
"VIDEOS", | ||
"WINDIR" | ||
]; | ||
const PARAM_NAMES = [ | ||
"ARCHIVE", | ||
"FILE_ATTRIBUTE_ARCHIVE", | ||
"FILE_ATTRIBUTE_NORMAL", | ||
"FILE_ATTRIBUTE_OFFLINE", | ||
"FILE_ATTRIBUTE_READONLY", | ||
"FILE_ATTRIBUTE_SYSTEM", | ||
"FILE_ATTRIBUTE_TEMPORARY", | ||
"HKCR", | ||
"HKCU", | ||
"HKDD", | ||
"HKEY_CLASSES_ROOT", | ||
"HKEY_CURRENT_CONFIG", | ||
"HKEY_CURRENT_USER", | ||
"HKEY_DYN_DATA", | ||
"HKEY_LOCAL_MACHINE", | ||
"HKEY_PERFORMANCE_DATA", | ||
"HKEY_USERS", | ||
"HKLM", | ||
"HKPD", | ||
"HKU", | ||
"IDABORT", | ||
"IDCANCEL", | ||
"IDIGNORE", | ||
"IDNO", | ||
"IDOK", | ||
"IDRETRY", | ||
"IDYES", | ||
"MB_ABORTRETRYIGNORE", | ||
"MB_DEFBUTTON1", | ||
"MB_DEFBUTTON2", | ||
"MB_DEFBUTTON3", | ||
"MB_DEFBUTTON4", | ||
"MB_ICONEXCLAMATION", | ||
"MB_ICONINFORMATION", | ||
"MB_ICONQUESTION", | ||
"MB_ICONSTOP", | ||
"MB_OK", | ||
"MB_OKCANCEL", | ||
"MB_RETRYCANCEL", | ||
"MB_RIGHT", | ||
"MB_RTLREADING", | ||
"MB_SETFOREGROUND", | ||
"MB_TOPMOST", | ||
"MB_USERICON", | ||
"MB_YESNO", | ||
"NORMAL", | ||
"OFFLINE", | ||
"READONLY", | ||
"SHCTX", | ||
"SHELL_CONTEXT", | ||
"SYSTEM|TEMPORARY", | ||
]; | ||
const COMPILER_FLAGS = [ | ||
"addincludedir", | ||
"addplugindir", | ||
"appendfile", | ||
"cd", | ||
"define", | ||
"delfile", | ||
"echo", | ||
"else", | ||
"endif", | ||
"error", | ||
"execute", | ||
"finalize", | ||
"getdllversion", | ||
"gettlbversion", | ||
"if", | ||
"ifdef", | ||
"ifmacrodef", | ||
"ifmacrondef", | ||
"ifndef", | ||
"include", | ||
"insertmacro", | ||
"macro", | ||
"macroend", | ||
"makensis", | ||
"packhdr", | ||
"searchparse", | ||
"searchreplace", | ||
"system", | ||
"tempfile", | ||
"undef", | ||
"uninstfinalize", | ||
"verbose", | ||
"warning", | ||
]; | ||
const CONSTANTS = { | ||
className: 'variable', | ||
begin: /\$(ADMINTOOLS|APPDATA|CDBURN_AREA|CMDLINE|COMMONFILES32|COMMONFILES64|COMMONFILES|COOKIES|DESKTOP|DOCUMENTS|EXEDIR|EXEFILE|EXEPATH|FAVORITES|FONTS|HISTORY|HWNDPARENT|INSTDIR|INTERNET_CACHE|LANGUAGE|LOCALAPPDATA|MUSIC|NETHOOD|OUTDIR|PICTURES|PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES32|PROGRAMFILES64|PROGRAMFILES|QUICKLAUNCH|RECENT|RESOURCES_LOCALIZED|RESOURCES|SENDTO|SMPROGRAMS|SMSTARTUP|STARTMENU|SYSDIR|TEMP|TEMPLATES|VIDEOS|WINDIR)/ | ||
className: 'variable.constant', | ||
begin: concat(/\$/, either(...LANGUAGE_CONSTANTS)) | ||
}; | ||
@@ -37,3 +230,3 @@ | ||
className: 'params', | ||
begin: '(ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)' | ||
begin: either(...PARAM_NAMES) | ||
}; | ||
@@ -44,3 +237,6 @@ | ||
className: 'keyword', | ||
begin: /!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversion|gettlbversion|if|ifdef|ifmacrodef|ifmacrondef|ifndef|include|insertmacro|macro|macroend|makensis|packhdr|searchparse|searchreplace|system|tempfile|undef|verbose|warning)/ | ||
begin: concat( | ||
/!/, | ||
either(...COMPILER_FLAGS) | ||
) | ||
}; | ||
@@ -56,3 +252,3 @@ | ||
// plug::ins | ||
className: 'class', | ||
className: 'title.function', | ||
begin: /\w+::\w+/ | ||
@@ -87,10 +283,291 @@ }; | ||
const KEYWORDS = [ | ||
"Abort", | ||
"AddBrandingImage", | ||
"AddSize", | ||
"AllowRootDirInstall", | ||
"AllowSkipFiles", | ||
"AutoCloseWindow", | ||
"BGFont", | ||
"BGGradient", | ||
"BrandingText", | ||
"BringToFront", | ||
"Call", | ||
"CallInstDLL", | ||
"Caption", | ||
"ChangeUI", | ||
"CheckBitmap", | ||
"ClearErrors", | ||
"CompletedText", | ||
"ComponentText", | ||
"CopyFiles", | ||
"CRCCheck", | ||
"CreateDirectory", | ||
"CreateFont", | ||
"CreateShortCut", | ||
"Delete", | ||
"DeleteINISec", | ||
"DeleteINIStr", | ||
"DeleteRegKey", | ||
"DeleteRegValue", | ||
"DetailPrint", | ||
"DetailsButtonText", | ||
"DirText", | ||
"DirVar", | ||
"DirVerify", | ||
"EnableWindow", | ||
"EnumRegKey", | ||
"EnumRegValue", | ||
"Exch", | ||
"Exec", | ||
"ExecShell", | ||
"ExecShellWait", | ||
"ExecWait", | ||
"ExpandEnvStrings", | ||
"File", | ||
"FileBufSize", | ||
"FileClose", | ||
"FileErrorText", | ||
"FileOpen", | ||
"FileRead", | ||
"FileReadByte", | ||
"FileReadUTF16LE", | ||
"FileReadWord", | ||
"FileWriteUTF16LE", | ||
"FileSeek", | ||
"FileWrite", | ||
"FileWriteByte", | ||
"FileWriteWord", | ||
"FindClose", | ||
"FindFirst", | ||
"FindNext", | ||
"FindWindow", | ||
"FlushINI", | ||
"GetCurInstType", | ||
"GetCurrentAddress", | ||
"GetDlgItem", | ||
"GetDLLVersion", | ||
"GetDLLVersionLocal", | ||
"GetErrorLevel", | ||
"GetFileTime", | ||
"GetFileTimeLocal", | ||
"GetFullPathName", | ||
"GetFunctionAddress", | ||
"GetInstDirError", | ||
"GetKnownFolderPath", | ||
"GetLabelAddress", | ||
"GetTempFileName", | ||
"GetWinVer", | ||
"Goto", | ||
"HideWindow", | ||
"Icon", | ||
"IfAbort", | ||
"IfErrors", | ||
"IfFileExists", | ||
"IfRebootFlag", | ||
"IfRtlLanguage", | ||
"IfShellVarContextAll", | ||
"IfSilent", | ||
"InitPluginsDir", | ||
"InstallButtonText", | ||
"InstallColors", | ||
"InstallDir", | ||
"InstallDirRegKey", | ||
"InstProgressFlags", | ||
"InstType", | ||
"InstTypeGetText", | ||
"InstTypeSetText", | ||
"Int64Cmp", | ||
"Int64CmpU", | ||
"Int64Fmt", | ||
"IntCmp", | ||
"IntCmpU", | ||
"IntFmt", | ||
"IntOp", | ||
"IntPtrCmp", | ||
"IntPtrCmpU", | ||
"IntPtrOp", | ||
"IsWindow", | ||
"LangString", | ||
"LicenseBkColor", | ||
"LicenseData", | ||
"LicenseForceSelection", | ||
"LicenseLangString", | ||
"LicenseText", | ||
"LoadAndSetImage", | ||
"LoadLanguageFile", | ||
"LockWindow", | ||
"LogSet", | ||
"LogText", | ||
"ManifestDPIAware", | ||
"ManifestLongPathAware", | ||
"ManifestMaxVersionTested", | ||
"ManifestSupportedOS", | ||
"MessageBox", | ||
"MiscButtonText", | ||
"Name", | ||
"Nop", | ||
"OutFile", | ||
"Page", | ||
"PageCallbacks", | ||
"PEAddResource", | ||
"PEDllCharacteristics", | ||
"PERemoveResource", | ||
"PESubsysVer", | ||
"Pop", | ||
"Push", | ||
"Quit", | ||
"ReadEnvStr", | ||
"ReadINIStr", | ||
"ReadRegDWORD", | ||
"ReadRegStr", | ||
"Reboot", | ||
"RegDLL", | ||
"Rename", | ||
"RequestExecutionLevel", | ||
"ReserveFile", | ||
"Return", | ||
"RMDir", | ||
"SearchPath", | ||
"SectionGetFlags", | ||
"SectionGetInstTypes", | ||
"SectionGetSize", | ||
"SectionGetText", | ||
"SectionIn", | ||
"SectionSetFlags", | ||
"SectionSetInstTypes", | ||
"SectionSetSize", | ||
"SectionSetText", | ||
"SendMessage", | ||
"SetAutoClose", | ||
"SetBrandingImage", | ||
"SetCompress", | ||
"SetCompressor", | ||
"SetCompressorDictSize", | ||
"SetCtlColors", | ||
"SetCurInstType", | ||
"SetDatablockOptimize", | ||
"SetDateSave", | ||
"SetDetailsPrint", | ||
"SetDetailsView", | ||
"SetErrorLevel", | ||
"SetErrors", | ||
"SetFileAttributes", | ||
"SetFont", | ||
"SetOutPath", | ||
"SetOverwrite", | ||
"SetRebootFlag", | ||
"SetRegView", | ||
"SetShellVarContext", | ||
"SetSilent", | ||
"ShowInstDetails", | ||
"ShowUninstDetails", | ||
"ShowWindow", | ||
"SilentInstall", | ||
"SilentUnInstall", | ||
"Sleep", | ||
"SpaceTexts", | ||
"StrCmp", | ||
"StrCmpS", | ||
"StrCpy", | ||
"StrLen", | ||
"SubCaption", | ||
"Unicode", | ||
"UninstallButtonText", | ||
"UninstallCaption", | ||
"UninstallIcon", | ||
"UninstallSubCaption", | ||
"UninstallText", | ||
"UninstPage", | ||
"UnRegDLL", | ||
"Var", | ||
"VIAddVersionKey", | ||
"VIFileVersion", | ||
"VIProductVersion", | ||
"WindowIcon", | ||
"WriteINIStr", | ||
"WriteRegBin", | ||
"WriteRegDWORD", | ||
"WriteRegExpandStr", | ||
"WriteRegMultiStr", | ||
"WriteRegNone", | ||
"WriteRegStr", | ||
"WriteUninstaller", | ||
"XPStyle" | ||
]; | ||
const LITERALS = [ | ||
"admin", | ||
"all", | ||
"auto", | ||
"both", | ||
"bottom", | ||
"bzip2", | ||
"colored", | ||
"components", | ||
"current", | ||
"custom", | ||
"directory", | ||
"false", | ||
"force", | ||
"hide", | ||
"highest", | ||
"ifdiff", | ||
"ifnewer", | ||
"instfiles", | ||
"lastused", | ||
"leave", | ||
"left", | ||
"license", | ||
"listonly", | ||
"lzma", | ||
"nevershow", | ||
"none", | ||
"normal", | ||
"notset", | ||
"off", | ||
"on", | ||
"open", | ||
"print", | ||
"right", | ||
"show", | ||
"silent", | ||
"silentlog", | ||
"smooth", | ||
"textonly", | ||
"top", | ||
"true", | ||
"try", | ||
"un.components", | ||
"un.custom", | ||
"un.directory", | ||
"un.instfiles", | ||
"un.license", | ||
"uninstConfirm", | ||
"user", | ||
"Win10", | ||
"Win7", | ||
"Win8", | ||
"WinVista", | ||
"zlib" | ||
]; | ||
const FUNCTION_DEF = { | ||
match: [ | ||
/Function/, | ||
/\s+/, | ||
concat(/(\.)?/, hljs.IDENT_RE) | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.function" | ||
} | ||
}; | ||
return { | ||
name: 'NSIS', | ||
case_insensitive: false, | ||
case_insensitive: true, | ||
keywords: { | ||
keyword: | ||
'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirText DirVar DirVerify EnableWindow EnumRegKey EnumRegValue Exch Exec ExecShell ExecShellWait ExecWait ExpandEnvStrings File FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileReadUTF16LE FileReadWord FileWriteUTF16LE FileSeek FileWrite FileWriteByte FileWriteWord FindClose FindFirst FindNext FindWindow FlushINI GetCurInstType GetCurrentAddress GetDlgItem GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal GetFullPathName GetFunctionAddress GetInstDirError GetKnownFolderPath GetLabelAddress GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfRtlLanguage IfShellVarContextAll IfSilent InitPluginsDir InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText InstTypeSetText Int64Cmp Int64CmpU Int64Fmt IntCmp IntCmpU IntFmt IntOp IntPtrCmp IntPtrCmpU IntPtrOp IsWindow LangString LicenseBkColor LicenseData LicenseForceSelection LicenseLangString LicenseText LoadAndSetImage LoadLanguageFile LockWindow LogSet LogText ManifestDPIAware ManifestLongPathAware ManifestMaxVersionTested ManifestSupportedOS MessageBox MiscButtonText Name Nop OutFile Page PageCallbacks PEAddResource PEDllCharacteristics PERemoveResource PESubsysVer Pop Push Quit ReadEnvStr ReadINIStr ReadRegDWORD ReadRegStr Reboot RegDLL Rename RequestExecutionLevel ReserveFile Return RMDir SearchPath SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress SetCompressor SetCompressorDictSize SetCtlColors SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrorLevel SetErrors SetFileAttributes SetFont SetOutPath SetOverwrite SetRebootFlag SetRegView SetShellVarContext SetSilent ShowInstDetails ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCmpS StrCpy StrLen SubCaption Unicode UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText UninstPage UnRegDLL Var VIAddVersionKey VIFileVersion VIProductVersion WindowIcon WriteINIStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegMultiStr WriteRegNone WriteRegStr WriteUninstaller XPStyle', | ||
literal: | ||
'admin all auto both bottom bzip2 colored components current custom directory false force hide highest ifdiff ifnewer instfiles lastused leave left license listonly lzma nevershow none normal notset off on open print right show silent silentlog smooth textonly top true try un.components un.custom un.directory un.instfiles un.license uninstConfirm user Win10 Win7 Win8 WinVista zlib' | ||
keyword: KEYWORDS, | ||
literal: LITERALS | ||
}, | ||
@@ -107,6 +584,5 @@ contains: [ | ||
), | ||
FUNCTION_DEF, | ||
{ | ||
className: 'function', | ||
beginKeywords: 'Function PageEx Section SectionGroup', | ||
end: '$' | ||
beginKeywords: 'Function PageEx Section SectionGroup FunctionEnd SectionEnd', | ||
}, | ||
@@ -125,2 +601,2 @@ STRING, | ||
export default nsis; | ||
export { nsis as default }; |
@@ -250,2 +250,2 @@ /* | ||
export default objectivec; | ||
export { objectivec as default }; |
@@ -82,2 +82,2 @@ /* | ||
export default ocaml; | ||
export { ocaml as default }; |
@@ -81,2 +81,2 @@ /* | ||
export default openscad; | ||
export { openscad as default }; |
@@ -101,2 +101,2 @@ /* | ||
export default oxygene; | ||
export { oxygene as default }; |
@@ -57,2 +57,2 @@ /* | ||
export default parser3; | ||
export { parser3 as default }; |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -61,2 +10,3 @@ Language: Perl | ||
function perl(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = [ | ||
@@ -318,3 +268,3 @@ 'abs', | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, | ||
@@ -354,5 +304,5 @@ // negative look-ahead tries to avoid matching patterns that are not | ||
? close | ||
: concat(close, open); | ||
return concat( | ||
concat("(?:", prefix, ")"), | ||
: regex.concat(close, open); | ||
return regex.concat( | ||
regex.concat("(?:", prefix, ")"), | ||
open, | ||
@@ -372,4 +322,4 @@ /(?:\\.|[^\\\/])*?/, | ||
const PAIRED_RE = (prefix, open, close) => { | ||
return concat( | ||
concat("(?:", prefix, ")"), | ||
return regex.concat( | ||
regex.concat("(?:", prefix, ")"), | ||
open, | ||
@@ -465,3 +415,3 @@ /(?:\\.|[^\\\/])*?/, | ||
// allow matching common delimiters | ||
{ begin: PAIRED_DOUBLE_RE("s|tr|y", either(...REGEX_DELIMS, { capture: true })) }, | ||
{ begin: PAIRED_DOUBLE_RE("s|tr|y", regex.either(...REGEX_DELIMS, { capture: true })) }, | ||
// and then paired delmis | ||
@@ -486,3 +436,3 @@ { begin: PAIRED_DOUBLE_RE("s|tr|y", "\\(", "\\)") }, | ||
// allow matching common delimiters | ||
{ begin: PAIRED_RE("m|qr", either(...REGEX_DELIMS, { capture: true }), /\1/)}, | ||
{ begin: PAIRED_RE("m|qr", regex.either(...REGEX_DELIMS, { capture: true }), /\1/)}, | ||
// allow common paired delmins | ||
@@ -535,2 +485,2 @@ { begin: PAIRED_RE("m|qr", /\(/, /\)/)}, | ||
export default perl; | ||
export { perl as default }; |
@@ -59,2 +59,2 @@ /* | ||
export default pf; | ||
export { pf as default }; |
@@ -631,2 +631,2 @@ /* | ||
export default pgsql; | ||
export { pgsql as default }; |
@@ -54,2 +54,2 @@ /* | ||
export default phpTemplate; | ||
export { phpTemplate as default }; |
@@ -203,2 +203,2 @@ /* | ||
export default php; | ||
export { php as default }; |
@@ -19,2 +19,2 @@ /* | ||
export default plaintext; | ||
export { plaintext as default }; |
@@ -89,2 +89,2 @@ /* | ||
export default pony; | ||
export { pony as default }; |
@@ -332,2 +332,2 @@ /* | ||
export default powershell; | ||
export { powershell as default }; |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -69,2 +10,3 @@ Language: Processing | ||
function processing(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_INS = [ | ||
@@ -337,3 +279,3 @@ "displayHeight", | ||
{ | ||
match: concat(either(...BUILT_INS), lookahead(/\s*\(/)), | ||
match: regex.concat(regex.either(...BUILT_INS), regex.lookahead(/\s*\(/)), | ||
className: "built_in" | ||
@@ -343,5 +285,5 @@ }, | ||
relevance: 0, | ||
match: concat( | ||
match: regex.concat( | ||
/\b(?!for|if|while)/, | ||
IDENT, lookahead(/\s*\(/)), | ||
IDENT, regex.lookahead(/\s*\(/)), | ||
className: "title.function" | ||
@@ -505,2 +447,2 @@ } | ||
export default processing; | ||
export { processing as default }; |
@@ -43,2 +43,2 @@ /* | ||
export default profile; | ||
export { profile as default }; |
@@ -102,2 +102,2 @@ /* | ||
export default prolog; | ||
export { prolog as default }; |
@@ -76,2 +76,2 @@ /* | ||
export default properties; | ||
export { properties as default }; |
@@ -47,2 +47,2 @@ /* | ||
export default protobuf; | ||
export { protobuf as default }; |
@@ -147,2 +147,2 @@ /* | ||
export default puppet; | ||
export { puppet as default }; |
@@ -101,2 +101,2 @@ /* | ||
export default purebasic; | ||
export { purebasic as default }; |
@@ -36,2 +36,2 @@ /* | ||
export default pythonRepl; | ||
export { pythonRepl as default }; |
@@ -1,166 +0,1 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {string} | ||
*/ | ||
/** | ||
* performs a shallow merge of multiple objects into one | ||
* | ||
* @template T | ||
* @param {T} original | ||
* @param {Record<string,any>[]} objects | ||
* @returns {T} a single new object | ||
*/ | ||
function inherit(original, ...objects) { | ||
/** @type Record<string,any> */ | ||
const result = Object.create(null); | ||
for (const key in original) { | ||
result[key] = original[key]; | ||
} | ||
objects.forEach(function(obj) { | ||
for (const key in obj) { | ||
result[key] = obj[key]; | ||
} | ||
}); | ||
return /** @type {T} */ (result); | ||
} | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; | ||
/** | ||
* Creates a comment mode | ||
* | ||
* @param {string | RegExp} begin | ||
* @param {string | RegExp} end | ||
* @param {Mode | {}} [modeOptions] | ||
* @returns {Partial<Mode>} | ||
*/ | ||
const COMMENT = function(begin, end, modeOptions = {}) { | ||
const mode = inherit( | ||
{ | ||
scope: 'comment', | ||
begin, | ||
end, | ||
contains: [] | ||
}, | ||
modeOptions | ||
); | ||
mode.contains.push({ | ||
scope: 'doctag', | ||
// hack to avoid the space from being included. the space is necessary to | ||
// match here to prevent the plain text rule below from gobbling up doctags | ||
begin: '[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)', | ||
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/, | ||
excludeBegin: true, | ||
relevance: 0 | ||
}); | ||
const ENGLISH_WORD = either( | ||
// list of common 1 and 2 letter words in English | ||
"I", | ||
"a", | ||
"is", | ||
"so", | ||
"us", | ||
"to", | ||
"at", | ||
"if", | ||
"in", | ||
"it", | ||
"on", | ||
// note: this is not an exhaustive list of contractions, just popular ones | ||
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/, // contractions - can't we'd they're let's, etc | ||
/[A-Za-z]+[-][a-z]+/, // `no-way`, etc. | ||
/[A-Za-z][a-z]{2,}/ // allow capitalized words at beginning of sentences | ||
); | ||
// looking like plain text, more likely to be a comment | ||
mode.contains.push( | ||
{ | ||
// TODO: how to include ", (, ) without breaking grammars that use these for | ||
// comment delimiters? | ||
// begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/ | ||
// --- | ||
// this tries to find sequences of 3 english words in a row (without any | ||
// "programming" type syntax) this gives us a strong signal that we've | ||
// TRULY found a comment - vs perhaps scanning with the wrong language. | ||
// It's possible to find something that LOOKS like the start of the | ||
// comment - but then if there is no readable text - good chance it is a | ||
// false match and not a comment. | ||
// | ||
// for a visual example please see: | ||
// https://github.com/highlightjs/highlight.js/issues/2827 | ||
begin: concat( | ||
/[ ]+/, // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */ | ||
'(', | ||
ENGLISH_WORD, | ||
/[.]?[:]?([.][ ]|[ ])/, | ||
'){3}') // look for 3 words in a row | ||
} | ||
); | ||
return mode; | ||
}; | ||
COMMENT('//', '$'); | ||
COMMENT('/\\*', '\\*/'); | ||
COMMENT('#', '$'); | ||
/* | ||
@@ -174,2 +9,4 @@ Language: Python | ||
function python(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[\p{XID_Start}_]\p{XID_Continue}*/u; | ||
const RESERVED_WORDS = [ | ||
@@ -471,3 +308,3 @@ 'and', | ||
className: "comment", | ||
begin: lookahead(/# type:/), | ||
begin: regex.lookahead(/# type:/), | ||
end: /$/, | ||
@@ -525,2 +362,3 @@ keywords: KEYWORDS, | ||
], | ||
unicodeRegex: true, | ||
keywords: KEYWORDS, | ||
@@ -547,3 +385,3 @@ illegal: /(<\/|->|\?)|=>/, | ||
/def/, /\s+/, | ||
UNDERSCORE_IDENT_RE | ||
IDENT_RE, | ||
], | ||
@@ -561,4 +399,4 @@ scope: { | ||
/class/, /\s+/, | ||
UNDERSCORE_IDENT_RE, /\s*/, | ||
/\(\s*/, UNDERSCORE_IDENT_RE,/\s*\)/ | ||
IDENT_RE, /\s*/, | ||
/\(\s*/, IDENT_RE,/\s*\)/ | ||
], | ||
@@ -569,3 +407,3 @@ }, | ||
/class/, /\s+/, | ||
UNDERSCORE_IDENT_RE | ||
IDENT_RE | ||
], | ||
@@ -594,2 +432,2 @@ } | ||
export default python; | ||
export { python as default }; |
@@ -37,2 +37,2 @@ /* | ||
export default q; | ||
export { q as default }; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: QML | ||
function qml(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
@@ -119,3 +95,3 @@ keyword: | ||
const QML_OBJECT = { | ||
begin: concat(QML_IDENT_RE, /\s*\{/), | ||
begin: regex.concat(QML_IDENT_RE, /\s*\{/), | ||
end: /\{/, | ||
@@ -227,2 +203,2 @@ returnBegin: true, | ||
export default qml; | ||
export { qml as default }; |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -71,2 +12,3 @@ Language: R | ||
function r(hljs) { | ||
const regex = hljs.regex; | ||
// Identifiers in R cannot start with `_`, but they can start with `.` if it | ||
@@ -79,3 +21,3 @@ // is not immediately followed by a digit. | ||
const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; | ||
const NUMBER_TYPES_RE = either( | ||
const NUMBER_TYPES_RE = regex.either( | ||
// Special case: only hexadecimal binary powers can contain fractions | ||
@@ -89,3 +31,3 @@ /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/, | ||
const OPERATORS_RE = /[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/; | ||
const PUNCTUATION_RE = either( | ||
const PUNCTUATION_RE = regex.either( | ||
/[()]/, | ||
@@ -150,3 +92,3 @@ /[{}]/, | ||
starts: { | ||
end: lookahead(either( | ||
end: regex.lookahead(regex.either( | ||
// end if another doc comment | ||
@@ -297,2 +239,2 @@ /\n^#'\s*(?=@[a-zA-Z]+)/, | ||
export default r; | ||
export { r as default }; |
@@ -324,2 +324,2 @@ /* | ||
export default reasonml; | ||
export { reasonml as default }; |
@@ -37,2 +37,2 @@ /* | ||
export default rib; | ||
export { rib as default }; |
@@ -82,2 +82,2 @@ /* | ||
export default roboconf; | ||
export { roboconf as default }; |
@@ -172,2 +172,2 @@ /* | ||
export default routeros; | ||
export { routeros as default }; |
@@ -49,2 +49,2 @@ /* | ||
export default rsl; | ||
export { rsl as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,2 +11,3 @@ Language: Ruby | ||
function ruby(hljs) { | ||
const regex = hljs.regex; | ||
const RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)'; | ||
@@ -163,5 +131,5 @@ const RUBY_KEYWORDS = { | ||
// positive (auto-detect, etc.) | ||
begin: concat( | ||
begin: regex.concat( | ||
/<<[-~]?'?/, | ||
lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/) | ||
regex.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/) | ||
), | ||
@@ -255,3 +223,3 @@ contains: [ | ||
// def method_name (end of line) | ||
begin: concat(/def\s+/, lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")), | ||
begin: regex.concat(/def\s+/, regex.lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")), | ||
relevance: 0, // relevance comes from kewords | ||
@@ -392,2 +360,2 @@ keywords: "def", | ||
export default ruby; | ||
export { ruby as default }; |
@@ -78,2 +78,2 @@ /* | ||
export default ruleslanguage; | ||
export { ruleslanguage as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,10 +11,11 @@ Language: Rust | ||
function rust(hljs) { | ||
const regex = hljs.regex; | ||
const FUNCTION_INVOKE = { | ||
className: "title.function.invoke", | ||
relevance: 0, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
/(?!let\b)/, | ||
hljs.IDENT_RE, | ||
lookahead(/\s*\(/)) | ||
regex.lookahead(/\s*\(/)) | ||
}; | ||
@@ -349,2 +317,2 @@ const NUMBER_SUFFIX = '([ui](8|16|32|64|128|size)|f(32|64))\?'; | ||
export default rust; | ||
export { rust as default }; |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -51,2 +9,3 @@ Language: SAS | ||
function sas(hljs) { | ||
const regex = hljs.regex; | ||
// Data step and PROC SQL statements | ||
@@ -571,3 +530,3 @@ const SAS_KEYWORDS = [ | ||
className: 'built_in', | ||
begin: '%' + either(...MACRO_FUNCTIONS) | ||
begin: '%' + regex.either(...MACRO_FUNCTIONS) | ||
}, | ||
@@ -584,3 +543,3 @@ { | ||
className: 'meta', | ||
begin: either(...FUNCTIONS) + '(?=\\()' | ||
begin: regex.either(...FUNCTIONS) + '(?=\\()' | ||
}, | ||
@@ -600,2 +559,2 @@ { | ||
export default sas; | ||
export { sas as default }; |
@@ -10,2 +10,3 @@ /* | ||
function scala(hljs) { | ||
const regex = hljs.regex; | ||
const ANNOTATION = { | ||
@@ -63,7 +64,2 @@ className: 'meta', | ||
const SYMBOL = { | ||
className: 'symbol', | ||
begin: '\'\\w[\\w\\d_]*(?!\')' | ||
}; | ||
const TYPE = { | ||
@@ -117,7 +113,51 @@ className: 'type', | ||
beginKeywords: 'def', | ||
end: /[:={\[(\n;]/, | ||
excludeEnd: true, | ||
end: regex.lookahead(/[:={\[(\n;]/), | ||
contains: [ NAME ] | ||
}; | ||
const EXTENSION = { | ||
begin: [ | ||
/^\s*/, // Is first token on the line | ||
'extension', | ||
/\s+(?=[[(])/, // followed by at least one space and `[` or `(` | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
} | ||
}; | ||
const END = [{ | ||
begin: [ | ||
/^\s*/, // Is first token on the line | ||
/end/, | ||
/\s+/, | ||
/(extension\b)?/, // `extension` is the only marker that follows an `end` that cannot be captured by another rule. | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
4: "keyword", | ||
} | ||
}]; | ||
// TODO: use negative look-behind in future | ||
// /(?<!\.)\binline(?=\s)/ | ||
const INLINE_MODES = [{ | ||
match: /\.inline\b/ | ||
}, | ||
{ | ||
begin: /\binline(?=\s)/, | ||
keywords: 'inline' | ||
}]; | ||
const USING_PARAM_CLAUSE = { | ||
begin: [ | ||
/\(\s*/, // Opening `(` of a parameter or argument list | ||
/using/, | ||
/\s+(?!\))/, // Spaces not followed by `)` | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
} | ||
}; | ||
return { | ||
@@ -127,3 +167,3 @@ name: 'Scala', | ||
literal: 'true false null', | ||
keyword: 'type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit' | ||
keyword: 'type yield lazy override def with val var sealed abstract private trait object if then forSome for while do throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit export enum given' | ||
}, | ||
@@ -134,3 +174,2 @@ contains: [ | ||
STRING, | ||
SYMBOL, | ||
TYPE, | ||
@@ -140,2 +179,6 @@ METHOD, | ||
hljs.C_NUMBER_MODE, | ||
EXTENSION, | ||
END, | ||
...INLINE_MODES, | ||
USING_PARAM_CLAUSE, | ||
ANNOTATION | ||
@@ -146,2 +189,2 @@ ] | ||
export default scala; | ||
export { scala as default }; |
@@ -207,2 +207,2 @@ /* | ||
export default scheme; | ||
export { scheme as default }; |
@@ -73,2 +73,2 @@ /* | ||
export default scilab; | ||
export { scilab as default }; |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -491,2 +601,5 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
// to recognize keyframe 40% etc which are outside the scope of our | ||
// attribute value mode | ||
modes.CSS_NUMBER_MODE, | ||
{ | ||
@@ -515,3 +628,3 @@ className: 'selector-id', | ||
className: 'selector-pseudo', | ||
begin: '::(' + PSEUDO_ELEMENTS$1.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS$1.join('|') + ')' | ||
}, | ||
@@ -533,5 +646,6 @@ VARIABLE, | ||
{ | ||
begin: ':', | ||
end: ';', | ||
begin: /:/, | ||
end: /[;}{]/, | ||
contains: [ | ||
modes.BLOCK_COMMENT, | ||
VARIABLE, | ||
@@ -579,3 +693,4 @@ modes.HEXCOLOR, | ||
] | ||
} | ||
}, | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -585,2 +700,2 @@ }; | ||
export default scss; | ||
export { scss as default }; |
@@ -30,2 +30,2 @@ /* | ||
export default shell; | ||
export { shell as default }; |
@@ -135,2 +135,2 @@ /* | ||
export default smali; | ||
export { smali as default }; |
@@ -70,2 +70,2 @@ /* | ||
export default smalltalk; | ||
export { smalltalk as default }; |
@@ -81,2 +81,2 @@ /* | ||
export default sml; | ||
export { sml as default }; |
@@ -2509,2 +2509,2 @@ /* | ||
export default sqf; | ||
export { sqf as default }; |
@@ -1,59 +0,25 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
/* | ||
Language: SQL | ||
Website: https://en.wikipedia.org/wiki/SQL | ||
Category: common, database | ||
*/ | ||
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; | ||
} | ||
Goals: | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
SQL is intended to highlight basic/common SQL keywords and expressions | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
- If pretty much every single SQL server includes supports, then it's a canidate. | ||
- It is NOT intended to include tons of vendor specific keywords (Oracle, MySQL, | ||
PostgreSQL) although the list of data types is purposely a bit more expansive. | ||
- For more specific SQL grammars please see: | ||
- PostgreSQL and PL/pgSQL - core | ||
- T-SQL - https://github.com/highlightjs/highlightjs-tsql | ||
- sql_more (core) | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
Language: SQL | ||
Website: https://en.wikipedia.org/wiki/SQL | ||
Category: common, database | ||
*/ | ||
function sql(hljs) { | ||
const regex = hljs.regex; | ||
const COMMENT_MODE = hljs.COMMENT('--', '$'); | ||
@@ -653,3 +619,3 @@ const STRING = { | ||
const FUNCTION_CALL = { | ||
begin: concat(/\b/, either(...FUNCTIONS), /\s*\(/), | ||
begin: regex.concat(/\b/, regex.either(...FUNCTIONS), /\s*\(/), | ||
relevance: 0, | ||
@@ -691,3 +657,3 @@ keywords: { | ||
{ | ||
begin: either(...COMBOS), | ||
begin: regex.either(...COMBOS), | ||
relevance: 0, | ||
@@ -703,3 +669,3 @@ keywords: { | ||
className: "type", | ||
begin: either(...MULTI_WORD_TYPES) | ||
begin: regex.either(...MULTI_WORD_TYPES) | ||
}, | ||
@@ -718,2 +684,2 @@ FUNCTION_CALL, | ||
export default sql; | ||
export { sql as default }; |
@@ -555,2 +555,2 @@ /* | ||
export default stan; | ||
export { stan as default }; |
@@ -60,2 +60,2 @@ /* | ||
export default stata; | ||
export { stata as default }; |
@@ -70,2 +70,2 @@ /* | ||
export default step21; | ||
export { step21 as default }; |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -558,3 +668,3 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
className: 'selector-pseudo', | ||
begin: '&?::(' + PSEUDO_ELEMENTS.join('|') + ')' + LOOKAHEAD_TAG_END | ||
begin: '&?:(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' + LOOKAHEAD_TAG_END | ||
}, | ||
@@ -641,3 +751,4 @@ | ||
} | ||
} | ||
}, | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -647,2 +758,2 @@ }; | ||
export default stylus; | ||
export { stylus as default }; |
@@ -51,2 +51,2 @@ /* | ||
export default subunit; | ||
export { subunit as default }; |
@@ -34,2 +34,6 @@ /** | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
@@ -54,6 +58,7 @@ const opts = args[args.length - 1]; | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
@@ -880,2 +885,2 @@ } | ||
export default swift; | ||
export { swift as default }; |
@@ -56,2 +56,2 @@ /* | ||
export default taggerscript; | ||
export { taggerscript as default }; |
@@ -55,2 +55,2 @@ /* | ||
export default tap; | ||
export { tap as default }; |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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 optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -42,2 +9,3 @@ Language: Tcl | ||
function tcl(hljs) { | ||
const regex = hljs.regex; | ||
const TCL_IDENT = /[a-zA-Z_][a-zA-Z0-9_]*/; | ||
@@ -196,5 +164,5 @@ | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/\$/, | ||
optional(/::/), | ||
regex.optional(/::/), | ||
TCL_IDENT, | ||
@@ -227,2 +195,2 @@ '(::', | ||
export default tcl; | ||
export { tcl as default }; |
@@ -75,2 +75,2 @@ /* | ||
export default thrift; | ||
export { thrift as default }; |
@@ -171,2 +171,2 @@ /* | ||
export default tp; | ||
export { tp as default }; |
@@ -77,2 +77,2 @@ /* | ||
export default twig; | ||
export { twig as default }; |
@@ -54,40 +54,57 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -142,35 +159,2 @@ "InternalError", | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -185,2 +169,3 @@ Language: JavaScript | ||
function javascript(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -204,2 +189,4 @@ * Takes a string like "<Booger" and checks to see | ||
}; | ||
// to avoid some special cases inside isTrulyOpeningTag | ||
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; | ||
const XML_TAG = { | ||
@@ -215,11 +202,16 @@ begin: /<[A-Za-z0-9\\._:-]+/, | ||
const nextChar = match.input[afterMatchIndex]; | ||
// nested type? | ||
// HTML should not include another raw `<` inside a tag | ||
// But a type might: `<Array<Array<number>>`, etc. | ||
if (nextChar === "<") { | ||
if ( | ||
// HTML should not include another raw `<` inside a tag | ||
// nested type? | ||
// `<Array<Array<number>>`, etc. | ||
nextChar === "<" || | ||
// the , gives away that this is not HTML | ||
// `<T, A extends keyof T, V>` | ||
nextChar === ",") { | ||
response.ignoreMatch(); | ||
return; | ||
} | ||
// <something> | ||
// This is now either a tag or a type. | ||
// `<something>` | ||
// Quite possibly a tag, lets look for a matching closing tag... | ||
if (nextChar === ">") { | ||
@@ -232,2 +224,18 @@ // if we cannot find a matching closing tag, then we | ||
} | ||
// `<blah />` (self-closing) | ||
// handled by simpleSelfClosing rule | ||
// `<From extends string>` | ||
// technically this could be HTML, but it smells like a type | ||
let m; | ||
const afterMatch = match.input.substr(afterMatchIndex); | ||
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276 | ||
if ((m = afterMatch.match(/^\s+extends\s+/))) { | ||
if (m.index === 0) { | ||
response.ignoreMatch(); | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} | ||
} | ||
} | ||
@@ -368,3 +376,5 @@ }; | ||
NUMBER, | ||
hljs.REGEXP_MODE | ||
// This is intentional: | ||
// See https://github.com/highlightjs/highlight.js/issues/3288 | ||
// hljs.REGEXP_MODE | ||
]; | ||
@@ -405,2 +415,3 @@ SUBST.contains = SUBST_INTERNALS | ||
variants: [ | ||
// class Car extends vehicle | ||
{ | ||
@@ -410,20 +421,28 @@ match: [ | ||
/\s+/, | ||
IDENT_RE$1 | ||
IDENT_RE$1, | ||
/\s+/, | ||
/extends/, | ||
/\s+/, | ||
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class" | ||
3: "title.class", | ||
5: "keyword", | ||
7: "title.class.inherited" | ||
} | ||
}, | ||
// class Car | ||
{ | ||
match: [ | ||
/extends/, | ||
/class/, | ||
/\s+/, | ||
concat(IDENT_RE$1, "(", concat(/\./, IDENT_RE$1), ")*") | ||
IDENT_RE$1 | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class.inherited" | ||
3: "title.class" | ||
} | ||
} | ||
}, | ||
] | ||
@@ -434,3 +453,13 @@ }; | ||
relevance: 0, | ||
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/, | ||
match: | ||
regex.either( | ||
// Hard coded exceptions | ||
/\bJSON/, | ||
// Float32Array | ||
/\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/, | ||
// CSSFactory | ||
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+/, | ||
// BLAH | ||
// this will be flagged as a UPPER_CASE_CONSTANT instead | ||
), | ||
className: "title.class", | ||
@@ -487,7 +516,7 @@ keywords: { | ||
function noneOf(list) { | ||
return concat("(?!", list.join("|"), ")"); | ||
return regex.concat("(?!", list.join("|"), ")"); | ||
} | ||
const FUNCTION_CALL = { | ||
match: concat( | ||
match: regex.concat( | ||
/\b/, | ||
@@ -498,3 +527,3 @@ noneOf([ | ||
]), | ||
IDENT_RE$1, lookahead(/\(/)), | ||
IDENT_RE$1, regex.lookahead(/\(/)), | ||
className: "title.function", | ||
@@ -505,4 +534,4 @@ relevance: 0 | ||
const PROPERTY_ACCESS = { | ||
begin: concat(/\./, lookahead( | ||
concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
begin: regex.concat(/\./, regex.lookahead( | ||
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
)), | ||
@@ -548,3 +577,3 @@ end: IDENT_RE$1, | ||
/=\s*/, | ||
lookahead(FUNC_LEAD_IN_RE) | ||
regex.lookahead(FUNC_LEAD_IN_RE) | ||
], | ||
@@ -565,3 +594,3 @@ className: { | ||
// this will be extended by TypeScript | ||
exports: { PARAMS_CONTAINS }, | ||
exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, | ||
illegal: /#(?![$_A-z])/, | ||
@@ -585,3 +614,3 @@ contains: [ | ||
className: 'attr', | ||
begin: IDENT_RE$1 + lookahead(':'), | ||
begin: IDENT_RE$1 + regex.lookahead(':'), | ||
relevance: 0 | ||
@@ -641,2 +670,3 @@ }, | ||
{ begin: FRAGMENT.begin, end: FRAGMENT.end }, | ||
{ match: XML_SELF_CLOSING }, | ||
{ | ||
@@ -727,15 +757,5 @@ begin: XML_TAG.begin, | ||
function typescript(hljs) { | ||
const tsLanguage = javascript(hljs); | ||
const IDENT_RE$1 = IDENT_RE; | ||
const NAMESPACE = { | ||
beginKeywords: 'namespace', end: /\{/, excludeEnd: true | ||
}; | ||
const INTERFACE = { | ||
beginKeywords: 'interface', end: /\{/, excludeEnd: true, | ||
keywords: 'interface extends' | ||
}; | ||
const USE_STRICT = { | ||
className: 'meta', | ||
relevance: 10, | ||
begin: /^\s*['"]use strict['"]/ | ||
}; | ||
const TYPES = [ | ||
@@ -751,2 +771,27 @@ "any", | ||
]; | ||
const NAMESPACE = { | ||
beginKeywords: 'namespace', | ||
end: /\{/, | ||
excludeEnd: true, | ||
contains: [ | ||
tsLanguage.exports.CLASS_REFERENCE | ||
] | ||
}; | ||
const INTERFACE = { | ||
beginKeywords: 'interface', | ||
end: /\{/, | ||
excludeEnd: true, | ||
keywords: { | ||
keyword: 'interface extends', | ||
built_in: TYPES | ||
}, | ||
contains: [ | ||
tsLanguage.exports.CLASS_REFERENCE | ||
] | ||
}; | ||
const USE_STRICT = { | ||
className: 'meta', | ||
relevance: 10, | ||
begin: /^\s*['"]use strict['"]/ | ||
}; | ||
const TS_SPECIFIC_KEYWORDS = [ | ||
@@ -783,3 +828,2 @@ "type", | ||
const tsLanguage = javascript(hljs); | ||
@@ -813,2 +857,2 @@ // this should update anywhere keywords is used since | ||
export default typescript; | ||
export { typescript as default }; |
@@ -60,2 +60,2 @@ /* | ||
export default vala; | ||
export { vala as default }; |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,2 +11,3 @@ Language: Visual Basic .NET | ||
function vbnet(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -95,19 +45,19 @@ * Character Literal | ||
// #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date) | ||
begin: concat(/# */, either(YYYY_MM_DD, MM_DD_YYYY), / *#/) | ||
begin: regex.concat(/# */, regex.either(YYYY_MM_DD, MM_DD_YYYY), / *#/) | ||
}, | ||
{ | ||
// #H:mm[:ss]# (24h Time) | ||
begin: concat(/# */, TIME_24H, / *#/) | ||
begin: regex.concat(/# */, TIME_24H, / *#/) | ||
}, | ||
{ | ||
// #h[:mm[:ss]] A# (12h Time) | ||
begin: concat(/# */, TIME_12H, / *#/) | ||
begin: regex.concat(/# */, TIME_12H, / *#/) | ||
}, | ||
{ | ||
// date plus time | ||
begin: concat( | ||
begin: regex.concat( | ||
/# */, | ||
either(YYYY_MM_DD, MM_DD_YYYY), | ||
regex.either(YYYY_MM_DD, MM_DD_YYYY), | ||
/ +/, | ||
either(TIME_12H, TIME_24H), | ||
regex.either(TIME_12H, TIME_24H), | ||
/ *#/ | ||
@@ -230,2 +180,2 @@ ) | ||
export default vbnet; | ||
export { vbnet as default }; |
@@ -24,2 +24,2 @@ /* | ||
export default vbscriptHtml; | ||
export { vbscriptHtml as default }; |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -63,2 +12,3 @@ Language: VBScript | ||
function vbscript(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_IN_FUNCTIONS = [ | ||
@@ -174,3 +124,3 @@ "lcase", | ||
const BUILT_IN_CALL = { | ||
begin: concat(either(...BUILT_IN_FUNCTIONS), "\\s*\\("), | ||
begin: regex.concat(regex.either(...BUILT_IN_FUNCTIONS), "\\s*\\("), | ||
// relevance 0 because this is acting as a beginKeywords really | ||
@@ -276,2 +226,2 @@ relevance: 0, | ||
export default vbscript; | ||
export { vbscript as default }; |
@@ -10,62 +10,489 @@ /* | ||
function verilog(hljs) { | ||
const SV_KEYWORDS = { | ||
$pattern: /[\w\$]+/, | ||
keyword: | ||
'accept_on alias always always_comb always_ff always_latch and assert assign ' + | ||
'assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 ' + | ||
'byte case casex casez cell chandle checker class clocking cmos config const ' + | ||
'constraint context continue cover covergroup coverpoint cross deassign default ' + | ||
'defparam design disable dist do edge else end endcase endchecker endclass ' + | ||
'endclocking endconfig endfunction endgenerate endgroup endinterface endmodule ' + | ||
'endpackage endprimitive endprogram endproperty endspecify endsequence endtable ' + | ||
'endtask enum event eventually expect export extends extern final first_match for ' + | ||
'force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 ' + | ||
'if iff ifnone ignore_bins illegal_bins implements implies import incdir include ' + | ||
'initial inout input inside instance int integer interconnect interface intersect ' + | ||
'join join_any join_none large let liblist library local localparam logic longint ' + | ||
'macromodule matches medium modport module nand negedge nettype new nexttime nmos ' + | ||
'nor noshowcancelled not notif0 notif1 or output package packed parameter pmos ' + | ||
'posedge primitive priority program property protected pull0 pull1 pulldown pullup ' + | ||
'pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos ' + | ||
'real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran ' + | ||
'rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared ' + | ||
'sequence shortint shortreal showcancelled signed small soft solve specify specparam ' + | ||
'static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on ' + | ||
'sync_reject_on table tagged task this throughout time timeprecision timeunit tran ' + | ||
'tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 ' + | ||
'unsigned until until_with untyped use uwire var vectored virtual void wait wait_order ' + | ||
'wand weak weak0 weak1 while wildcard wire with within wor xnor xor', | ||
literal: | ||
'null', | ||
built_in: | ||
'$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale ' + | ||
'$bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat ' + | ||
'$realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson ' + | ||
'$assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff ' + | ||
'$assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk ' + | ||
'$fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control ' + | ||
'$coverage_get $coverage_save $set_coverage_db_name $rose $stable $past ' + | ||
'$rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display ' + | ||
'$coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename ' + | ||
'$unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow ' + | ||
'$floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning ' + | ||
'$dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh ' + | ||
'$tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random ' + | ||
'$dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson ' + | ||
'$dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array ' + | ||
'$async$nand$array $async$or$array $async$nor$array $sync$and$array ' + | ||
'$sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf ' + | ||
'$async$and$plane $async$nand$plane $async$or$plane $async$nor$plane ' + | ||
'$sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system ' + | ||
'$display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo ' + | ||
'$write $readmemb $readmemh $writememh $value$plusargs ' + | ||
'$dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit ' + | ||
'$writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb ' + | ||
'$dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall ' + | ||
'$dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo ' + | ||
'$fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh ' + | ||
'$swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb ' + | ||
'$fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat ' + | ||
'$sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror' | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
$pattern: /\$?[\w]+(\$[\w]+)*/, | ||
keyword: [ | ||
"accept_on", | ||
"alias", | ||
"always", | ||
"always_comb", | ||
"always_ff", | ||
"always_latch", | ||
"and", | ||
"assert", | ||
"assign", | ||
"assume", | ||
"automatic", | ||
"before", | ||
"begin", | ||
"bind", | ||
"bins", | ||
"binsof", | ||
"bit", | ||
"break", | ||
"buf|0", | ||
"bufif0", | ||
"bufif1", | ||
"byte", | ||
"case", | ||
"casex", | ||
"casez", | ||
"cell", | ||
"chandle", | ||
"checker", | ||
"class", | ||
"clocking", | ||
"cmos", | ||
"config", | ||
"const", | ||
"constraint", | ||
"context", | ||
"continue", | ||
"cover", | ||
"covergroup", | ||
"coverpoint", | ||
"cross", | ||
"deassign", | ||
"default", | ||
"defparam", | ||
"design", | ||
"disable", | ||
"dist", | ||
"do", | ||
"edge", | ||
"else", | ||
"end", | ||
"endcase", | ||
"endchecker", | ||
"endclass", | ||
"endclocking", | ||
"endconfig", | ||
"endfunction", | ||
"endgenerate", | ||
"endgroup", | ||
"endinterface", | ||
"endmodule", | ||
"endpackage", | ||
"endprimitive", | ||
"endprogram", | ||
"endproperty", | ||
"endspecify", | ||
"endsequence", | ||
"endtable", | ||
"endtask", | ||
"enum", | ||
"event", | ||
"eventually", | ||
"expect", | ||
"export", | ||
"extends", | ||
"extern", | ||
"final", | ||
"first_match", | ||
"for", | ||
"force", | ||
"foreach", | ||
"forever", | ||
"fork", | ||
"forkjoin", | ||
"function", | ||
"generate|5", | ||
"genvar", | ||
"global", | ||
"highz0", | ||
"highz1", | ||
"if", | ||
"iff", | ||
"ifnone", | ||
"ignore_bins", | ||
"illegal_bins", | ||
"implements", | ||
"implies", | ||
"import", | ||
"incdir", | ||
"include", | ||
"initial", | ||
"inout", | ||
"input", | ||
"inside", | ||
"instance", | ||
"int", | ||
"integer", | ||
"interconnect", | ||
"interface", | ||
"intersect", | ||
"join", | ||
"join_any", | ||
"join_none", | ||
"large", | ||
"let", | ||
"liblist", | ||
"library", | ||
"local", | ||
"localparam", | ||
"logic", | ||
"longint", | ||
"macromodule", | ||
"matches", | ||
"medium", | ||
"modport", | ||
"module", | ||
"nand", | ||
"negedge", | ||
"nettype", | ||
"new", | ||
"nexttime", | ||
"nmos", | ||
"nor", | ||
"noshowcancelled", | ||
"not", | ||
"notif0", | ||
"notif1", | ||
"or", | ||
"output", | ||
"package", | ||
"packed", | ||
"parameter", | ||
"pmos", | ||
"posedge", | ||
"primitive", | ||
"priority", | ||
"program", | ||
"property", | ||
"protected", | ||
"pull0", | ||
"pull1", | ||
"pulldown", | ||
"pullup", | ||
"pulsestyle_ondetect", | ||
"pulsestyle_onevent", | ||
"pure", | ||
"rand", | ||
"randc", | ||
"randcase", | ||
"randsequence", | ||
"rcmos", | ||
"real", | ||
"realtime", | ||
"ref", | ||
"reg", | ||
"reject_on", | ||
"release", | ||
"repeat", | ||
"restrict", | ||
"return", | ||
"rnmos", | ||
"rpmos", | ||
"rtran", | ||
"rtranif0", | ||
"rtranif1", | ||
"s_always", | ||
"s_eventually", | ||
"s_nexttime", | ||
"s_until", | ||
"s_until_with", | ||
"scalared", | ||
"sequence", | ||
"shortint", | ||
"shortreal", | ||
"showcancelled", | ||
"signed", | ||
"small", | ||
"soft", | ||
"solve", | ||
"specify", | ||
"specparam", | ||
"static", | ||
"string", | ||
"strong", | ||
"strong0", | ||
"strong1", | ||
"struct", | ||
"super", | ||
"supply0", | ||
"supply1", | ||
"sync_accept_on", | ||
"sync_reject_on", | ||
"table", | ||
"tagged", | ||
"task", | ||
"this", | ||
"throughout", | ||
"time", | ||
"timeprecision", | ||
"timeunit", | ||
"tran", | ||
"tranif0", | ||
"tranif1", | ||
"tri", | ||
"tri0", | ||
"tri1", | ||
"triand", | ||
"trior", | ||
"trireg", | ||
"type", | ||
"typedef", | ||
"union", | ||
"unique", | ||
"unique0", | ||
"unsigned", | ||
"until", | ||
"until_with", | ||
"untyped", | ||
"use", | ||
"uwire", | ||
"var", | ||
"vectored", | ||
"virtual", | ||
"void", | ||
"wait", | ||
"wait_order", | ||
"wand", | ||
"weak", | ||
"weak0", | ||
"weak1", | ||
"while", | ||
"wildcard", | ||
"wire", | ||
"with", | ||
"within", | ||
"wor", | ||
"xnor", | ||
"xor" | ||
], | ||
literal: [ 'null' ], | ||
built_in: [ | ||
"$finish", | ||
"$stop", | ||
"$exit", | ||
"$fatal", | ||
"$error", | ||
"$warning", | ||
"$info", | ||
"$realtime", | ||
"$time", | ||
"$printtimescale", | ||
"$bitstoreal", | ||
"$bitstoshortreal", | ||
"$itor", | ||
"$signed", | ||
"$cast", | ||
"$bits", | ||
"$stime", | ||
"$timeformat", | ||
"$realtobits", | ||
"$shortrealtobits", | ||
"$rtoi", | ||
"$unsigned", | ||
"$asserton", | ||
"$assertkill", | ||
"$assertpasson", | ||
"$assertfailon", | ||
"$assertnonvacuouson", | ||
"$assertoff", | ||
"$assertcontrol", | ||
"$assertpassoff", | ||
"$assertfailoff", | ||
"$assertvacuousoff", | ||
"$isunbounded", | ||
"$sampled", | ||
"$fell", | ||
"$changed", | ||
"$past_gclk", | ||
"$fell_gclk", | ||
"$changed_gclk", | ||
"$rising_gclk", | ||
"$steady_gclk", | ||
"$coverage_control", | ||
"$coverage_get", | ||
"$coverage_save", | ||
"$set_coverage_db_name", | ||
"$rose", | ||
"$stable", | ||
"$past", | ||
"$rose_gclk", | ||
"$stable_gclk", | ||
"$future_gclk", | ||
"$falling_gclk", | ||
"$changing_gclk", | ||
"$display", | ||
"$coverage_get_max", | ||
"$coverage_merge", | ||
"$get_coverage", | ||
"$load_coverage_db", | ||
"$typename", | ||
"$unpacked_dimensions", | ||
"$left", | ||
"$low", | ||
"$increment", | ||
"$clog2", | ||
"$ln", | ||
"$log10", | ||
"$exp", | ||
"$sqrt", | ||
"$pow", | ||
"$floor", | ||
"$ceil", | ||
"$sin", | ||
"$cos", | ||
"$tan", | ||
"$countbits", | ||
"$onehot", | ||
"$isunknown", | ||
"$fatal", | ||
"$warning", | ||
"$dimensions", | ||
"$right", | ||
"$high", | ||
"$size", | ||
"$asin", | ||
"$acos", | ||
"$atan", | ||
"$atan2", | ||
"$hypot", | ||
"$sinh", | ||
"$cosh", | ||
"$tanh", | ||
"$asinh", | ||
"$acosh", | ||
"$atanh", | ||
"$countones", | ||
"$onehot0", | ||
"$error", | ||
"$info", | ||
"$random", | ||
"$dist_chi_square", | ||
"$dist_erlang", | ||
"$dist_exponential", | ||
"$dist_normal", | ||
"$dist_poisson", | ||
"$dist_t", | ||
"$dist_uniform", | ||
"$q_initialize", | ||
"$q_remove", | ||
"$q_exam", | ||
"$async$and$array", | ||
"$async$nand$array", | ||
"$async$or$array", | ||
"$async$nor$array", | ||
"$sync$and$array", | ||
"$sync$nand$array", | ||
"$sync$or$array", | ||
"$sync$nor$array", | ||
"$q_add", | ||
"$q_full", | ||
"$psprintf", | ||
"$async$and$plane", | ||
"$async$nand$plane", | ||
"$async$or$plane", | ||
"$async$nor$plane", | ||
"$sync$and$plane", | ||
"$sync$nand$plane", | ||
"$sync$or$plane", | ||
"$sync$nor$plane", | ||
"$system", | ||
"$display", | ||
"$displayb", | ||
"$displayh", | ||
"$displayo", | ||
"$strobe", | ||
"$strobeb", | ||
"$strobeh", | ||
"$strobeo", | ||
"$write", | ||
"$readmemb", | ||
"$readmemh", | ||
"$writememh", | ||
"$value$plusargs", | ||
"$dumpvars", | ||
"$dumpon", | ||
"$dumplimit", | ||
"$dumpports", | ||
"$dumpportson", | ||
"$dumpportslimit", | ||
"$writeb", | ||
"$writeh", | ||
"$writeo", | ||
"$monitor", | ||
"$monitorb", | ||
"$monitorh", | ||
"$monitoro", | ||
"$writememb", | ||
"$dumpfile", | ||
"$dumpoff", | ||
"$dumpall", | ||
"$dumpflush", | ||
"$dumpportsoff", | ||
"$dumpportsall", | ||
"$dumpportsflush", | ||
"$fclose", | ||
"$fdisplay", | ||
"$fdisplayb", | ||
"$fdisplayh", | ||
"$fdisplayo", | ||
"$fstrobe", | ||
"$fstrobeb", | ||
"$fstrobeh", | ||
"$fstrobeo", | ||
"$swrite", | ||
"$swriteb", | ||
"$swriteh", | ||
"$swriteo", | ||
"$fscanf", | ||
"$fread", | ||
"$fseek", | ||
"$fflush", | ||
"$feof", | ||
"$fopen", | ||
"$fwrite", | ||
"$fwriteb", | ||
"$fwriteh", | ||
"$fwriteo", | ||
"$fmonitor", | ||
"$fmonitorb", | ||
"$fmonitorh", | ||
"$fmonitoro", | ||
"$sformat", | ||
"$sformatf", | ||
"$fgetc", | ||
"$ungetc", | ||
"$fgets", | ||
"$sscanf", | ||
"$rewind", | ||
"$ftell", | ||
"$ferror" | ||
] | ||
}; | ||
const BUILT_IN_CONSTANTS = [ | ||
"__FILE__", | ||
"__LINE__" | ||
]; | ||
const DIRECTIVES = [ | ||
"begin_keywords", | ||
"celldefine", | ||
"default_nettype", | ||
"default_decay_time", | ||
"default_trireg_strength", | ||
"define", | ||
"delay_mode_distributed", | ||
"delay_mode_path", | ||
"delay_mode_unit", | ||
"delay_mode_zero", | ||
"else", | ||
"elsif", | ||
"end_keywords", | ||
"endcelldefine", | ||
"endif", | ||
"ifdef", | ||
"ifndef", | ||
"include", | ||
"line", | ||
"nounconnected_drive", | ||
"pragma", | ||
"resetall", | ||
"timescale", | ||
"unconnected_drive", | ||
"undef", | ||
"undefineall" | ||
]; | ||
@@ -80,3 +507,3 @@ return { | ||
case_insensitive: false, | ||
keywords: SV_KEYWORDS, | ||
keywords: KEYWORDS, | ||
contains: [ | ||
@@ -87,13 +514,13 @@ hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
className: 'number', | ||
scope: 'number', | ||
contains: [ hljs.BACKSLASH_ESCAPE ], | ||
variants: [ | ||
{ | ||
begin: '\\b((\\d+\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)' | ||
begin: /\b((\d+'([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ | ||
}, | ||
{ | ||
begin: '\\B((\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)' | ||
begin: /\B(('([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ | ||
}, | ||
{ | ||
begin: '\\b([0-9_])+', | ||
{ // decimal | ||
begin: /\b[0-9][0-9_]*/, | ||
relevance: 0 | ||
@@ -105,3 +532,3 @@ } | ||
{ | ||
className: 'variable', | ||
scope: 'variable', | ||
variants: [ | ||
@@ -118,14 +545,11 @@ { | ||
{ | ||
className: 'meta', | ||
begin: '`', | ||
end: '$', | ||
keywords: { | ||
keyword: | ||
'define __FILE__ ' + | ||
'__LINE__ begin_keywords celldefine default_nettype define ' + | ||
'else elsif end_keywords endcelldefine endif ifdef ifndef ' + | ||
'include line nounconnected_drive pragma resetall timescale ' + | ||
'unconnected_drive undef undefineall' | ||
}, | ||
relevance: 0 | ||
scope: 'variable.constant', | ||
match: regex.concat(/`/, regex.either(...BUILT_IN_CONSTANTS)), | ||
}, | ||
{ | ||
scope: 'meta', | ||
begin: regex.concat(/`/, regex.either(...DIRECTIVES)), | ||
end: /$|\/\/|\/\*/, | ||
returnEnd: true, | ||
keywords: DIRECTIVES | ||
} | ||
@@ -136,2 +560,2 @@ ] | ||
export default verilog; | ||
export { verilog as default }; |
@@ -215,2 +215,2 @@ /* | ||
export default vhdl; | ||
export { vhdl as default }; |
@@ -129,2 +129,2 @@ /* | ||
export default vim; | ||
export { vim as default }; |
@@ -11,2 +11,3 @@ /* | ||
function wasm(hljs) { | ||
hljs.regex; | ||
const BLOCK_COMMENT = hljs.COMMENT(/\(;/, /;\)/); | ||
@@ -139,2 +140,2 @@ BLOCK_COMMENT.contains.push("self"); | ||
export default wasm; | ||
export { wasm as default }; |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -71,2 +12,3 @@ Language: Wren | ||
function wren(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[a-zA-Z]\w*/; | ||
@@ -140,10 +82,10 @@ const KEYWORDS = [ | ||
relevance: 0, | ||
match: concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE, /(?=\s*[({])/), | ||
match: regex.concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE, /(?=\s*[({])/), | ||
className: "title.function" | ||
}; | ||
const FUNCTION_DEFINITION = { | ||
match: concat( | ||
either( | ||
concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE), | ||
either(...OPERATORS) | ||
match: regex.concat( | ||
regex.either( | ||
regex.concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE), | ||
regex.either(...OPERATORS) | ||
), | ||
@@ -194,3 +136,3 @@ /(?=\s*\([^)]+\)\s*\{)/), | ||
relevance: 0, | ||
match: either(...OPERATORS), | ||
match: regex.either(...OPERATORS), | ||
className: "operator" | ||
@@ -207,3 +149,3 @@ }; | ||
className: "property", | ||
begin: concat(/\./, lookahead(IDENT_RE)), | ||
begin: regex.concat(/\./, regex.lookahead(IDENT_RE)), | ||
end: IDENT_RE, | ||
@@ -216,3 +158,3 @@ excludeBegin: true, | ||
relevance: 0, | ||
match: concat(/\b_/, IDENT_RE), | ||
match: regex.concat(/\b_/, IDENT_RE), | ||
scope: "variable" | ||
@@ -294,3 +236,3 @@ }; | ||
relevance: 0, | ||
match: concat( | ||
match: regex.concat( | ||
"\\b(?!", | ||
@@ -361,2 +303,2 @@ ALL_KWS.join("|"), | ||
export default wren; | ||
export { wren as default }; |
@@ -163,2 +163,2 @@ /* | ||
export default x86asm; | ||
export { x86asm as default }; |
@@ -207,2 +207,2 @@ /* | ||
export default xl; | ||
export { xl as default }; |
@@ -1,68 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -77,4 +10,5 @@ Language: HTML, XML | ||
function xml(hljs) { | ||
const regex = hljs.regex; | ||
// Element names can contain letters, digits, hyphens, underscores, and periods | ||
const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/); | ||
const TAG_NAME_RE = regex.concat(/[A-Z_]/, regex.optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/); | ||
const XML_IDENT_RE = /[A-Za-z0-9._:-]+/; | ||
@@ -255,5 +189,5 @@ const XML_ENTITIES = { | ||
className: 'tag', | ||
begin: concat( | ||
begin: regex.concat( | ||
/</, | ||
lookahead(concat( | ||
regex.lookahead(regex.concat( | ||
TAG_NAME_RE, | ||
@@ -263,3 +197,3 @@ // <tag/> | ||
// <tag ... | ||
either(/\/>/, />/, /\s/) | ||
regex.either(/\/>/, />/, /\s/) | ||
)) | ||
@@ -280,5 +214,5 @@ ), | ||
className: 'tag', | ||
begin: concat( | ||
begin: regex.concat( | ||
/<\//, | ||
lookahead(concat( | ||
regex.lookahead(regex.concat( | ||
TAG_NAME_RE, />/ | ||
@@ -304,2 +238,2 @@ )) | ||
export default xml; | ||
export { xml as default }; |
@@ -361,2 +361,2 @@ /* | ||
export default xquery; | ||
export { xquery as default }; |
@@ -206,2 +206,2 @@ /* | ||
export default yaml; | ||
export { yaml as default }; |
@@ -140,2 +140,2 @@ /* | ||
export default zephir; | ||
export { zephir as default }; |
@@ -53,2 +53,6 @@ /** | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
@@ -73,6 +77,7 @@ const opts = args[args.length - 1]; | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
@@ -82,3 +87,3 @@ } | ||
/** | ||
* @param {RegExp} re | ||
* @param {RegExp | string} re | ||
* @returns {number} | ||
@@ -85,0 +90,0 @@ */ |
@@ -38,2 +38,4 @@ var hljs = require('./core'); | ||
hljs.HighlightJS = hljs | ||
hljs.default = hljs | ||
module.exports = hljs; |
@@ -195,2 +195,4 @@ var hljs = require('./core'); | ||
hljs.HighlightJS = hljs | ||
hljs.default = hljs | ||
module.exports = hljs; |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Augmented Backus-Naur Form | ||
function abnf(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT = /^[a-zA-Z][a-zA-Z0-9-]*/; | ||
@@ -81,3 +57,3 @@ | ||
scope: "attribute", | ||
match: concat(IDENT, /(?=\s*=)/) | ||
match: regex.concat(IDENT, /(?=\s*=)/) | ||
}; | ||
@@ -84,0 +60,0 @@ |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,3 +11,4 @@ Language: Apache Access Log | ||
/** @type LanguageFn */ | ||
function accesslog(_hljs) { | ||
function accesslog(hljs) { | ||
const regex = hljs.regex; | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods | ||
@@ -94,3 +44,3 @@ const HTTP_VERBS = [ | ||
className: 'string', | ||
begin: concat(/"/, either(...HTTP_VERBS)), | ||
begin: regex.concat(/"/, regex.either(...HTTP_VERBS)), | ||
end: /"/, | ||
@@ -97,0 +47,0 @@ keywords: HTTP_VERBS, |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,6 +10,7 @@ Language: ActionScript | ||
function actionscript(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/; | ||
const PKG_NAME_RE = concat( | ||
const PKG_NAME_RE = regex.concat( | ||
IDENT_RE, | ||
concat("(\\.", IDENT_RE, ")*") | ||
regex.concat("(\\.", IDENT_RE, ")*") | ||
); | ||
@@ -169,3 +145,3 @@ const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/; | ||
}, | ||
{ begin: concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) } | ||
{ begin: regex.concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) } | ||
] | ||
@@ -172,0 +148,0 @@ }, |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,2 +11,3 @@ Language: AppleScript | ||
function applescript(hljs) { | ||
const regex = hljs.regex; | ||
const STRING = hljs.inherit( | ||
@@ -167,5 +117,5 @@ hljs.QUOTE_STRING_MODE, { | ||
className: 'built_in', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
either(...BUILT_IN_PATTERNS), | ||
regex.either(...BUILT_IN_PATTERNS), | ||
/\b/ | ||
@@ -185,5 +135,5 @@ ) | ||
className: 'keyword', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
either(...KEYWORD_PATTERNS), | ||
regex.either(...KEYWORD_PATTERNS), | ||
/\b/ | ||
@@ -190,0 +140,0 @@ ) |
@@ -1,42 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -50,2 +9,3 @@ Language: C++ | ||
function cPlusPlus(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -66,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -144,7 +104,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -173,3 +133,2 @@ // https://en.cppreference.com/w/cpp/keyword | ||
'concept', | ||
'const', | ||
'const_cast|10', | ||
@@ -218,5 +177,3 @@ 'consteval', | ||
'return', | ||
'signed', | ||
'sizeof', | ||
'static', | ||
'static_assert', | ||
@@ -239,3 +196,2 @@ 'static_cast|10', | ||
'union', | ||
'unsigned', | ||
'using', | ||
@@ -246,3 +202,3 @@ 'virtual', | ||
'xor', | ||
'xor_eq,' | ||
'xor_eq' | ||
]; | ||
@@ -263,3 +219,7 @@ | ||
'void', | ||
'wchar_t' | ||
'wchar_t', | ||
'unsigned', | ||
'signed', | ||
'const', | ||
'static' | ||
]; | ||
@@ -456,3 +416,3 @@ | ||
}, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
@@ -462,5 +422,6 @@ /(?!decltype)/, | ||
/(?!for)/, | ||
/(?!switch)/, | ||
/(?!while)/, | ||
hljs.IDENT_RE, | ||
lookahead(/(<[^<>]+>|)\s*\(/)) | ||
regex.lookahead(/(<[^<>]+>|)\s*\(/)) | ||
}; | ||
@@ -467,0 +428,0 @@ |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: AsciiDoc | ||
function asciidoc(hljs) { | ||
const regex = hljs.regex; | ||
const HORIZONTAL_RULE = { | ||
@@ -74,3 +50,3 @@ begin: '^\'{3,}[ \\t]*$', | ||
className: 'strong', | ||
begin: concat( | ||
begin: regex.concat( | ||
/\*\*/, | ||
@@ -105,3 +81,3 @@ /((\*(?!\*)|\\[^\n]|[^*\n\\])+\n)+/, | ||
className: 'emphasis', | ||
begin: concat( | ||
begin: regex.concat( | ||
/__/, | ||
@@ -108,0 +84,0 @@ /((_(?!_)|\\[^\n]|[^_\n\\])+\n)+/, |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: AspectJ | ||
function aspectj(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = [ | ||
@@ -189,3 +165,3 @@ "false", | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
returnBegin: true, | ||
@@ -206,3 +182,3 @@ contains: [ hljs.UNDERSCORE_TITLE_MODE ] | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
keywords: KEYWORDS.concat(SHORTKEYS), | ||
@@ -229,3 +205,3 @@ relevance: 0 | ||
{ | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/), | ||
returnBegin: true, | ||
@@ -232,0 +208,0 @@ relevance: 0, |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: Bash | ||
function bash(hljs) { | ||
const regex = hljs.regex; | ||
const VAR = {}; | ||
@@ -52,3 +28,3 @@ const BRACED_VAR = { | ||
variants: [ | ||
{begin: concat(/\$[\w\d#@][\w\d_]*/, | ||
{begin: regex.concat(/\$[\w\d#@][\w\d_]*/, | ||
// negative look-ahead tries to avoid matching patterns that are not | ||
@@ -150,2 +126,230 @@ // Perl at all like $ident$, @ident@, etc. | ||
// to consume paths to prevent keyword matches inside them | ||
const PATH_MODE = { | ||
match: /(\/[a-z._-]+)+/ | ||
}; | ||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html | ||
const SHELL_BUILT_INS = [ | ||
"break", | ||
"cd", | ||
"continue", | ||
"eval", | ||
"exec", | ||
"exit", | ||
"export", | ||
"getopts", | ||
"hash", | ||
"pwd", | ||
"readonly", | ||
"return", | ||
"shift", | ||
"test", | ||
"times", | ||
"trap", | ||
"umask", | ||
"unset" | ||
]; | ||
const BASH_BUILT_INS = [ | ||
"alias", | ||
"bind", | ||
"builtin", | ||
"caller", | ||
"command", | ||
"declare", | ||
"echo", | ||
"enable", | ||
"help", | ||
"let", | ||
"local", | ||
"logout", | ||
"mapfile", | ||
"printf", | ||
"read", | ||
"readarray", | ||
"source", | ||
"type", | ||
"typeset", | ||
"ulimit", | ||
"unalias" | ||
]; | ||
const ZSH_BUILT_INS = [ | ||
"autoload", | ||
"bg", | ||
"bindkey", | ||
"bye", | ||
"cap", | ||
"chdir", | ||
"clone", | ||
"comparguments", | ||
"compcall", | ||
"compctl", | ||
"compdescribe", | ||
"compfiles", | ||
"compgroups", | ||
"compquote", | ||
"comptags", | ||
"comptry", | ||
"compvalues", | ||
"dirs", | ||
"disable", | ||
"disown", | ||
"echotc", | ||
"echoti", | ||
"emulate", | ||
"fc", | ||
"fg", | ||
"float", | ||
"functions", | ||
"getcap", | ||
"getln", | ||
"history", | ||
"integer", | ||
"jobs", | ||
"kill", | ||
"limit", | ||
"log", | ||
"noglob", | ||
"popd", | ||
"print", | ||
"pushd", | ||
"pushln", | ||
"rehash", | ||
"sched", | ||
"setcap", | ||
"setopt", | ||
"stat", | ||
"suspend", | ||
"ttyctl", | ||
"unfunction", | ||
"unhash", | ||
"unlimit", | ||
"unsetopt", | ||
"vared", | ||
"wait", | ||
"whence", | ||
"where", | ||
"which", | ||
"zcompile", | ||
"zformat", | ||
"zftp", | ||
"zle", | ||
"zmodload", | ||
"zparseopts", | ||
"zprof", | ||
"zpty", | ||
"zregexparse", | ||
"zsocket", | ||
"zstyle", | ||
"ztcp" | ||
]; | ||
const GNU_CORE_UTILS = [ | ||
"chcon", | ||
"chgrp", | ||
"chown", | ||
"chmod", | ||
"cp", | ||
"dd", | ||
"df", | ||
"dir", | ||
"dircolors", | ||
"ln", | ||
"ls", | ||
"mkdir", | ||
"mkfifo", | ||
"mknod", | ||
"mktemp", | ||
"mv", | ||
"realpath", | ||
"rm", | ||
"rmdir", | ||
"shred", | ||
"sync", | ||
"touch", | ||
"truncate", | ||
"vdir", | ||
"b2sum", | ||
"base32", | ||
"base64", | ||
"cat", | ||
"cksum", | ||
"comm", | ||
"csplit", | ||
"cut", | ||
"expand", | ||
"fmt", | ||
"fold", | ||
"head", | ||
"join", | ||
"md5sum", | ||
"nl", | ||
"numfmt", | ||
"od", | ||
"paste", | ||
"ptx", | ||
"pr", | ||
"sha1sum", | ||
"sha224sum", | ||
"sha256sum", | ||
"sha384sum", | ||
"sha512sum", | ||
"shuf", | ||
"sort", | ||
"split", | ||
"sum", | ||
"tac", | ||
"tail", | ||
"tr", | ||
"tsort", | ||
"unexpand", | ||
"uniq", | ||
"wc", | ||
"arch", | ||
"basename", | ||
"chroot", | ||
"date", | ||
"dirname", | ||
"du", | ||
"echo", | ||
"env", | ||
"expr", | ||
"factor", | ||
// "false", // keyword literal already | ||
"groups", | ||
"hostid", | ||
"id", | ||
"link", | ||
"logname", | ||
"nice", | ||
"nohup", | ||
"nproc", | ||
"pathchk", | ||
"pinky", | ||
"printenv", | ||
"printf", | ||
"pwd", | ||
"readlink", | ||
"runcon", | ||
"seq", | ||
"sleep", | ||
"stat", | ||
"stdbuf", | ||
"stty", | ||
"tee", | ||
"test", | ||
"timeout", | ||
// "true", // keyword literal already | ||
"tty", | ||
"uname", | ||
"unlink", | ||
"uptime", | ||
"users", | ||
"who", | ||
"whoami", | ||
"yes" | ||
]; | ||
return { | ||
@@ -158,19 +362,11 @@ name: 'Bash', | ||
literal: LITERALS, | ||
built_in: | ||
// Shell built-ins | ||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html | ||
'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' + | ||
'trap umask unset ' + | ||
// Bash built-ins | ||
'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' + | ||
'read readarray source type typeset ulimit unalias ' + | ||
built_in:[ | ||
...SHELL_BUILT_INS, | ||
...BASH_BUILT_INS, | ||
// Shell modifiers | ||
'set shopt ' + | ||
// Zsh built-ins | ||
'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' + | ||
'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' + | ||
'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' + | ||
'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' + | ||
'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' + | ||
'zpty zregexparse zsocket zstyle ztcp' | ||
"set", | ||
"shopt", | ||
...ZSH_BUILT_INS, | ||
...GNU_CORE_UTILS | ||
] | ||
}, | ||
@@ -184,2 +380,3 @@ contains: [ | ||
HERE_DOC, | ||
PATH_MODE, | ||
QUOTE_STRING, | ||
@@ -186,0 +383,0 @@ ESCAPED_QUOTE, |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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 optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -42,2 +9,3 @@ Language: C | ||
function c(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -58,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -141,7 +109,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -153,3 +121,2 @@ const C_KEYWORDS = [ | ||
"case", | ||
"const", | ||
"continue", | ||
@@ -170,3 +137,2 @@ "default", | ||
"sizeof", | ||
"static", | ||
"struct", | ||
@@ -211,2 +177,5 @@ "switch", | ||
"_Decimal128", | ||
// modifiers | ||
"const", | ||
"static", | ||
// aliases | ||
@@ -213,0 +182,0 @@ "complex", |
@@ -53,40 +53,57 @@ const KEYWORDS = [ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -93,0 +110,0 @@ "InternalError", |
@@ -1,42 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -50,2 +9,3 @@ Language: C++ | ||
function cpp(hljs) { | ||
const regex = hljs.regex; | ||
// added for historic reasons because `hljs.C_LINE_COMMENT_MODE` does | ||
@@ -66,4 +26,4 @@ // not include such support nor can we be sure all the grammars depending | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
regex.optional(NAMESPACE_RE) + | ||
'[a-zA-Z_]\\w*' + regex.optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
@@ -144,7 +104,7 @@ | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
begin: regex.optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
const FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
const FUNCTION_TITLE = regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
@@ -173,3 +133,2 @@ // https://en.cppreference.com/w/cpp/keyword | ||
'concept', | ||
'const', | ||
'const_cast|10', | ||
@@ -218,5 +177,3 @@ 'consteval', | ||
'return', | ||
'signed', | ||
'sizeof', | ||
'static', | ||
'static_assert', | ||
@@ -239,3 +196,2 @@ 'static_cast|10', | ||
'union', | ||
'unsigned', | ||
'using', | ||
@@ -246,3 +202,3 @@ 'virtual', | ||
'xor', | ||
'xor_eq,' | ||
'xor_eq' | ||
]; | ||
@@ -263,3 +219,7 @@ | ||
'void', | ||
'wchar_t' | ||
'wchar_t', | ||
'unsigned', | ||
'signed', | ||
'const', | ||
'static' | ||
]; | ||
@@ -456,3 +416,3 @@ | ||
}, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
@@ -462,5 +422,6 @@ /(?!decltype)/, | ||
/(?!for)/, | ||
/(?!switch)/, | ||
/(?!while)/, | ||
hljs.IDENT_RE, | ||
lookahead(/(<[^<>]+>|)\s*\(/)) | ||
regex.lookahead(/(<[^<>]+>|)\s*\(/)) | ||
}; | ||
@@ -467,0 +428,0 @@ |
@@ -399,3 +399,3 @@ /* | ||
className: 'function', | ||
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', | ||
begin: '(' + TYPE_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', | ||
returnBegin: true, | ||
@@ -412,3 +412,3 @@ end: /\s*[{;=]/, | ||
{ | ||
begin: hljs.IDENT_RE + '\\s*(<.+>\\s*)?\\(', | ||
begin: hljs.IDENT_RE + '\\s*(<[^=]+>\\s*)?\\(', | ||
returnBegin: true, | ||
@@ -422,2 +422,5 @@ contains: [ | ||
{ | ||
match: /\(\)/ | ||
}, | ||
{ | ||
className: 'params', | ||
@@ -424,0 +427,0 @@ begin: /\(/, |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -462,35 +572,2 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -504,7 +581,4 @@ Language: CSS | ||
function css(hljs) { | ||
const regex = hljs.regex; | ||
const modes = MODES(hljs); | ||
const FUNCTION_DISPATCH = { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}; | ||
const VENDOR_PREFIX = { | ||
@@ -534,3 +608,3 @@ begin: /-(webkit|moz|ms|o)-(?=[a-z])/ | ||
contains: [ | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
modes.BLOCK_COMMENT, | ||
VENDOR_PREFIX, | ||
@@ -558,3 +632,3 @@ // to recognize keyframe 40% etc which are outside the scope of our | ||
{ | ||
begin: '::(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
} | ||
@@ -576,5 +650,6 @@ ] | ||
{ | ||
begin: ':', | ||
end: '[;}]', | ||
begin: /:/, | ||
end: /[;}{]/, | ||
contains: [ | ||
modes.BLOCK_COMMENT, | ||
modes.HEXCOLOR, | ||
@@ -605,7 +680,7 @@ modes.IMPORTANT, | ||
}, | ||
FUNCTION_DISPATCH | ||
modes.FUNCTION_DISPATCH | ||
] | ||
}, | ||
{ | ||
begin: lookahead(/@/), | ||
begin: regex.lookahead(/@/), | ||
end: '[{;]', | ||
@@ -612,0 +687,0 @@ relevance: 0, |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -53,2 +11,3 @@ Language: Diff | ||
function diff(hljs) { | ||
const regex = hljs.regex; | ||
return { | ||
@@ -61,3 +20,3 @@ name: 'Diff', | ||
relevance: 10, | ||
match: either( | ||
match: regex.either( | ||
/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, | ||
@@ -72,3 +31,3 @@ /^\*\*\* +\d+,\d+ +\*\*\*\*$/, | ||
{ | ||
begin: either( | ||
begin: regex.either( | ||
/Index: /, | ||
@@ -75,0 +34,0 @@ /^index/, |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: Elixir | ||
function elixir(hljs) { | ||
const regex = hljs.regex; | ||
const ELIXIR_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_.]*(!|\\?)?'; | ||
@@ -142,3 +118,3 @@ const ELIXIR_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; | ||
scope: "char.escape", | ||
begin: concat(/\\/, end), | ||
begin: regex.concat(/\\/, end), | ||
relevance: 0 | ||
@@ -178,3 +154,3 @@ }; | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
end: regex.concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ | ||
@@ -192,3 +168,3 @@ escapeSigilEnd(x.end), | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
end: regex.concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ escapeSigilEnd(x.end) ] | ||
@@ -195,0 +171,0 @@ }) |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Erlang REPL | ||
function erlangRepl(hljs) { | ||
const regex = hljs.regex; | ||
return { | ||
@@ -60,3 +36,3 @@ name: 'Erlang REPL', | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/\?(::)?/, | ||
@@ -63,0 +39,0 @@ /([A-Z]\w*)/, // at least one identifier |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Fortran | ||
function fortran(hljs) { | ||
const regex = hljs.regex; | ||
const PARAMS = { | ||
@@ -64,9 +40,9 @@ className: 'params', | ||
{ | ||
begin: concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
} | ||
@@ -73,0 +49,0 @@ ], |
@@ -0,5 +1,69 @@ | ||
/** | ||
* @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; | ||
} | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* Any of the passed expresssions may match | ||
* | ||
* Creates a huge this | this | that | that match | ||
* @param {(RegExp | string)[] } args | ||
* @returns {string} | ||
*/ | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
Language: F# | ||
Author: Jonas Follesø <jonas@follesoe.no> | ||
Contributors: Troy Kershaw <hello@troykershaw.com>, Henrik Feldt <henrik@haf.se> | ||
Contributors: Troy Kershaw <hello@troykershaw.com>, Henrik Feldt <henrik@haf.se>, Melvyn Laïly <melvyn.laily@gmail.com> | ||
Website: https://docs.microsoft.com/en-us/dotnet/fsharp/ | ||
@@ -11,12 +75,2 @@ Category: functional | ||
function fsharp(hljs) { | ||
const TYPEPARAM = { | ||
begin: '<', | ||
end: '>', | ||
contains: [ | ||
hljs.inherit(hljs.TITLE_MODE, { | ||
begin: /'[a-zA-Z0-9_]+/ | ||
}) | ||
] | ||
}; | ||
const KEYWORDS = [ | ||
@@ -41,4 +95,5 @@ "abstract", | ||
"extern", | ||
"false", | ||
// "false", // literal | ||
"finally", | ||
"fixed", | ||
"for", | ||
@@ -62,3 +117,4 @@ "fun", | ||
"new", | ||
"null", | ||
// "not", // built_in | ||
// "null", // literal | ||
"of", | ||
@@ -72,3 +128,2 @@ "open", | ||
"return", | ||
"sig", | ||
"static", | ||
@@ -78,3 +133,3 @@ "struct", | ||
"to", | ||
"true", | ||
// "true", // literal | ||
"try", | ||
@@ -92,61 +147,362 @@ "type", | ||
return { | ||
name: 'F#', | ||
aliases: ['fs'], | ||
keywords: KEYWORDS, | ||
illegal: /\/\*/, | ||
const BANG_KEYWORD_MODE = { | ||
// monad builder keywords (matches before non-bang keywords) | ||
scope: 'keyword', | ||
match: /\b(yield|return|let|do|match|use)!/ | ||
}; | ||
const PREPROCESSOR_KEYWORDS = [ | ||
"if", | ||
"else", | ||
"endif", | ||
"line", | ||
"nowarn", | ||
"light", | ||
"r", | ||
"i", | ||
"I", | ||
"load", | ||
"time", | ||
"help", | ||
"quit" | ||
]; | ||
const LITERALS = [ | ||
"true", | ||
"false", | ||
"null", | ||
"Some", | ||
"None", | ||
"Ok", | ||
"Error", | ||
"infinity", | ||
"infinityf", | ||
"nan", | ||
"nanf" | ||
]; | ||
const SPECIAL_IDENTIFIERS = [ | ||
"__LINE__", | ||
"__SOURCE_DIRECTORY__", | ||
"__SOURCE_FILE__" | ||
]; | ||
const TYPES = [ | ||
// basic types | ||
"bool", | ||
"byte", | ||
"sbyte", | ||
"int8", | ||
"int16", | ||
"int32", | ||
"uint8", | ||
"uint16", | ||
"uint32", | ||
"int", | ||
"uint", | ||
"int64", | ||
"uint64", | ||
"nativeint", | ||
"unativeint", | ||
"decimal", | ||
"float", | ||
"double", | ||
"float32", | ||
"single", | ||
"char", | ||
"string", | ||
"unit", | ||
"bigint", | ||
// other native types or lowercase aliases | ||
"option", | ||
"voption", | ||
"list", | ||
"array", | ||
"seq", | ||
"byref", | ||
"exn", | ||
"inref", | ||
"nativeptr", | ||
"obj", | ||
"outref", | ||
"voidptr" | ||
]; | ||
const BUILTINS = [ | ||
// Somewhat arbitrary list of builtin functions and values. | ||
// Most of them are declared in Microsoft.FSharp.Core | ||
// I tried to stay relevant by adding only the most idiomatic | ||
// and most used symbols that are not already declared as types. | ||
"not", | ||
"ref", | ||
"raise", | ||
"reraise", | ||
"dict", | ||
"readOnlyDict", | ||
"set", | ||
"enum", | ||
"sizeof", | ||
"typeof", | ||
"typedefof", | ||
"nameof", | ||
"nullArg", | ||
"invalidArg", | ||
"invalidOp", | ||
"id", | ||
"fst", | ||
"snd", | ||
"ignore", | ||
"lock", | ||
"using", | ||
"box", | ||
"unbox", | ||
"tryUnbox", | ||
"printf", | ||
"printfn", | ||
"sprintf", | ||
"eprintf", | ||
"eprintfn", | ||
"fprintf", | ||
"fprintfn", | ||
"failwith", | ||
"failwithf" | ||
]; | ||
const ALL_KEYWORDS = { | ||
type: TYPES, | ||
keyword: KEYWORDS, | ||
literal: LITERALS, | ||
built_in: BUILTINS, | ||
'variable.constant': SPECIAL_IDENTIFIERS | ||
}; | ||
// (* potentially multi-line Meta Language style comment *) | ||
const ML_COMMENT = | ||
hljs.COMMENT(/\(\*(?!\))/, /\*\)/, { | ||
contains: ["self"] | ||
}); | ||
// Either a multi-line (* Meta Language style comment *) or a single line // C style comment. | ||
const COMMENT = { | ||
variants: [ | ||
ML_COMMENT, | ||
hljs.C_LINE_COMMENT_MODE, | ||
] | ||
}; | ||
// 'a or ^a | ||
const GENERIC_TYPE_SYMBOL = { | ||
match: concat(/('|\^)/, hljs.UNDERSCORE_IDENT_RE), | ||
scope: 'symbol', | ||
relevance: 0 | ||
}; | ||
const COMPUTATION_EXPRESSION = { | ||
// computation expressions: | ||
scope: 'computation-expression', | ||
match: /\b[_a-z]\w*(?=\s*\{)/ | ||
}; | ||
const PREPROCESSOR = { | ||
// preprocessor directives and fsi commands: | ||
begin: [ | ||
/^\s*/, | ||
concat(/#/, either(...PREPROCESSOR_KEYWORDS)), | ||
/\b/ | ||
], | ||
beginScope: { 2: 'meta' }, | ||
end: lookahead(/\s|$/) | ||
}; | ||
// TODO: this definition is missing support for type suffixes and octal notation. | ||
// BUG: range operator without any space is wrongly interpreted as a single number (e.g. 1..10 ) | ||
const NUMBER = { | ||
variants: [ | ||
hljs.BINARY_NUMBER_MODE, | ||
hljs.C_NUMBER_MODE | ||
] | ||
}; | ||
// All the following string definitions are potentially multi-line. | ||
// BUG: these definitions are missing support for byte strings (suffixed with B) | ||
// "..." | ||
const QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /"/, | ||
end: /"/, | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE | ||
] | ||
}; | ||
// @"..." | ||
const VERBATIM_STRING = { | ||
scope: 'string', | ||
begin: /@"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
// monad builder keywords (matches before non-bang kws) | ||
className: 'keyword', | ||
begin: /\b(yield|return|let|do)!/ | ||
match: /""/ // escaped " | ||
}, | ||
hljs.BACKSLASH_ESCAPE | ||
] | ||
}; | ||
// """...""" | ||
const TRIPLE_QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /"""/, | ||
end: /"""/, | ||
relevance: 2 | ||
}; | ||
const SUBST = { | ||
scope: 'subst', | ||
begin: /\{/, | ||
end: /\}/, | ||
keywords: ALL_KEYWORDS | ||
}; | ||
// $"...{1+1}..." | ||
const INTERPOLATED_STRING = { | ||
scope: 'string', | ||
begin: /\$"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
className: 'string', | ||
begin: '@"', | ||
end: '"', | ||
contains: [ | ||
{ | ||
begin: '""' | ||
} | ||
] | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
className: 'string', | ||
begin: '"""', | ||
end: '"""' | ||
match: /\}\}/ // escaped } | ||
}, | ||
hljs.COMMENT('\\(\\*(\\s)', '\\*\\)', { | ||
contains: ["self"] | ||
}), | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
}; | ||
// $@"...{1+1}..." | ||
const INTERPOLATED_VERBATIM_STRING = { | ||
scope: 'string', | ||
begin: /(\$@|@\$)"/, | ||
end: /"/, | ||
contains: [ | ||
{ | ||
className: 'class', | ||
beginKeywords: 'type', | ||
end: '\\(|=|$', | ||
excludeEnd: true, | ||
contains: [ | ||
hljs.UNDERSCORE_TITLE_MODE, | ||
TYPEPARAM | ||
] | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
className: 'meta', | ||
begin: '\\[<', | ||
end: '>\\]', | ||
relevance: 10 | ||
match: /\}\}/ // escaped } | ||
}, | ||
{ | ||
className: 'symbol', | ||
begin: '\\B(\'[A-Za-z])\\b', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
match: /""/ | ||
}, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.inherit(hljs.QUOTE_STRING_MODE, { | ||
illegal: null | ||
}), | ||
hljs.C_NUMBER_MODE | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
}; | ||
// $"""...{1+1}...""" | ||
const INTERPOLATED_TRIPLE_QUOTED_STRING = { | ||
scope: 'string', | ||
begin: /\$"""/, | ||
end: /"""/, | ||
contains: [ | ||
{ | ||
match: /\{\{/ // escaped { | ||
}, | ||
{ | ||
match: /\}\}/ // escaped } | ||
}, | ||
SUBST | ||
], | ||
relevance: 2 | ||
}; | ||
// '.' | ||
const CHAR_LITERAL = { | ||
scope: 'string', | ||
match: concat( | ||
/'/, | ||
either( | ||
/[^\\']/, // either a single non escaped char... | ||
/\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8})/ // ...or an escape sequence | ||
), | ||
/'/ | ||
) | ||
}; | ||
// F# allows a lot of things inside string placeholders. | ||
// Things that don't currently seem allowed by the compiler: types definition, attributes usage. | ||
// (Strictly speaking, some of the followings are only allowed inside triple quoted interpolated strings...) | ||
SUBST.contains = [ | ||
INTERPOLATED_VERBATIM_STRING, | ||
INTERPOLATED_STRING, | ||
VERBATIM_STRING, | ||
QUOTED_STRING, | ||
CHAR_LITERAL, | ||
BANG_KEYWORD_MODE, | ||
COMMENT, | ||
COMPUTATION_EXPRESSION, | ||
PREPROCESSOR, | ||
NUMBER, | ||
GENERIC_TYPE_SYMBOL | ||
]; | ||
const STRING = { | ||
variants: [ | ||
INTERPOLATED_TRIPLE_QUOTED_STRING, | ||
INTERPOLATED_VERBATIM_STRING, | ||
INTERPOLATED_STRING, | ||
TRIPLE_QUOTED_STRING, | ||
VERBATIM_STRING, | ||
QUOTED_STRING, | ||
CHAR_LITERAL | ||
] | ||
}; | ||
return { | ||
name: 'F#', | ||
aliases: [ | ||
'fs', | ||
'f#' | ||
], | ||
keywords: ALL_KEYWORDS, | ||
illegal: /\/\*/, | ||
classNameAliases: { | ||
'computation-expression': 'keyword' | ||
}, | ||
contains: [ | ||
BANG_KEYWORD_MODE, | ||
STRING, | ||
COMMENT, | ||
{ | ||
// type MyType<'a> = ... | ||
begin: [ | ||
/type/, | ||
/\s+/, | ||
hljs.UNDERSCORE_IDENT_RE | ||
], | ||
beginScope: { | ||
1: 'keyword', | ||
3: 'title.class' | ||
}, | ||
end: lookahead(/\(|=|$/), | ||
contains: [ | ||
GENERIC_TYPE_SYMBOL | ||
] | ||
}, | ||
{ | ||
// [<Attributes("")>] | ||
scope: 'meta', | ||
begin: /^\s*\[</, | ||
excludeBegin: true, | ||
end: lookahead(/>\]/), | ||
relevance: 2, | ||
contains: [ | ||
{ | ||
scope: 'string', | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
NUMBER | ||
] | ||
}, | ||
COMPUTATION_EXPRESSION, | ||
PREPROCESSOR, | ||
NUMBER, | ||
GENERIC_TYPE_SYMBOL | ||
] | ||
}; | ||
} | ||
module.exports = fsharp; |
@@ -1,36 +0,13 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
/* | ||
Language: GAMS | ||
Author: Stefan Bechert <stefan.bechert@gmx.net> | ||
Contributors: Oleg Efimov <efimovov@gmail.com>, Mikko Kouhia <mikko.kouhia@iki.fi> | ||
Description: The General Algebraic Modeling System language | ||
Website: https://www.gams.com | ||
Category: scientific | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function anyNumberOfTimes(re) { | ||
return concat('(?:', re, ')*'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/** @type LanguageFn */ | ||
function gams(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
@@ -119,6 +96,6 @@ keyword: | ||
// one comment word, then possibly more | ||
begin: concat( | ||
begin: regex.concat( | ||
COMMENT_WORD, | ||
// [ ] because \s would be too broad (matching newlines) | ||
anyNumberOfTimes(concat(/[ ]+/, COMMENT_WORD)) | ||
regex.anyNumberOfTimes(regex.concat(/[ ]+/, COMMENT_WORD)) | ||
), | ||
@@ -125,0 +102,0 @@ relevance: 0 |
@@ -34,28 +34,3 @@ /* | ||
]; | ||
const KWS = [ | ||
"break", | ||
"default", | ||
"func", | ||
"interface", | ||
"select", | ||
"case", | ||
"map", | ||
"struct", | ||
"chan", | ||
"else", | ||
"goto", | ||
"package", | ||
"switch", | ||
"const", | ||
"fallthrough", | ||
"if", | ||
"range", | ||
"type", | ||
"continue", | ||
"for", | ||
"import", | ||
"return", | ||
"var", | ||
"go", | ||
"defer", | ||
const TYPES = [ | ||
"bool", | ||
@@ -65,2 +40,3 @@ "byte", | ||
"complex128", | ||
"error", | ||
"float32", | ||
@@ -82,4 +58,32 @@ "float64", | ||
]; | ||
const KWS = [ | ||
"break", | ||
"case", | ||
"chan", | ||
"const", | ||
"continue", | ||
"default", | ||
"defer", | ||
"else", | ||
"fallthrough", | ||
"for", | ||
"func", | ||
"go", | ||
"goto", | ||
"if", | ||
"import", | ||
"interface", | ||
"map", | ||
"package", | ||
"range", | ||
"return", | ||
"select", | ||
"struct", | ||
"switch", | ||
"type", | ||
"var", | ||
]; | ||
const KEYWORDS = { | ||
keyword: KWS, | ||
type: TYPES, | ||
literal: LITERALS, | ||
@@ -131,2 +135,3 @@ built_in: BUILT_INS | ||
end: /\)/, | ||
endsParent: true, | ||
keywords: KEYWORDS, | ||
@@ -133,0 +138,0 @@ illegal: /["']/ |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -47,2 +14,3 @@ Language: Groovy | ||
function groovy(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = '[A-Za-z0-9_$]+'; | ||
@@ -165,3 +133,3 @@ const COMMENT = variants([ | ||
className: 'symbol', | ||
begin: '^[ \t]*' + lookahead(IDENT_RE + ':'), | ||
begin: '^[ \t]*' + regex.lookahead(IDENT_RE + ':'), | ||
excludeBegin: true, | ||
@@ -168,0 +136,0 @@ end: IDENT_RE + ':', |
@@ -1,68 +0,1 @@ | ||
/** | ||
* @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 anyNumberOfTimes(re) { | ||
return concat('(?:', re, ')*'); | ||
} | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -78,2 +11,3 @@ Language: Handlebars | ||
function handlebars(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_INS = { | ||
@@ -133,3 +67,3 @@ $pattern: /[\w.\/]+/, | ||
const PATH_DELIMITER_REGEX = /(\.|\/)/; | ||
const ANY_ID = either( | ||
const ANY_ID = regex.either( | ||
DOUBLE_QUOTED_ID_REGEX, | ||
@@ -141,6 +75,6 @@ SINGLE_QUOTED_ID_REGEX, | ||
const IDENTIFIER_REGEX = concat( | ||
optional(/\.|\.\/|\//), // relative or absolute path | ||
const IDENTIFIER_REGEX = regex.concat( | ||
regex.optional(/\.|\.\/|\//), // relative or absolute path | ||
ANY_ID, | ||
anyNumberOfTimes(concat( | ||
regex.anyNumberOfTimes(regex.concat( | ||
PATH_DELIMITER_REGEX, | ||
@@ -152,3 +86,3 @@ ANY_ID | ||
// identifier followed by a equal-sign (without the equal sign) | ||
const HASH_PARAM_REGEX = concat( | ||
const HASH_PARAM_REGEX = regex.concat( | ||
'(', | ||
@@ -155,0 +89,0 @@ BRACKET_QUOTED_ID_REGEX, '|', |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: HTTP | ||
function http(hljs) { | ||
const regex = hljs.regex; | ||
const VERSION = 'HTTP/(2|1\\.[01])'; | ||
@@ -40,3 +16,3 @@ const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/; | ||
className: 'attribute', | ||
begin: concat('^', HEADER_NAME, '(?=\\:\\s)'), | ||
begin: regex.concat('^', HEADER_NAME, '(?=\\:\\s)'), | ||
starts: { | ||
@@ -43,0 +19,0 @@ contains: [ |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -69,2 +10,3 @@ Language: TOML, also INI | ||
function ini(hljs) { | ||
const regex = hljs.regex; | ||
const NUMBERS = { | ||
@@ -149,8 +91,8 @@ className: 'number', | ||
const QUOTED_KEY_SINGLE_QUOTE = /'[^']*'/; | ||
const ANY_KEY = either( | ||
const ANY_KEY = regex.either( | ||
BARE_KEY, QUOTED_KEY_DOUBLE_QUOTE, QUOTED_KEY_SINGLE_QUOTE | ||
); | ||
const DOTTED_KEY = concat( | ||
const DOTTED_KEY = regex.concat( | ||
ANY_KEY, '(\\s*\\.\\s*', ANY_KEY, ')*', | ||
lookahead(/\s*=\s*[^#\s]/) | ||
regex.lookahead(/\s*=\s*[^#\s]/) | ||
); | ||
@@ -157,0 +99,0 @@ |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -36,2 +11,3 @@ Language: IRPF90 | ||
function irpf90(hljs) { | ||
const regex = hljs.regex; | ||
const PARAMS = { | ||
@@ -50,9 +26,9 @@ className: 'params', | ||
{ | ||
begin: concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
}, | ||
{ | ||
begin: concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
begin: regex.concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) | ||
} | ||
@@ -59,0 +35,0 @@ ], |
@@ -64,2 +64,3 @@ // https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.10 | ||
function java(hljs) { | ||
hljs.regex; | ||
const JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; | ||
@@ -194,2 +195,8 @@ const GENERIC_IDENT_RE = JAVA_IDENT_RE + | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
begin: /"""/, | ||
end: /"""/, | ||
className: "string", | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
}, | ||
hljs.APOS_STRING_MODE, | ||
@@ -196,0 +203,0 @@ hljs.QUOTE_STRING_MODE, |
@@ -54,40 +54,57 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -142,35 +159,2 @@ "InternalError", | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -185,2 +169,3 @@ Language: JavaScript | ||
function javascript(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -204,2 +189,4 @@ * Takes a string like "<Booger" and checks to see | ||
}; | ||
// to avoid some special cases inside isTrulyOpeningTag | ||
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; | ||
const XML_TAG = { | ||
@@ -215,11 +202,16 @@ begin: /<[A-Za-z0-9\\._:-]+/, | ||
const nextChar = match.input[afterMatchIndex]; | ||
// nested type? | ||
// HTML should not include another raw `<` inside a tag | ||
// But a type might: `<Array<Array<number>>`, etc. | ||
if (nextChar === "<") { | ||
if ( | ||
// HTML should not include another raw `<` inside a tag | ||
// nested type? | ||
// `<Array<Array<number>>`, etc. | ||
nextChar === "<" || | ||
// the , gives away that this is not HTML | ||
// `<T, A extends keyof T, V>` | ||
nextChar === ",") { | ||
response.ignoreMatch(); | ||
return; | ||
} | ||
// <something> | ||
// This is now either a tag or a type. | ||
// `<something>` | ||
// Quite possibly a tag, lets look for a matching closing tag... | ||
if (nextChar === ">") { | ||
@@ -232,2 +224,18 @@ // if we cannot find a matching closing tag, then we | ||
} | ||
// `<blah />` (self-closing) | ||
// handled by simpleSelfClosing rule | ||
// `<From extends string>` | ||
// technically this could be HTML, but it smells like a type | ||
let m; | ||
const afterMatch = match.input.substr(afterMatchIndex); | ||
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276 | ||
if ((m = afterMatch.match(/^\s+extends\s+/))) { | ||
if (m.index === 0) { | ||
response.ignoreMatch(); | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} | ||
} | ||
} | ||
@@ -368,3 +376,5 @@ }; | ||
NUMBER, | ||
hljs.REGEXP_MODE | ||
// This is intentional: | ||
// See https://github.com/highlightjs/highlight.js/issues/3288 | ||
// hljs.REGEXP_MODE | ||
]; | ||
@@ -405,2 +415,3 @@ SUBST.contains = SUBST_INTERNALS | ||
variants: [ | ||
// class Car extends vehicle | ||
{ | ||
@@ -410,20 +421,28 @@ match: [ | ||
/\s+/, | ||
IDENT_RE$1 | ||
IDENT_RE$1, | ||
/\s+/, | ||
/extends/, | ||
/\s+/, | ||
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class" | ||
3: "title.class", | ||
5: "keyword", | ||
7: "title.class.inherited" | ||
} | ||
}, | ||
// class Car | ||
{ | ||
match: [ | ||
/extends/, | ||
/class/, | ||
/\s+/, | ||
concat(IDENT_RE$1, "(", concat(/\./, IDENT_RE$1), ")*") | ||
IDENT_RE$1 | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class.inherited" | ||
3: "title.class" | ||
} | ||
} | ||
}, | ||
] | ||
@@ -434,3 +453,13 @@ }; | ||
relevance: 0, | ||
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/, | ||
match: | ||
regex.either( | ||
// Hard coded exceptions | ||
/\bJSON/, | ||
// Float32Array | ||
/\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/, | ||
// CSSFactory | ||
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+/, | ||
// BLAH | ||
// this will be flagged as a UPPER_CASE_CONSTANT instead | ||
), | ||
className: "title.class", | ||
@@ -487,7 +516,7 @@ keywords: { | ||
function noneOf(list) { | ||
return concat("(?!", list.join("|"), ")"); | ||
return regex.concat("(?!", list.join("|"), ")"); | ||
} | ||
const FUNCTION_CALL = { | ||
match: concat( | ||
match: regex.concat( | ||
/\b/, | ||
@@ -498,3 +527,3 @@ noneOf([ | ||
]), | ||
IDENT_RE$1, lookahead(/\(/)), | ||
IDENT_RE$1, regex.lookahead(/\(/)), | ||
className: "title.function", | ||
@@ -505,4 +534,4 @@ relevance: 0 | ||
const PROPERTY_ACCESS = { | ||
begin: concat(/\./, lookahead( | ||
concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
begin: regex.concat(/\./, regex.lookahead( | ||
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
)), | ||
@@ -548,3 +577,3 @@ end: IDENT_RE$1, | ||
/=\s*/, | ||
lookahead(FUNC_LEAD_IN_RE) | ||
regex.lookahead(FUNC_LEAD_IN_RE) | ||
], | ||
@@ -565,3 +594,3 @@ className: { | ||
// this will be extended by TypeScript | ||
exports: { PARAMS_CONTAINS }, | ||
exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, | ||
illegal: /#(?![$_A-z])/, | ||
@@ -585,3 +614,3 @@ contains: [ | ||
className: 'attr', | ||
begin: IDENT_RE$1 + lookahead(':'), | ||
begin: IDENT_RE$1 + regex.lookahead(':'), | ||
relevance: 0 | ||
@@ -641,2 +670,3 @@ }, | ||
{ begin: FRAGMENT.begin, end: FRAGMENT.end }, | ||
{ match: XML_SELF_CLOSING }, | ||
{ | ||
@@ -643,0 +673,0 @@ begin: XML_TAG.begin, |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -52,3 +10,4 @@ Language: LaTeX | ||
function latex(hljs) { | ||
const KNOWN_CONTROL_WORDS = either(...[ | ||
const regex = hljs.regex; | ||
const KNOWN_CONTROL_WORDS = regex.either(...[ | ||
'(?:NeedsTeXFormat|RequirePackage|GetIdInfo)', | ||
@@ -55,0 +14,0 @@ 'Provides(?:Expl)?(?:Package|Class|File)', |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -652,3 +762,4 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
}, | ||
IDENT_MODE('selector-tag', INTERP_IDENT_RE + '%?', 0), // '%' for more consistent coloring of @keyframes "tags" | ||
modes.CSS_NUMBER_MODE, | ||
IDENT_MODE('selector-tag', INTERP_IDENT_RE, 0), | ||
IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE), | ||
@@ -664,3 +775,3 @@ IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE, 0), | ||
className: 'selector-pseudo', | ||
begin: '::(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' | ||
}, | ||
@@ -675,3 +786,4 @@ { | ||
begin: '!important' | ||
} // eat !important after mixin call or it will be colored as tag | ||
}, // eat !important after mixin call or it will be colored as tag | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -678,0 +790,0 @@ }; |
@@ -53,40 +53,57 @@ const KEYWORDS = [ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -93,0 +110,0 @@ "InternalError", |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: LLVM IR | ||
function llvm(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /([-a-zA-Z$._][\w$.-]*)/; | ||
@@ -71,3 +47,3 @@ const TYPE = { | ||
variants: [ | ||
{ begin: concat(/%/, IDENT_RE) }, | ||
{ begin: regex.concat(/%/, IDENT_RE) }, | ||
{ begin: /%\d+/ }, | ||
@@ -80,6 +56,6 @@ { begin: /#\d+/ }, | ||
variants: [ | ||
{ begin: concat(/@/, IDENT_RE) }, | ||
{ begin: regex.concat(/@/, IDENT_RE) }, | ||
{ begin: /@\d+/ }, | ||
{ begin: concat(/!/, IDENT_RE) }, | ||
{ begin: concat(/!\d+/, IDENT_RE) }, | ||
{ begin: regex.concat(/!/, IDENT_RE) }, | ||
{ begin: regex.concat(/!\d+/, IDENT_RE) }, | ||
// https://llvm.org/docs/LangRef.html#namedmetadatastructure | ||
@@ -86,0 +62,0 @@ // obviously a single digit can also be used in this fashion |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -35,2 +10,3 @@ Language: Markdown | ||
function markdown(hljs) { | ||
const regex = hljs.regex; | ||
const INLINE_HTML = { | ||
@@ -122,3 +98,3 @@ begin: /<\/?[A-Za-z_]/, | ||
{ | ||
begin: concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/), | ||
begin: regex.concat(/\[.+?\]\(/, URL_SCHEME, /:\/\/.*?\)/), | ||
relevance: 2 | ||
@@ -125,0 +101,0 @@ }, |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,2 +11,3 @@ Language: Nginx config | ||
function nginx(hljs) { | ||
const regex = hljs.regex; | ||
const VAR = { | ||
@@ -55,3 +23,3 @@ className: 'variable', | ||
{ | ||
begin: concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) | ||
begin: regex.concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) | ||
} | ||
@@ -179,7 +147,7 @@ ] | ||
className: 'section', | ||
begin: concat(hljs.UNDERSCORE_IDENT_RE + lookahead(/\s+\{/)), | ||
begin: regex.concat(hljs.UNDERSCORE_IDENT_RE + regex.lookahead(/\s+\{/)), | ||
relevance: 0 | ||
}, | ||
{ | ||
begin: lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'), | ||
begin: regex.lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'), | ||
end: ';|\\{', | ||
@@ -186,0 +154,0 @@ contains: [ |
@@ -0,1 +1,57 @@ | ||
/** | ||
* @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; | ||
} | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* Any of the passed expresssions may match | ||
* | ||
* Creates a huge this | this | that | that match | ||
* @param {(RegExp | string)[] } args | ||
* @returns {string} | ||
*/ | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -9,5 +65,142 @@ Language: NSIS | ||
function nsis(hljs) { | ||
const LANGUAGE_CONSTANTS = [ | ||
"ADMINTOOLS", | ||
"APPDATA", | ||
"CDBURN_AREA", | ||
"CMDLINE", | ||
"COMMONFILES32", | ||
"COMMONFILES64", | ||
"COMMONFILES", | ||
"COOKIES", | ||
"DESKTOP", | ||
"DOCUMENTS", | ||
"EXEDIR", | ||
"EXEFILE", | ||
"EXEPATH", | ||
"FAVORITES", | ||
"FONTS", | ||
"HISTORY", | ||
"HWNDPARENT", | ||
"INSTDIR", | ||
"INTERNET_CACHE", | ||
"LANGUAGE", | ||
"LOCALAPPDATA", | ||
"MUSIC", | ||
"NETHOOD", | ||
"OUTDIR", | ||
"PICTURES", | ||
"PLUGINSDIR", | ||
"PRINTHOOD", | ||
"PROFILE", | ||
"PROGRAMFILES32", | ||
"PROGRAMFILES64", | ||
"PROGRAMFILES", | ||
"QUICKLAUNCH", | ||
"RECENT", | ||
"RESOURCES_LOCALIZED", | ||
"RESOURCES", | ||
"SENDTO", | ||
"SMPROGRAMS", | ||
"SMSTARTUP", | ||
"STARTMENU", | ||
"SYSDIR", | ||
"TEMP", | ||
"TEMPLATES", | ||
"VIDEOS", | ||
"WINDIR" | ||
]; | ||
const PARAM_NAMES = [ | ||
"ARCHIVE", | ||
"FILE_ATTRIBUTE_ARCHIVE", | ||
"FILE_ATTRIBUTE_NORMAL", | ||
"FILE_ATTRIBUTE_OFFLINE", | ||
"FILE_ATTRIBUTE_READONLY", | ||
"FILE_ATTRIBUTE_SYSTEM", | ||
"FILE_ATTRIBUTE_TEMPORARY", | ||
"HKCR", | ||
"HKCU", | ||
"HKDD", | ||
"HKEY_CLASSES_ROOT", | ||
"HKEY_CURRENT_CONFIG", | ||
"HKEY_CURRENT_USER", | ||
"HKEY_DYN_DATA", | ||
"HKEY_LOCAL_MACHINE", | ||
"HKEY_PERFORMANCE_DATA", | ||
"HKEY_USERS", | ||
"HKLM", | ||
"HKPD", | ||
"HKU", | ||
"IDABORT", | ||
"IDCANCEL", | ||
"IDIGNORE", | ||
"IDNO", | ||
"IDOK", | ||
"IDRETRY", | ||
"IDYES", | ||
"MB_ABORTRETRYIGNORE", | ||
"MB_DEFBUTTON1", | ||
"MB_DEFBUTTON2", | ||
"MB_DEFBUTTON3", | ||
"MB_DEFBUTTON4", | ||
"MB_ICONEXCLAMATION", | ||
"MB_ICONINFORMATION", | ||
"MB_ICONQUESTION", | ||
"MB_ICONSTOP", | ||
"MB_OK", | ||
"MB_OKCANCEL", | ||
"MB_RETRYCANCEL", | ||
"MB_RIGHT", | ||
"MB_RTLREADING", | ||
"MB_SETFOREGROUND", | ||
"MB_TOPMOST", | ||
"MB_USERICON", | ||
"MB_YESNO", | ||
"NORMAL", | ||
"OFFLINE", | ||
"READONLY", | ||
"SHCTX", | ||
"SHELL_CONTEXT", | ||
"SYSTEM|TEMPORARY", | ||
]; | ||
const COMPILER_FLAGS = [ | ||
"addincludedir", | ||
"addplugindir", | ||
"appendfile", | ||
"cd", | ||
"define", | ||
"delfile", | ||
"echo", | ||
"else", | ||
"endif", | ||
"error", | ||
"execute", | ||
"finalize", | ||
"getdllversion", | ||
"gettlbversion", | ||
"if", | ||
"ifdef", | ||
"ifmacrodef", | ||
"ifmacrondef", | ||
"ifndef", | ||
"include", | ||
"insertmacro", | ||
"macro", | ||
"macroend", | ||
"makensis", | ||
"packhdr", | ||
"searchparse", | ||
"searchreplace", | ||
"system", | ||
"tempfile", | ||
"undef", | ||
"uninstfinalize", | ||
"verbose", | ||
"warning", | ||
]; | ||
const CONSTANTS = { | ||
className: 'variable', | ||
begin: /\$(ADMINTOOLS|APPDATA|CDBURN_AREA|CMDLINE|COMMONFILES32|COMMONFILES64|COMMONFILES|COOKIES|DESKTOP|DOCUMENTS|EXEDIR|EXEFILE|EXEPATH|FAVORITES|FONTS|HISTORY|HWNDPARENT|INSTDIR|INTERNET_CACHE|LANGUAGE|LOCALAPPDATA|MUSIC|NETHOOD|OUTDIR|PICTURES|PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES32|PROGRAMFILES64|PROGRAMFILES|QUICKLAUNCH|RECENT|RESOURCES_LOCALIZED|RESOURCES|SENDTO|SMPROGRAMS|SMSTARTUP|STARTMENU|SYSDIR|TEMP|TEMPLATES|VIDEOS|WINDIR)/ | ||
className: 'variable.constant', | ||
begin: concat(/\$/, either(...LANGUAGE_CONSTANTS)) | ||
}; | ||
@@ -37,3 +230,3 @@ | ||
className: 'params', | ||
begin: '(ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)' | ||
begin: either(...PARAM_NAMES) | ||
}; | ||
@@ -44,3 +237,6 @@ | ||
className: 'keyword', | ||
begin: /!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversion|gettlbversion|if|ifdef|ifmacrodef|ifmacrondef|ifndef|include|insertmacro|macro|macroend|makensis|packhdr|searchparse|searchreplace|system|tempfile|undef|verbose|warning)/ | ||
begin: concat( | ||
/!/, | ||
either(...COMPILER_FLAGS) | ||
) | ||
}; | ||
@@ -56,3 +252,3 @@ | ||
// plug::ins | ||
className: 'class', | ||
className: 'title.function', | ||
begin: /\w+::\w+/ | ||
@@ -87,10 +283,291 @@ }; | ||
const KEYWORDS = [ | ||
"Abort", | ||
"AddBrandingImage", | ||
"AddSize", | ||
"AllowRootDirInstall", | ||
"AllowSkipFiles", | ||
"AutoCloseWindow", | ||
"BGFont", | ||
"BGGradient", | ||
"BrandingText", | ||
"BringToFront", | ||
"Call", | ||
"CallInstDLL", | ||
"Caption", | ||
"ChangeUI", | ||
"CheckBitmap", | ||
"ClearErrors", | ||
"CompletedText", | ||
"ComponentText", | ||
"CopyFiles", | ||
"CRCCheck", | ||
"CreateDirectory", | ||
"CreateFont", | ||
"CreateShortCut", | ||
"Delete", | ||
"DeleteINISec", | ||
"DeleteINIStr", | ||
"DeleteRegKey", | ||
"DeleteRegValue", | ||
"DetailPrint", | ||
"DetailsButtonText", | ||
"DirText", | ||
"DirVar", | ||
"DirVerify", | ||
"EnableWindow", | ||
"EnumRegKey", | ||
"EnumRegValue", | ||
"Exch", | ||
"Exec", | ||
"ExecShell", | ||
"ExecShellWait", | ||
"ExecWait", | ||
"ExpandEnvStrings", | ||
"File", | ||
"FileBufSize", | ||
"FileClose", | ||
"FileErrorText", | ||
"FileOpen", | ||
"FileRead", | ||
"FileReadByte", | ||
"FileReadUTF16LE", | ||
"FileReadWord", | ||
"FileWriteUTF16LE", | ||
"FileSeek", | ||
"FileWrite", | ||
"FileWriteByte", | ||
"FileWriteWord", | ||
"FindClose", | ||
"FindFirst", | ||
"FindNext", | ||
"FindWindow", | ||
"FlushINI", | ||
"GetCurInstType", | ||
"GetCurrentAddress", | ||
"GetDlgItem", | ||
"GetDLLVersion", | ||
"GetDLLVersionLocal", | ||
"GetErrorLevel", | ||
"GetFileTime", | ||
"GetFileTimeLocal", | ||
"GetFullPathName", | ||
"GetFunctionAddress", | ||
"GetInstDirError", | ||
"GetKnownFolderPath", | ||
"GetLabelAddress", | ||
"GetTempFileName", | ||
"GetWinVer", | ||
"Goto", | ||
"HideWindow", | ||
"Icon", | ||
"IfAbort", | ||
"IfErrors", | ||
"IfFileExists", | ||
"IfRebootFlag", | ||
"IfRtlLanguage", | ||
"IfShellVarContextAll", | ||
"IfSilent", | ||
"InitPluginsDir", | ||
"InstallButtonText", | ||
"InstallColors", | ||
"InstallDir", | ||
"InstallDirRegKey", | ||
"InstProgressFlags", | ||
"InstType", | ||
"InstTypeGetText", | ||
"InstTypeSetText", | ||
"Int64Cmp", | ||
"Int64CmpU", | ||
"Int64Fmt", | ||
"IntCmp", | ||
"IntCmpU", | ||
"IntFmt", | ||
"IntOp", | ||
"IntPtrCmp", | ||
"IntPtrCmpU", | ||
"IntPtrOp", | ||
"IsWindow", | ||
"LangString", | ||
"LicenseBkColor", | ||
"LicenseData", | ||
"LicenseForceSelection", | ||
"LicenseLangString", | ||
"LicenseText", | ||
"LoadAndSetImage", | ||
"LoadLanguageFile", | ||
"LockWindow", | ||
"LogSet", | ||
"LogText", | ||
"ManifestDPIAware", | ||
"ManifestLongPathAware", | ||
"ManifestMaxVersionTested", | ||
"ManifestSupportedOS", | ||
"MessageBox", | ||
"MiscButtonText", | ||
"Name", | ||
"Nop", | ||
"OutFile", | ||
"Page", | ||
"PageCallbacks", | ||
"PEAddResource", | ||
"PEDllCharacteristics", | ||
"PERemoveResource", | ||
"PESubsysVer", | ||
"Pop", | ||
"Push", | ||
"Quit", | ||
"ReadEnvStr", | ||
"ReadINIStr", | ||
"ReadRegDWORD", | ||
"ReadRegStr", | ||
"Reboot", | ||
"RegDLL", | ||
"Rename", | ||
"RequestExecutionLevel", | ||
"ReserveFile", | ||
"Return", | ||
"RMDir", | ||
"SearchPath", | ||
"SectionGetFlags", | ||
"SectionGetInstTypes", | ||
"SectionGetSize", | ||
"SectionGetText", | ||
"SectionIn", | ||
"SectionSetFlags", | ||
"SectionSetInstTypes", | ||
"SectionSetSize", | ||
"SectionSetText", | ||
"SendMessage", | ||
"SetAutoClose", | ||
"SetBrandingImage", | ||
"SetCompress", | ||
"SetCompressor", | ||
"SetCompressorDictSize", | ||
"SetCtlColors", | ||
"SetCurInstType", | ||
"SetDatablockOptimize", | ||
"SetDateSave", | ||
"SetDetailsPrint", | ||
"SetDetailsView", | ||
"SetErrorLevel", | ||
"SetErrors", | ||
"SetFileAttributes", | ||
"SetFont", | ||
"SetOutPath", | ||
"SetOverwrite", | ||
"SetRebootFlag", | ||
"SetRegView", | ||
"SetShellVarContext", | ||
"SetSilent", | ||
"ShowInstDetails", | ||
"ShowUninstDetails", | ||
"ShowWindow", | ||
"SilentInstall", | ||
"SilentUnInstall", | ||
"Sleep", | ||
"SpaceTexts", | ||
"StrCmp", | ||
"StrCmpS", | ||
"StrCpy", | ||
"StrLen", | ||
"SubCaption", | ||
"Unicode", | ||
"UninstallButtonText", | ||
"UninstallCaption", | ||
"UninstallIcon", | ||
"UninstallSubCaption", | ||
"UninstallText", | ||
"UninstPage", | ||
"UnRegDLL", | ||
"Var", | ||
"VIAddVersionKey", | ||
"VIFileVersion", | ||
"VIProductVersion", | ||
"WindowIcon", | ||
"WriteINIStr", | ||
"WriteRegBin", | ||
"WriteRegDWORD", | ||
"WriteRegExpandStr", | ||
"WriteRegMultiStr", | ||
"WriteRegNone", | ||
"WriteRegStr", | ||
"WriteUninstaller", | ||
"XPStyle" | ||
]; | ||
const LITERALS = [ | ||
"admin", | ||
"all", | ||
"auto", | ||
"both", | ||
"bottom", | ||
"bzip2", | ||
"colored", | ||
"components", | ||
"current", | ||
"custom", | ||
"directory", | ||
"false", | ||
"force", | ||
"hide", | ||
"highest", | ||
"ifdiff", | ||
"ifnewer", | ||
"instfiles", | ||
"lastused", | ||
"leave", | ||
"left", | ||
"license", | ||
"listonly", | ||
"lzma", | ||
"nevershow", | ||
"none", | ||
"normal", | ||
"notset", | ||
"off", | ||
"on", | ||
"open", | ||
"print", | ||
"right", | ||
"show", | ||
"silent", | ||
"silentlog", | ||
"smooth", | ||
"textonly", | ||
"top", | ||
"true", | ||
"try", | ||
"un.components", | ||
"un.custom", | ||
"un.directory", | ||
"un.instfiles", | ||
"un.license", | ||
"uninstConfirm", | ||
"user", | ||
"Win10", | ||
"Win7", | ||
"Win8", | ||
"WinVista", | ||
"zlib" | ||
]; | ||
const FUNCTION_DEF = { | ||
match: [ | ||
/Function/, | ||
/\s+/, | ||
concat(/(\.)?/, hljs.IDENT_RE) | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.function" | ||
} | ||
}; | ||
return { | ||
name: 'NSIS', | ||
case_insensitive: false, | ||
case_insensitive: true, | ||
keywords: { | ||
keyword: | ||
'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ChangeUI CheckBitmap ClearErrors CompletedText ComponentText CopyFiles CRCCheck CreateDirectory CreateFont CreateShortCut Delete DeleteINISec DeleteINIStr DeleteRegKey DeleteRegValue DetailPrint DetailsButtonText DirText DirVar DirVerify EnableWindow EnumRegKey EnumRegValue Exch Exec ExecShell ExecShellWait ExecWait ExpandEnvStrings File FileBufSize FileClose FileErrorText FileOpen FileRead FileReadByte FileReadUTF16LE FileReadWord FileWriteUTF16LE FileSeek FileWrite FileWriteByte FileWriteWord FindClose FindFirst FindNext FindWindow FlushINI GetCurInstType GetCurrentAddress GetDlgItem GetDLLVersion GetDLLVersionLocal GetErrorLevel GetFileTime GetFileTimeLocal GetFullPathName GetFunctionAddress GetInstDirError GetKnownFolderPath GetLabelAddress GetTempFileName Goto HideWindow Icon IfAbort IfErrors IfFileExists IfRebootFlag IfRtlLanguage IfShellVarContextAll IfSilent InitPluginsDir InstallButtonText InstallColors InstallDir InstallDirRegKey InstProgressFlags InstType InstTypeGetText InstTypeSetText Int64Cmp Int64CmpU Int64Fmt IntCmp IntCmpU IntFmt IntOp IntPtrCmp IntPtrCmpU IntPtrOp IsWindow LangString LicenseBkColor LicenseData LicenseForceSelection LicenseLangString LicenseText LoadAndSetImage LoadLanguageFile LockWindow LogSet LogText ManifestDPIAware ManifestLongPathAware ManifestMaxVersionTested ManifestSupportedOS MessageBox MiscButtonText Name Nop OutFile Page PageCallbacks PEAddResource PEDllCharacteristics PERemoveResource PESubsysVer Pop Push Quit ReadEnvStr ReadINIStr ReadRegDWORD ReadRegStr Reboot RegDLL Rename RequestExecutionLevel ReserveFile Return RMDir SearchPath SectionGetFlags SectionGetInstTypes SectionGetSize SectionGetText SectionIn SectionSetFlags SectionSetInstTypes SectionSetSize SectionSetText SendMessage SetAutoClose SetBrandingImage SetCompress SetCompressor SetCompressorDictSize SetCtlColors SetCurInstType SetDatablockOptimize SetDateSave SetDetailsPrint SetDetailsView SetErrorLevel SetErrors SetFileAttributes SetFont SetOutPath SetOverwrite SetRebootFlag SetRegView SetShellVarContext SetSilent ShowInstDetails ShowUninstDetails ShowWindow SilentInstall SilentUnInstall Sleep SpaceTexts StrCmp StrCmpS StrCpy StrLen SubCaption Unicode UninstallButtonText UninstallCaption UninstallIcon UninstallSubCaption UninstallText UninstPage UnRegDLL Var VIAddVersionKey VIFileVersion VIProductVersion WindowIcon WriteINIStr WriteRegBin WriteRegDWORD WriteRegExpandStr WriteRegMultiStr WriteRegNone WriteRegStr WriteUninstaller XPStyle', | ||
literal: | ||
'admin all auto both bottom bzip2 colored components current custom directory false force hide highest ifdiff ifnewer instfiles lastused leave left license listonly lzma nevershow none normal notset off on open print right show silent silentlog smooth textonly top true try un.components un.custom un.directory un.instfiles un.license uninstConfirm user Win10 Win7 Win8 WinVista zlib' | ||
keyword: KEYWORDS, | ||
literal: LITERALS | ||
}, | ||
@@ -107,6 +584,5 @@ contains: [ | ||
), | ||
FUNCTION_DEF, | ||
{ | ||
className: 'function', | ||
beginKeywords: 'Function PageEx Section SectionGroup', | ||
end: '$' | ||
beginKeywords: 'Function PageEx Section SectionGroup FunctionEnd SectionEnd', | ||
}, | ||
@@ -113,0 +589,0 @@ STRING, |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -61,2 +10,3 @@ Language: Perl | ||
function perl(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = [ | ||
@@ -318,3 +268,3 @@ 'abs', | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/, | ||
@@ -354,5 +304,5 @@ // negative look-ahead tries to avoid matching patterns that are not | ||
? close | ||
: concat(close, open); | ||
return concat( | ||
concat("(?:", prefix, ")"), | ||
: regex.concat(close, open); | ||
return regex.concat( | ||
regex.concat("(?:", prefix, ")"), | ||
open, | ||
@@ -372,4 +322,4 @@ /(?:\\.|[^\\\/])*?/, | ||
const PAIRED_RE = (prefix, open, close) => { | ||
return concat( | ||
concat("(?:", prefix, ")"), | ||
return regex.concat( | ||
regex.concat("(?:", prefix, ")"), | ||
open, | ||
@@ -465,3 +415,3 @@ /(?:\\.|[^\\\/])*?/, | ||
// allow matching common delimiters | ||
{ begin: PAIRED_DOUBLE_RE("s|tr|y", either(...REGEX_DELIMS, { capture: true })) }, | ||
{ begin: PAIRED_DOUBLE_RE("s|tr|y", regex.either(...REGEX_DELIMS, { capture: true })) }, | ||
// and then paired delmis | ||
@@ -486,3 +436,3 @@ { begin: PAIRED_DOUBLE_RE("s|tr|y", "\\(", "\\)") }, | ||
// allow matching common delimiters | ||
{ begin: PAIRED_RE("m|qr", either(...REGEX_DELIMS, { capture: true }), /\1/)}, | ||
{ begin: PAIRED_RE("m|qr", regex.either(...REGEX_DELIMS, { capture: true }), /\1/)}, | ||
// allow common paired delmins | ||
@@ -489,0 +439,0 @@ { begin: PAIRED_RE("m|qr", /\(/, /\)/)}, |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -69,2 +10,3 @@ Language: Processing | ||
function processing(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_INS = [ | ||
@@ -337,3 +279,3 @@ "displayHeight", | ||
{ | ||
match: concat(either(...BUILT_INS), lookahead(/\s*\(/)), | ||
match: regex.concat(regex.either(...BUILT_INS), regex.lookahead(/\s*\(/)), | ||
className: "built_in" | ||
@@ -343,5 +285,5 @@ }, | ||
relevance: 0, | ||
match: concat( | ||
match: regex.concat( | ||
/\b(?!for|if|while)/, | ||
IDENT, lookahead(/\s*\(/)), | ||
IDENT, regex.lookahead(/\s*\(/)), | ||
className: "title.function" | ||
@@ -348,0 +290,0 @@ } |
@@ -1,166 +0,1 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {string} | ||
*/ | ||
/** | ||
* performs a shallow merge of multiple objects into one | ||
* | ||
* @template T | ||
* @param {T} original | ||
* @param {Record<string,any>[]} objects | ||
* @returns {T} a single new object | ||
*/ | ||
function inherit(original, ...objects) { | ||
/** @type Record<string,any> */ | ||
const result = Object.create(null); | ||
for (const key in original) { | ||
result[key] = original[key]; | ||
} | ||
objects.forEach(function(obj) { | ||
for (const key in obj) { | ||
result[key] = obj[key]; | ||
} | ||
}); | ||
return /** @type {T} */ (result); | ||
} | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; | ||
/** | ||
* Creates a comment mode | ||
* | ||
* @param {string | RegExp} begin | ||
* @param {string | RegExp} end | ||
* @param {Mode | {}} [modeOptions] | ||
* @returns {Partial<Mode>} | ||
*/ | ||
const COMMENT = function(begin, end, modeOptions = {}) { | ||
const mode = inherit( | ||
{ | ||
scope: 'comment', | ||
begin, | ||
end, | ||
contains: [] | ||
}, | ||
modeOptions | ||
); | ||
mode.contains.push({ | ||
scope: 'doctag', | ||
// hack to avoid the space from being included. the space is necessary to | ||
// match here to prevent the plain text rule below from gobbling up doctags | ||
begin: '[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)', | ||
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/, | ||
excludeBegin: true, | ||
relevance: 0 | ||
}); | ||
const ENGLISH_WORD = either( | ||
// list of common 1 and 2 letter words in English | ||
"I", | ||
"a", | ||
"is", | ||
"so", | ||
"us", | ||
"to", | ||
"at", | ||
"if", | ||
"in", | ||
"it", | ||
"on", | ||
// note: this is not an exhaustive list of contractions, just popular ones | ||
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/, // contractions - can't we'd they're let's, etc | ||
/[A-Za-z]+[-][a-z]+/, // `no-way`, etc. | ||
/[A-Za-z][a-z]{2,}/ // allow capitalized words at beginning of sentences | ||
); | ||
// looking like plain text, more likely to be a comment | ||
mode.contains.push( | ||
{ | ||
// TODO: how to include ", (, ) without breaking grammars that use these for | ||
// comment delimiters? | ||
// begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/ | ||
// --- | ||
// this tries to find sequences of 3 english words in a row (without any | ||
// "programming" type syntax) this gives us a strong signal that we've | ||
// TRULY found a comment - vs perhaps scanning with the wrong language. | ||
// It's possible to find something that LOOKS like the start of the | ||
// comment - but then if there is no readable text - good chance it is a | ||
// false match and not a comment. | ||
// | ||
// for a visual example please see: | ||
// https://github.com/highlightjs/highlight.js/issues/2827 | ||
begin: concat( | ||
/[ ]+/, // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */ | ||
'(', | ||
ENGLISH_WORD, | ||
/[.]?[:]?([.][ ]|[ ])/, | ||
'){3}') // look for 3 words in a row | ||
} | ||
); | ||
return mode; | ||
}; | ||
COMMENT('//', '$'); | ||
COMMENT('/\\*', '\\*/'); | ||
COMMENT('#', '$'); | ||
/* | ||
@@ -174,2 +9,4 @@ Language: Python | ||
function python(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[\p{XID_Start}_]\p{XID_Continue}*/u; | ||
const RESERVED_WORDS = [ | ||
@@ -471,3 +308,3 @@ 'and', | ||
className: "comment", | ||
begin: lookahead(/# type:/), | ||
begin: regex.lookahead(/# type:/), | ||
end: /$/, | ||
@@ -525,2 +362,3 @@ keywords: KEYWORDS, | ||
], | ||
unicodeRegex: true, | ||
keywords: KEYWORDS, | ||
@@ -547,3 +385,3 @@ illegal: /(<\/|->|\?)|=>/, | ||
/def/, /\s+/, | ||
UNDERSCORE_IDENT_RE | ||
IDENT_RE, | ||
], | ||
@@ -561,4 +399,4 @@ scope: { | ||
/class/, /\s+/, | ||
UNDERSCORE_IDENT_RE, /\s*/, | ||
/\(\s*/, UNDERSCORE_IDENT_RE,/\s*\)/ | ||
IDENT_RE, /\s*/, | ||
/\(\s*/, IDENT_RE,/\s*\)/ | ||
], | ||
@@ -569,3 +407,3 @@ }, | ||
/class/, /\s+/, | ||
UNDERSCORE_IDENT_RE | ||
IDENT_RE | ||
], | ||
@@ -572,0 +410,0 @@ } |
@@ -1,26 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -37,2 +12,3 @@ Language: QML | ||
function qml(hljs) { | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
@@ -119,3 +95,3 @@ keyword: | ||
const QML_OBJECT = { | ||
begin: concat(QML_IDENT_RE, /\s*\{/), | ||
begin: regex.concat(QML_IDENT_RE, /\s*\{/), | ||
end: /\{/, | ||
@@ -122,0 +98,0 @@ returnBegin: true, |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -71,2 +12,3 @@ Language: R | ||
function r(hljs) { | ||
const regex = hljs.regex; | ||
// Identifiers in R cannot start with `_`, but they can start with `.` if it | ||
@@ -79,3 +21,3 @@ // is not immediately followed by a digit. | ||
const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; | ||
const NUMBER_TYPES_RE = either( | ||
const NUMBER_TYPES_RE = regex.either( | ||
// Special case: only hexadecimal binary powers can contain fractions | ||
@@ -89,3 +31,3 @@ /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/, | ||
const OPERATORS_RE = /[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/; | ||
const PUNCTUATION_RE = either( | ||
const PUNCTUATION_RE = regex.either( | ||
/[()]/, | ||
@@ -150,3 +92,3 @@ /[{}]/, | ||
starts: { | ||
end: lookahead(either( | ||
end: regex.lookahead(regex.either( | ||
// end if another doc comment | ||
@@ -153,0 +95,0 @@ /\n^#'\s*(?=@[a-zA-Z]+)/, |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,2 +11,3 @@ Language: Ruby | ||
function ruby(hljs) { | ||
const regex = hljs.regex; | ||
const RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)'; | ||
@@ -163,5 +131,5 @@ const RUBY_KEYWORDS = { | ||
// positive (auto-detect, etc.) | ||
begin: concat( | ||
begin: regex.concat( | ||
/<<[-~]?'?/, | ||
lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/) | ||
regex.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/) | ||
), | ||
@@ -255,3 +223,3 @@ contains: [ | ||
// def method_name (end of line) | ||
begin: concat(/def\s+/, lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")), | ||
begin: regex.concat(/def\s+/, regex.lookahead(RUBY_METHOD_RE + "\\s*(\\(|;|$)")), | ||
relevance: 0, // relevance comes from kewords | ||
@@ -258,0 +226,0 @@ keywords: "def", |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -44,10 +11,11 @@ Language: Rust | ||
function rust(hljs) { | ||
const regex = hljs.regex; | ||
const FUNCTION_INVOKE = { | ||
className: "title.function.invoke", | ||
relevance: 0, | ||
begin: concat( | ||
begin: regex.concat( | ||
/\b/, | ||
/(?!let\b)/, | ||
hljs.IDENT_RE, | ||
lookahead(/\s*\(/)) | ||
regex.lookahead(/\s*\(/)) | ||
}; | ||
@@ -54,0 +22,0 @@ const NUMBER_SUFFIX = '([ui](8|16|32|64|128|size)|f(32|64))\?'; |
@@ -1,43 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -51,2 +9,3 @@ Language: SAS | ||
function sas(hljs) { | ||
const regex = hljs.regex; | ||
// Data step and PROC SQL statements | ||
@@ -571,3 +530,3 @@ const SAS_KEYWORDS = [ | ||
className: 'built_in', | ||
begin: '%' + either(...MACRO_FUNCTIONS) | ||
begin: '%' + regex.either(...MACRO_FUNCTIONS) | ||
}, | ||
@@ -584,3 +543,3 @@ { | ||
className: 'meta', | ||
begin: either(...FUNCTIONS) + '(?=\\()' | ||
begin: regex.either(...FUNCTIONS) + '(?=\\()' | ||
}, | ||
@@ -587,0 +546,0 @@ { |
@@ -10,2 +10,3 @@ /* | ||
function scala(hljs) { | ||
const regex = hljs.regex; | ||
const ANNOTATION = { | ||
@@ -63,7 +64,2 @@ className: 'meta', | ||
const SYMBOL = { | ||
className: 'symbol', | ||
begin: '\'\\w[\\w\\d_]*(?!\')' | ||
}; | ||
const TYPE = { | ||
@@ -117,7 +113,51 @@ className: 'type', | ||
beginKeywords: 'def', | ||
end: /[:={\[(\n;]/, | ||
excludeEnd: true, | ||
end: regex.lookahead(/[:={\[(\n;]/), | ||
contains: [ NAME ] | ||
}; | ||
const EXTENSION = { | ||
begin: [ | ||
/^\s*/, // Is first token on the line | ||
'extension', | ||
/\s+(?=[[(])/, // followed by at least one space and `[` or `(` | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
} | ||
}; | ||
const END = [{ | ||
begin: [ | ||
/^\s*/, // Is first token on the line | ||
/end/, | ||
/\s+/, | ||
/(extension\b)?/, // `extension` is the only marker that follows an `end` that cannot be captured by another rule. | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
4: "keyword", | ||
} | ||
}]; | ||
// TODO: use negative look-behind in future | ||
// /(?<!\.)\binline(?=\s)/ | ||
const INLINE_MODES = [{ | ||
match: /\.inline\b/ | ||
}, | ||
{ | ||
begin: /\binline(?=\s)/, | ||
keywords: 'inline' | ||
}]; | ||
const USING_PARAM_CLAUSE = { | ||
begin: [ | ||
/\(\s*/, // Opening `(` of a parameter or argument list | ||
/using/, | ||
/\s+(?!\))/, // Spaces not followed by `)` | ||
], | ||
beginScope: { | ||
2: "keyword", | ||
} | ||
}; | ||
return { | ||
@@ -127,3 +167,3 @@ name: 'Scala', | ||
literal: 'true false null', | ||
keyword: 'type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit' | ||
keyword: 'type yield lazy override def with val var sealed abstract private trait object if then forSome for while do throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit export enum given' | ||
}, | ||
@@ -134,3 +174,2 @@ contains: [ | ||
STRING, | ||
SYMBOL, | ||
TYPE, | ||
@@ -140,2 +179,6 @@ METHOD, | ||
hljs.C_NUMBER_MODE, | ||
EXTENSION, | ||
END, | ||
...INLINE_MODES, | ||
USING_PARAM_CLAUSE, | ||
ANNOTATION | ||
@@ -142,0 +185,0 @@ ] |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -491,2 +601,5 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
// to recognize keyframe 40% etc which are outside the scope of our | ||
// attribute value mode | ||
modes.CSS_NUMBER_MODE, | ||
{ | ||
@@ -515,3 +628,3 @@ className: 'selector-id', | ||
className: 'selector-pseudo', | ||
begin: '::(' + PSEUDO_ELEMENTS$1.join('|') + ')' | ||
begin: ':(:)?(' + PSEUDO_ELEMENTS$1.join('|') + ')' | ||
}, | ||
@@ -533,5 +646,6 @@ VARIABLE, | ||
{ | ||
begin: ':', | ||
end: ';', | ||
begin: /:/, | ||
end: /[;}{]/, | ||
contains: [ | ||
modes.BLOCK_COMMENT, | ||
VARIABLE, | ||
@@ -579,3 +693,4 @@ modes.HEXCOLOR, | ||
] | ||
} | ||
}, | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -582,0 +697,0 @@ }; |
@@ -1,59 +0,25 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
/* | ||
Language: SQL | ||
Website: https://en.wikipedia.org/wiki/SQL | ||
Category: common, database | ||
*/ | ||
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; | ||
} | ||
Goals: | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
SQL is intended to highlight basic/common SQL keywords and expressions | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
- If pretty much every single SQL server includes supports, then it's a canidate. | ||
- It is NOT intended to include tons of vendor specific keywords (Oracle, MySQL, | ||
PostgreSQL) although the list of data types is purposely a bit more expansive. | ||
- For more specific SQL grammars please see: | ||
- PostgreSQL and PL/pgSQL - core | ||
- T-SQL - https://github.com/highlightjs/highlightjs-tsql | ||
- sql_more (core) | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
Language: SQL | ||
Website: https://en.wikipedia.org/wiki/SQL | ||
Category: common, database | ||
*/ | ||
function sql(hljs) { | ||
const regex = hljs.regex; | ||
const COMMENT_MODE = hljs.COMMENT('--', '$'); | ||
@@ -653,3 +619,3 @@ const STRING = { | ||
const FUNCTION_CALL = { | ||
begin: concat(/\b/, either(...FUNCTIONS), /\s*\(/), | ||
begin: regex.concat(/\b/, regex.either(...FUNCTIONS), /\s*\(/), | ||
relevance: 0, | ||
@@ -691,3 +657,3 @@ keywords: { | ||
{ | ||
begin: either(...COMBOS), | ||
begin: regex.either(...COMBOS), | ||
relevance: 0, | ||
@@ -703,3 +669,3 @@ keywords: { | ||
className: "type", | ||
begin: either(...MULTI_WORD_TYPES) | ||
begin: regex.either(...MULTI_WORD_TYPES) | ||
}, | ||
@@ -706,0 +672,0 @@ FUNCTION_CALL, |
@@ -7,6 +7,11 @@ const MODES = (hljs) => { | ||
}, | ||
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE, | ||
HEXCOLOR: { | ||
scope: 'number', | ||
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})' | ||
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/ | ||
}, | ||
FUNCTION_DISPATCH: { | ||
className: "built_in", | ||
begin: /[\w-]+(?=\()/ | ||
}, | ||
ATTRIBUTE_SELECTOR_MODE: { | ||
@@ -239,2 +244,3 @@ scope: 'selector-attr', | ||
'align-self', | ||
'all', | ||
'animation', | ||
@@ -249,3 +255,2 @@ 'animation-delay', | ||
'animation-timing-function', | ||
'auto', | ||
'backface-visibility', | ||
@@ -302,5 +307,7 @@ 'background', | ||
'caption-side', | ||
'caret-color', | ||
'clear', | ||
'clip', | ||
'clip-path', | ||
'clip-rule', | ||
'color', | ||
@@ -317,5 +324,10 @@ 'column-count', | ||
'columns', | ||
'contain', | ||
'content', | ||
'content-visibility', | ||
'counter-increment', | ||
'counter-reset', | ||
'cue', | ||
'cue-after', | ||
'cue-before', | ||
'cursor', | ||
@@ -334,2 +346,3 @@ 'direction', | ||
'float', | ||
'flow', | ||
'font', | ||
@@ -346,6 +359,30 @@ 'font-display', | ||
'font-style', | ||
'font-synthesis', | ||
'font-variant', | ||
'font-variant-caps', | ||
'font-variant-east-asian', | ||
'font-variant-ligatures', | ||
'font-variant-numeric', | ||
'font-variant-position', | ||
'font-variation-settings', | ||
'font-weight', | ||
'gap', | ||
'glyph-orientation-vertical', | ||
'grid', | ||
'grid-area', | ||
'grid-auto-columns', | ||
'grid-auto-flow', | ||
'grid-auto-rows', | ||
'grid-column', | ||
'grid-column-end', | ||
'grid-column-start', | ||
'grid-gap', | ||
'grid-row', | ||
'grid-row-end', | ||
'grid-row-start', | ||
'grid-template', | ||
'grid-template-areas', | ||
'grid-template-columns', | ||
'grid-template-rows', | ||
'hanging-punctuation', | ||
'height', | ||
@@ -358,7 +395,7 @@ 'hyphens', | ||
'ime-mode', | ||
'inherit', | ||
'initial', | ||
'isolation', | ||
'justify-content', | ||
'left', | ||
'letter-spacing', | ||
'line-break', | ||
'line-height', | ||
@@ -376,2 +413,18 @@ 'list-style', | ||
'mask', | ||
'mask-border', | ||
'mask-border-mode', | ||
'mask-border-outset', | ||
'mask-border-repeat', | ||
'mask-border-slice', | ||
'mask-border-source', | ||
'mask-border-width', | ||
'mask-clip', | ||
'mask-composite', | ||
'mask-image', | ||
'mask-mode', | ||
'mask-origin', | ||
'mask-position', | ||
'mask-repeat', | ||
'mask-size', | ||
'mask-type', | ||
'max-height', | ||
@@ -381,2 +434,3 @@ 'max-width', | ||
'min-width', | ||
'mix-blend-mode', | ||
'nav-down', | ||
@@ -411,2 +465,5 @@ 'nav-index', | ||
'page-break-inside', | ||
'pause', | ||
'pause-after', | ||
'pause-before', | ||
'perspective', | ||
@@ -418,3 +475,37 @@ 'perspective-origin', | ||
'resize', | ||
'rest', | ||
'rest-after', | ||
'rest-before', | ||
'right', | ||
'row-gap', | ||
'scroll-margin', | ||
'scroll-margin-block', | ||
'scroll-margin-block-end', | ||
'scroll-margin-block-start', | ||
'scroll-margin-bottom', | ||
'scroll-margin-inline', | ||
'scroll-margin-inline-end', | ||
'scroll-margin-inline-start', | ||
'scroll-margin-left', | ||
'scroll-margin-right', | ||
'scroll-margin-top', | ||
'scroll-padding', | ||
'scroll-padding-block', | ||
'scroll-padding-block-end', | ||
'scroll-padding-block-start', | ||
'scroll-padding-bottom', | ||
'scroll-padding-inline', | ||
'scroll-padding-inline-end', | ||
'scroll-padding-inline-start', | ||
'scroll-padding-left', | ||
'scroll-padding-right', | ||
'scroll-padding-top', | ||
'scroll-snap-align', | ||
'scroll-snap-stop', | ||
'scroll-snap-type', | ||
'shape-image-threshold', | ||
'shape-margin', | ||
'shape-outside', | ||
'speak', | ||
'speak-as', | ||
'src', // @font-face | ||
@@ -424,3 +515,5 @@ 'tab-size', | ||
'text-align', | ||
'text-align-all', | ||
'text-align-last', | ||
'text-combine-upright', | ||
'text-decoration', | ||
@@ -430,3 +523,9 @@ 'text-decoration-color', | ||
'text-decoration-style', | ||
'text-emphasis', | ||
'text-emphasis-color', | ||
'text-emphasis-position', | ||
'text-emphasis-style', | ||
'text-indent', | ||
'text-justify', | ||
'text-orientation', | ||
'text-overflow', | ||
@@ -439,2 +538,3 @@ 'text-rendering', | ||
'transform', | ||
'transform-box', | ||
'transform-origin', | ||
@@ -450,8 +550,18 @@ 'transform-style', | ||
'visibility', | ||
'voice-balance', | ||
'voice-duration', | ||
'voice-family', | ||
'voice-pitch', | ||
'voice-range', | ||
'voice-rate', | ||
'voice-stress', | ||
'voice-volume', | ||
'white-space', | ||
'widows', | ||
'width', | ||
'will-change', | ||
'word-break', | ||
'word-spacing', | ||
'word-wrap', | ||
'writing-mode', | ||
'z-index' | ||
@@ -558,3 +668,3 @@ // reverse makes sure longer attributes `font-weight` are matched fully | ||
className: 'selector-pseudo', | ||
begin: '&?::(' + PSEUDO_ELEMENTS.join('|') + ')' + LOOKAHEAD_TAG_END | ||
begin: '&?:(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' + LOOKAHEAD_TAG_END | ||
}, | ||
@@ -641,3 +751,4 @@ | ||
} | ||
} | ||
}, | ||
modes.FUNCTION_DISPATCH | ||
] | ||
@@ -644,0 +755,0 @@ }; |
@@ -34,2 +34,6 @@ /** | ||
/** | ||
* @param { Array<string | RegExp | Object> } args | ||
* @returns {object} | ||
*/ | ||
function stripOptionsFromArgs(args) { | ||
@@ -54,6 +58,7 @@ const opts = args[args.length - 1]; | ||
function either(...args) { | ||
/** @type { object & {capture?: boolean} } */ | ||
const opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
const joined = '(' | ||
+ (opts.capture ? "" : "?:") | ||
+ args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
@@ -60,0 +65,0 @@ } |
@@ -1,34 +0,1 @@ | ||
/** | ||
* @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 optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -42,2 +9,3 @@ Language: Tcl | ||
function tcl(hljs) { | ||
const regex = hljs.regex; | ||
const TCL_IDENT = /[a-zA-Z_][a-zA-Z0-9_]*/; | ||
@@ -196,5 +164,5 @@ | ||
{ | ||
begin: concat( | ||
begin: regex.concat( | ||
/\$/, | ||
optional(/::/), | ||
regex.optional(/::/), | ||
TCL_IDENT, | ||
@@ -201,0 +169,0 @@ '(::', |
@@ -54,40 +54,57 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects | ||
const TYPES = [ | ||
"Intl", | ||
"DataView", | ||
"Number", | ||
// Fundamental objects | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Symbol", | ||
// numbers and dates | ||
"Math", | ||
"Date", | ||
"Number", | ||
"BigInt", | ||
// text | ||
"String", | ||
"RegExp", | ||
"Object", | ||
"Function", | ||
"Boolean", | ||
"Error", | ||
"Symbol", | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
"Proxy", | ||
"Reflect", | ||
"JSON", | ||
"Promise", | ||
// Indexed collections | ||
"Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Int32Array", | ||
"Int8Array", | ||
"Uint16Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"ArrayBuffer", | ||
"BigInt64Array", | ||
"BigUint64Array", | ||
"BigInt" | ||
// Keyed collections | ||
"Set", | ||
"Map", | ||
"WeakSet", | ||
"WeakMap", | ||
// Structured data | ||
"ArrayBuffer", | ||
"SharedArrayBuffer", | ||
"Atomics", | ||
"DataView", | ||
"JSON", | ||
// Control abstraction objects | ||
"Promise", | ||
"Generator", | ||
"GeneratorFunction", | ||
"AsyncFunction", | ||
// Reflection | ||
"Reflect", | ||
"Proxy", | ||
// Internationalization | ||
"Intl", | ||
// WebAssembly | ||
"WebAssembly" | ||
]; | ||
const ERROR_TYPES = [ | ||
"Error", | ||
"EvalError", | ||
@@ -142,35 +159,2 @@ "InternalError", | ||
/** | ||
* @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; | ||
} | ||
/* | ||
@@ -185,2 +169,3 @@ Language: JavaScript | ||
function javascript(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -204,2 +189,4 @@ * Takes a string like "<Booger" and checks to see | ||
}; | ||
// to avoid some special cases inside isTrulyOpeningTag | ||
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/; | ||
const XML_TAG = { | ||
@@ -215,11 +202,16 @@ begin: /<[A-Za-z0-9\\._:-]+/, | ||
const nextChar = match.input[afterMatchIndex]; | ||
// nested type? | ||
// HTML should not include another raw `<` inside a tag | ||
// But a type might: `<Array<Array<number>>`, etc. | ||
if (nextChar === "<") { | ||
if ( | ||
// HTML should not include another raw `<` inside a tag | ||
// nested type? | ||
// `<Array<Array<number>>`, etc. | ||
nextChar === "<" || | ||
// the , gives away that this is not HTML | ||
// `<T, A extends keyof T, V>` | ||
nextChar === ",") { | ||
response.ignoreMatch(); | ||
return; | ||
} | ||
// <something> | ||
// This is now either a tag or a type. | ||
// `<something>` | ||
// Quite possibly a tag, lets look for a matching closing tag... | ||
if (nextChar === ">") { | ||
@@ -232,2 +224,18 @@ // if we cannot find a matching closing tag, then we | ||
} | ||
// `<blah />` (self-closing) | ||
// handled by simpleSelfClosing rule | ||
// `<From extends string>` | ||
// technically this could be HTML, but it smells like a type | ||
let m; | ||
const afterMatch = match.input.substr(afterMatchIndex); | ||
// NOTE: This is ugh, but added specifically for https://github.com/highlightjs/highlight.js/issues/3276 | ||
if ((m = afterMatch.match(/^\s+extends\s+/))) { | ||
if (m.index === 0) { | ||
response.ignoreMatch(); | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} | ||
} | ||
} | ||
@@ -368,3 +376,5 @@ }; | ||
NUMBER, | ||
hljs.REGEXP_MODE | ||
// This is intentional: | ||
// See https://github.com/highlightjs/highlight.js/issues/3288 | ||
// hljs.REGEXP_MODE | ||
]; | ||
@@ -405,2 +415,3 @@ SUBST.contains = SUBST_INTERNALS | ||
variants: [ | ||
// class Car extends vehicle | ||
{ | ||
@@ -410,20 +421,28 @@ match: [ | ||
/\s+/, | ||
IDENT_RE$1 | ||
IDENT_RE$1, | ||
/\s+/, | ||
/extends/, | ||
/\s+/, | ||
regex.concat(IDENT_RE$1, "(", regex.concat(/\./, IDENT_RE$1), ")*") | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class" | ||
3: "title.class", | ||
5: "keyword", | ||
7: "title.class.inherited" | ||
} | ||
}, | ||
// class Car | ||
{ | ||
match: [ | ||
/extends/, | ||
/class/, | ||
/\s+/, | ||
concat(IDENT_RE$1, "(", concat(/\./, IDENT_RE$1), ")*") | ||
IDENT_RE$1 | ||
], | ||
scope: { | ||
1: "keyword", | ||
3: "title.class.inherited" | ||
3: "title.class" | ||
} | ||
} | ||
}, | ||
] | ||
@@ -434,3 +453,13 @@ }; | ||
relevance: 0, | ||
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/, | ||
match: | ||
regex.either( | ||
// Hard coded exceptions | ||
/\bJSON/, | ||
// Float32Array | ||
/\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/, | ||
// CSSFactory | ||
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+/, | ||
// BLAH | ||
// this will be flagged as a UPPER_CASE_CONSTANT instead | ||
), | ||
className: "title.class", | ||
@@ -487,7 +516,7 @@ keywords: { | ||
function noneOf(list) { | ||
return concat("(?!", list.join("|"), ")"); | ||
return regex.concat("(?!", list.join("|"), ")"); | ||
} | ||
const FUNCTION_CALL = { | ||
match: concat( | ||
match: regex.concat( | ||
/\b/, | ||
@@ -498,3 +527,3 @@ noneOf([ | ||
]), | ||
IDENT_RE$1, lookahead(/\(/)), | ||
IDENT_RE$1, regex.lookahead(/\(/)), | ||
className: "title.function", | ||
@@ -505,4 +534,4 @@ relevance: 0 | ||
const PROPERTY_ACCESS = { | ||
begin: concat(/\./, lookahead( | ||
concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
begin: regex.concat(/\./, regex.lookahead( | ||
regex.concat(IDENT_RE$1, /(?![0-9A-Za-z$_(])/) | ||
)), | ||
@@ -548,3 +577,3 @@ end: IDENT_RE$1, | ||
/=\s*/, | ||
lookahead(FUNC_LEAD_IN_RE) | ||
regex.lookahead(FUNC_LEAD_IN_RE) | ||
], | ||
@@ -565,3 +594,3 @@ className: { | ||
// this will be extended by TypeScript | ||
exports: { PARAMS_CONTAINS }, | ||
exports: { PARAMS_CONTAINS, CLASS_REFERENCE }, | ||
illegal: /#(?![$_A-z])/, | ||
@@ -585,3 +614,3 @@ contains: [ | ||
className: 'attr', | ||
begin: IDENT_RE$1 + lookahead(':'), | ||
begin: IDENT_RE$1 + regex.lookahead(':'), | ||
relevance: 0 | ||
@@ -641,2 +670,3 @@ }, | ||
{ begin: FRAGMENT.begin, end: FRAGMENT.end }, | ||
{ match: XML_SELF_CLOSING }, | ||
{ | ||
@@ -727,15 +757,5 @@ begin: XML_TAG.begin, | ||
function typescript(hljs) { | ||
const tsLanguage = javascript(hljs); | ||
const IDENT_RE$1 = IDENT_RE; | ||
const NAMESPACE = { | ||
beginKeywords: 'namespace', end: /\{/, excludeEnd: true | ||
}; | ||
const INTERFACE = { | ||
beginKeywords: 'interface', end: /\{/, excludeEnd: true, | ||
keywords: 'interface extends' | ||
}; | ||
const USE_STRICT = { | ||
className: 'meta', | ||
relevance: 10, | ||
begin: /^\s*['"]use strict['"]/ | ||
}; | ||
const TYPES = [ | ||
@@ -751,2 +771,27 @@ "any", | ||
]; | ||
const NAMESPACE = { | ||
beginKeywords: 'namespace', | ||
end: /\{/, | ||
excludeEnd: true, | ||
contains: [ | ||
tsLanguage.exports.CLASS_REFERENCE | ||
] | ||
}; | ||
const INTERFACE = { | ||
beginKeywords: 'interface', | ||
end: /\{/, | ||
excludeEnd: true, | ||
keywords: { | ||
keyword: 'interface extends', | ||
built_in: TYPES | ||
}, | ||
contains: [ | ||
tsLanguage.exports.CLASS_REFERENCE | ||
] | ||
}; | ||
const USE_STRICT = { | ||
className: 'meta', | ||
relevance: 10, | ||
begin: /^\s*['"]use strict['"]/ | ||
}; | ||
const TS_SPECIFIC_KEYWORDS = [ | ||
@@ -783,3 +828,2 @@ "type", | ||
const tsLanguage = javascript(hljs); | ||
@@ -786,0 +830,0 @@ // this should update anywhere keywords is used since |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -62,2 +11,3 @@ Language: Visual Basic .NET | ||
function vbnet(hljs) { | ||
const regex = hljs.regex; | ||
/** | ||
@@ -95,19 +45,19 @@ * Character Literal | ||
// #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date) | ||
begin: concat(/# */, either(YYYY_MM_DD, MM_DD_YYYY), / *#/) | ||
begin: regex.concat(/# */, regex.either(YYYY_MM_DD, MM_DD_YYYY), / *#/) | ||
}, | ||
{ | ||
// #H:mm[:ss]# (24h Time) | ||
begin: concat(/# */, TIME_24H, / *#/) | ||
begin: regex.concat(/# */, TIME_24H, / *#/) | ||
}, | ||
{ | ||
// #h[:mm[:ss]] A# (12h Time) | ||
begin: concat(/# */, TIME_12H, / *#/) | ||
begin: regex.concat(/# */, TIME_12H, / *#/) | ||
}, | ||
{ | ||
// date plus time | ||
begin: concat( | ||
begin: regex.concat( | ||
/# */, | ||
either(YYYY_MM_DD, MM_DD_YYYY), | ||
regex.either(YYYY_MM_DD, MM_DD_YYYY), | ||
/ +/, | ||
either(TIME_12H, TIME_24H), | ||
regex.either(TIME_12H, TIME_24H), | ||
/ *#/ | ||
@@ -114,0 +64,0 @@ ) |
@@ -1,52 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -63,2 +12,3 @@ Language: VBScript | ||
function vbscript(hljs) { | ||
const regex = hljs.regex; | ||
const BUILT_IN_FUNCTIONS = [ | ||
@@ -174,3 +124,3 @@ "lcase", | ||
const BUILT_IN_CALL = { | ||
begin: concat(either(...BUILT_IN_FUNCTIONS), "\\s*\\("), | ||
begin: regex.concat(regex.either(...BUILT_IN_FUNCTIONS), "\\s*\\("), | ||
// relevance 0 because this is acting as a beginKeywords really | ||
@@ -177,0 +127,0 @@ relevance: 0, |
@@ -10,62 +10,489 @@ /* | ||
function verilog(hljs) { | ||
const SV_KEYWORDS = { | ||
$pattern: /[\w\$]+/, | ||
keyword: | ||
'accept_on alias always always_comb always_ff always_latch and assert assign ' + | ||
'assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 ' + | ||
'byte case casex casez cell chandle checker class clocking cmos config const ' + | ||
'constraint context continue cover covergroup coverpoint cross deassign default ' + | ||
'defparam design disable dist do edge else end endcase endchecker endclass ' + | ||
'endclocking endconfig endfunction endgenerate endgroup endinterface endmodule ' + | ||
'endpackage endprimitive endprogram endproperty endspecify endsequence endtable ' + | ||
'endtask enum event eventually expect export extends extern final first_match for ' + | ||
'force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 ' + | ||
'if iff ifnone ignore_bins illegal_bins implements implies import incdir include ' + | ||
'initial inout input inside instance int integer interconnect interface intersect ' + | ||
'join join_any join_none large let liblist library local localparam logic longint ' + | ||
'macromodule matches medium modport module nand negedge nettype new nexttime nmos ' + | ||
'nor noshowcancelled not notif0 notif1 or output package packed parameter pmos ' + | ||
'posedge primitive priority program property protected pull0 pull1 pulldown pullup ' + | ||
'pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos ' + | ||
'real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran ' + | ||
'rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared ' + | ||
'sequence shortint shortreal showcancelled signed small soft solve specify specparam ' + | ||
'static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on ' + | ||
'sync_reject_on table tagged task this throughout time timeprecision timeunit tran ' + | ||
'tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 ' + | ||
'unsigned until until_with untyped use uwire var vectored virtual void wait wait_order ' + | ||
'wand weak weak0 weak1 while wildcard wire with within wor xnor xor', | ||
literal: | ||
'null', | ||
built_in: | ||
'$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale ' + | ||
'$bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat ' + | ||
'$realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson ' + | ||
'$assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff ' + | ||
'$assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk ' + | ||
'$fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control ' + | ||
'$coverage_get $coverage_save $set_coverage_db_name $rose $stable $past ' + | ||
'$rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display ' + | ||
'$coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename ' + | ||
'$unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow ' + | ||
'$floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning ' + | ||
'$dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh ' + | ||
'$tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random ' + | ||
'$dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson ' + | ||
'$dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array ' + | ||
'$async$nand$array $async$or$array $async$nor$array $sync$and$array ' + | ||
'$sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf ' + | ||
'$async$and$plane $async$nand$plane $async$or$plane $async$nor$plane ' + | ||
'$sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system ' + | ||
'$display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo ' + | ||
'$write $readmemb $readmemh $writememh $value$plusargs ' + | ||
'$dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit ' + | ||
'$writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb ' + | ||
'$dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall ' + | ||
'$dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo ' + | ||
'$fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh ' + | ||
'$swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb ' + | ||
'$fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat ' + | ||
'$sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror' | ||
const regex = hljs.regex; | ||
const KEYWORDS = { | ||
$pattern: /\$?[\w]+(\$[\w]+)*/, | ||
keyword: [ | ||
"accept_on", | ||
"alias", | ||
"always", | ||
"always_comb", | ||
"always_ff", | ||
"always_latch", | ||
"and", | ||
"assert", | ||
"assign", | ||
"assume", | ||
"automatic", | ||
"before", | ||
"begin", | ||
"bind", | ||
"bins", | ||
"binsof", | ||
"bit", | ||
"break", | ||
"buf|0", | ||
"bufif0", | ||
"bufif1", | ||
"byte", | ||
"case", | ||
"casex", | ||
"casez", | ||
"cell", | ||
"chandle", | ||
"checker", | ||
"class", | ||
"clocking", | ||
"cmos", | ||
"config", | ||
"const", | ||
"constraint", | ||
"context", | ||
"continue", | ||
"cover", | ||
"covergroup", | ||
"coverpoint", | ||
"cross", | ||
"deassign", | ||
"default", | ||
"defparam", | ||
"design", | ||
"disable", | ||
"dist", | ||
"do", | ||
"edge", | ||
"else", | ||
"end", | ||
"endcase", | ||
"endchecker", | ||
"endclass", | ||
"endclocking", | ||
"endconfig", | ||
"endfunction", | ||
"endgenerate", | ||
"endgroup", | ||
"endinterface", | ||
"endmodule", | ||
"endpackage", | ||
"endprimitive", | ||
"endprogram", | ||
"endproperty", | ||
"endspecify", | ||
"endsequence", | ||
"endtable", | ||
"endtask", | ||
"enum", | ||
"event", | ||
"eventually", | ||
"expect", | ||
"export", | ||
"extends", | ||
"extern", | ||
"final", | ||
"first_match", | ||
"for", | ||
"force", | ||
"foreach", | ||
"forever", | ||
"fork", | ||
"forkjoin", | ||
"function", | ||
"generate|5", | ||
"genvar", | ||
"global", | ||
"highz0", | ||
"highz1", | ||
"if", | ||
"iff", | ||
"ifnone", | ||
"ignore_bins", | ||
"illegal_bins", | ||
"implements", | ||
"implies", | ||
"import", | ||
"incdir", | ||
"include", | ||
"initial", | ||
"inout", | ||
"input", | ||
"inside", | ||
"instance", | ||
"int", | ||
"integer", | ||
"interconnect", | ||
"interface", | ||
"intersect", | ||
"join", | ||
"join_any", | ||
"join_none", | ||
"large", | ||
"let", | ||
"liblist", | ||
"library", | ||
"local", | ||
"localparam", | ||
"logic", | ||
"longint", | ||
"macromodule", | ||
"matches", | ||
"medium", | ||
"modport", | ||
"module", | ||
"nand", | ||
"negedge", | ||
"nettype", | ||
"new", | ||
"nexttime", | ||
"nmos", | ||
"nor", | ||
"noshowcancelled", | ||
"not", | ||
"notif0", | ||
"notif1", | ||
"or", | ||
"output", | ||
"package", | ||
"packed", | ||
"parameter", | ||
"pmos", | ||
"posedge", | ||
"primitive", | ||
"priority", | ||
"program", | ||
"property", | ||
"protected", | ||
"pull0", | ||
"pull1", | ||
"pulldown", | ||
"pullup", | ||
"pulsestyle_ondetect", | ||
"pulsestyle_onevent", | ||
"pure", | ||
"rand", | ||
"randc", | ||
"randcase", | ||
"randsequence", | ||
"rcmos", | ||
"real", | ||
"realtime", | ||
"ref", | ||
"reg", | ||
"reject_on", | ||
"release", | ||
"repeat", | ||
"restrict", | ||
"return", | ||
"rnmos", | ||
"rpmos", | ||
"rtran", | ||
"rtranif0", | ||
"rtranif1", | ||
"s_always", | ||
"s_eventually", | ||
"s_nexttime", | ||
"s_until", | ||
"s_until_with", | ||
"scalared", | ||
"sequence", | ||
"shortint", | ||
"shortreal", | ||
"showcancelled", | ||
"signed", | ||
"small", | ||
"soft", | ||
"solve", | ||
"specify", | ||
"specparam", | ||
"static", | ||
"string", | ||
"strong", | ||
"strong0", | ||
"strong1", | ||
"struct", | ||
"super", | ||
"supply0", | ||
"supply1", | ||
"sync_accept_on", | ||
"sync_reject_on", | ||
"table", | ||
"tagged", | ||
"task", | ||
"this", | ||
"throughout", | ||
"time", | ||
"timeprecision", | ||
"timeunit", | ||
"tran", | ||
"tranif0", | ||
"tranif1", | ||
"tri", | ||
"tri0", | ||
"tri1", | ||
"triand", | ||
"trior", | ||
"trireg", | ||
"type", | ||
"typedef", | ||
"union", | ||
"unique", | ||
"unique0", | ||
"unsigned", | ||
"until", | ||
"until_with", | ||
"untyped", | ||
"use", | ||
"uwire", | ||
"var", | ||
"vectored", | ||
"virtual", | ||
"void", | ||
"wait", | ||
"wait_order", | ||
"wand", | ||
"weak", | ||
"weak0", | ||
"weak1", | ||
"while", | ||
"wildcard", | ||
"wire", | ||
"with", | ||
"within", | ||
"wor", | ||
"xnor", | ||
"xor" | ||
], | ||
literal: [ 'null' ], | ||
built_in: [ | ||
"$finish", | ||
"$stop", | ||
"$exit", | ||
"$fatal", | ||
"$error", | ||
"$warning", | ||
"$info", | ||
"$realtime", | ||
"$time", | ||
"$printtimescale", | ||
"$bitstoreal", | ||
"$bitstoshortreal", | ||
"$itor", | ||
"$signed", | ||
"$cast", | ||
"$bits", | ||
"$stime", | ||
"$timeformat", | ||
"$realtobits", | ||
"$shortrealtobits", | ||
"$rtoi", | ||
"$unsigned", | ||
"$asserton", | ||
"$assertkill", | ||
"$assertpasson", | ||
"$assertfailon", | ||
"$assertnonvacuouson", | ||
"$assertoff", | ||
"$assertcontrol", | ||
"$assertpassoff", | ||
"$assertfailoff", | ||
"$assertvacuousoff", | ||
"$isunbounded", | ||
"$sampled", | ||
"$fell", | ||
"$changed", | ||
"$past_gclk", | ||
"$fell_gclk", | ||
"$changed_gclk", | ||
"$rising_gclk", | ||
"$steady_gclk", | ||
"$coverage_control", | ||
"$coverage_get", | ||
"$coverage_save", | ||
"$set_coverage_db_name", | ||
"$rose", | ||
"$stable", | ||
"$past", | ||
"$rose_gclk", | ||
"$stable_gclk", | ||
"$future_gclk", | ||
"$falling_gclk", | ||
"$changing_gclk", | ||
"$display", | ||
"$coverage_get_max", | ||
"$coverage_merge", | ||
"$get_coverage", | ||
"$load_coverage_db", | ||
"$typename", | ||
"$unpacked_dimensions", | ||
"$left", | ||
"$low", | ||
"$increment", | ||
"$clog2", | ||
"$ln", | ||
"$log10", | ||
"$exp", | ||
"$sqrt", | ||
"$pow", | ||
"$floor", | ||
"$ceil", | ||
"$sin", | ||
"$cos", | ||
"$tan", | ||
"$countbits", | ||
"$onehot", | ||
"$isunknown", | ||
"$fatal", | ||
"$warning", | ||
"$dimensions", | ||
"$right", | ||
"$high", | ||
"$size", | ||
"$asin", | ||
"$acos", | ||
"$atan", | ||
"$atan2", | ||
"$hypot", | ||
"$sinh", | ||
"$cosh", | ||
"$tanh", | ||
"$asinh", | ||
"$acosh", | ||
"$atanh", | ||
"$countones", | ||
"$onehot0", | ||
"$error", | ||
"$info", | ||
"$random", | ||
"$dist_chi_square", | ||
"$dist_erlang", | ||
"$dist_exponential", | ||
"$dist_normal", | ||
"$dist_poisson", | ||
"$dist_t", | ||
"$dist_uniform", | ||
"$q_initialize", | ||
"$q_remove", | ||
"$q_exam", | ||
"$async$and$array", | ||
"$async$nand$array", | ||
"$async$or$array", | ||
"$async$nor$array", | ||
"$sync$and$array", | ||
"$sync$nand$array", | ||
"$sync$or$array", | ||
"$sync$nor$array", | ||
"$q_add", | ||
"$q_full", | ||
"$psprintf", | ||
"$async$and$plane", | ||
"$async$nand$plane", | ||
"$async$or$plane", | ||
"$async$nor$plane", | ||
"$sync$and$plane", | ||
"$sync$nand$plane", | ||
"$sync$or$plane", | ||
"$sync$nor$plane", | ||
"$system", | ||
"$display", | ||
"$displayb", | ||
"$displayh", | ||
"$displayo", | ||
"$strobe", | ||
"$strobeb", | ||
"$strobeh", | ||
"$strobeo", | ||
"$write", | ||
"$readmemb", | ||
"$readmemh", | ||
"$writememh", | ||
"$value$plusargs", | ||
"$dumpvars", | ||
"$dumpon", | ||
"$dumplimit", | ||
"$dumpports", | ||
"$dumpportson", | ||
"$dumpportslimit", | ||
"$writeb", | ||
"$writeh", | ||
"$writeo", | ||
"$monitor", | ||
"$monitorb", | ||
"$monitorh", | ||
"$monitoro", | ||
"$writememb", | ||
"$dumpfile", | ||
"$dumpoff", | ||
"$dumpall", | ||
"$dumpflush", | ||
"$dumpportsoff", | ||
"$dumpportsall", | ||
"$dumpportsflush", | ||
"$fclose", | ||
"$fdisplay", | ||
"$fdisplayb", | ||
"$fdisplayh", | ||
"$fdisplayo", | ||
"$fstrobe", | ||
"$fstrobeb", | ||
"$fstrobeh", | ||
"$fstrobeo", | ||
"$swrite", | ||
"$swriteb", | ||
"$swriteh", | ||
"$swriteo", | ||
"$fscanf", | ||
"$fread", | ||
"$fseek", | ||
"$fflush", | ||
"$feof", | ||
"$fopen", | ||
"$fwrite", | ||
"$fwriteb", | ||
"$fwriteh", | ||
"$fwriteo", | ||
"$fmonitor", | ||
"$fmonitorb", | ||
"$fmonitorh", | ||
"$fmonitoro", | ||
"$sformat", | ||
"$sformatf", | ||
"$fgetc", | ||
"$ungetc", | ||
"$fgets", | ||
"$sscanf", | ||
"$rewind", | ||
"$ftell", | ||
"$ferror" | ||
] | ||
}; | ||
const BUILT_IN_CONSTANTS = [ | ||
"__FILE__", | ||
"__LINE__" | ||
]; | ||
const DIRECTIVES = [ | ||
"begin_keywords", | ||
"celldefine", | ||
"default_nettype", | ||
"default_decay_time", | ||
"default_trireg_strength", | ||
"define", | ||
"delay_mode_distributed", | ||
"delay_mode_path", | ||
"delay_mode_unit", | ||
"delay_mode_zero", | ||
"else", | ||
"elsif", | ||
"end_keywords", | ||
"endcelldefine", | ||
"endif", | ||
"ifdef", | ||
"ifndef", | ||
"include", | ||
"line", | ||
"nounconnected_drive", | ||
"pragma", | ||
"resetall", | ||
"timescale", | ||
"unconnected_drive", | ||
"undef", | ||
"undefineall" | ||
]; | ||
@@ -80,3 +507,3 @@ return { | ||
case_insensitive: false, | ||
keywords: SV_KEYWORDS, | ||
keywords: KEYWORDS, | ||
contains: [ | ||
@@ -87,13 +514,13 @@ hljs.C_BLOCK_COMMENT_MODE, | ||
{ | ||
className: 'number', | ||
scope: 'number', | ||
contains: [ hljs.BACKSLASH_ESCAPE ], | ||
variants: [ | ||
{ | ||
begin: '\\b((\\d+\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)' | ||
begin: /\b((\d+'([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ | ||
}, | ||
{ | ||
begin: '\\B((\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)' | ||
begin: /\B(('([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ | ||
}, | ||
{ | ||
begin: '\\b([0-9_])+', | ||
{ // decimal | ||
begin: /\b[0-9][0-9_]*/, | ||
relevance: 0 | ||
@@ -105,3 +532,3 @@ } | ||
{ | ||
className: 'variable', | ||
scope: 'variable', | ||
variants: [ | ||
@@ -118,14 +545,11 @@ { | ||
{ | ||
className: 'meta', | ||
begin: '`', | ||
end: '$', | ||
keywords: { | ||
keyword: | ||
'define __FILE__ ' + | ||
'__LINE__ begin_keywords celldefine default_nettype define ' + | ||
'else elsif end_keywords endcelldefine endif ifdef ifndef ' + | ||
'include line nounconnected_drive pragma resetall timescale ' + | ||
'unconnected_drive undef undefineall' | ||
}, | ||
relevance: 0 | ||
scope: 'variable.constant', | ||
match: regex.concat(/`/, regex.either(...BUILT_IN_CONSTANTS)), | ||
}, | ||
{ | ||
scope: 'meta', | ||
begin: regex.concat(/`/, regex.either(...DIRECTIVES)), | ||
end: /$|\/\/|\/\*/, | ||
returnEnd: true, | ||
keywords: DIRECTIVES | ||
} | ||
@@ -132,0 +556,0 @@ ] |
@@ -11,2 +11,3 @@ /* | ||
function wasm(hljs) { | ||
hljs.regex; | ||
const BLOCK_COMMENT = hljs.COMMENT(/\(;/, /;\)/); | ||
@@ -13,0 +14,0 @@ BLOCK_COMMENT.contains.push("self"); |
@@ -1,60 +0,1 @@ | ||
/** | ||
* @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; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -71,2 +12,3 @@ Language: Wren | ||
function wren(hljs) { | ||
const regex = hljs.regex; | ||
const IDENT_RE = /[a-zA-Z]\w*/; | ||
@@ -140,10 +82,10 @@ const KEYWORDS = [ | ||
relevance: 0, | ||
match: concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE, /(?=\s*[({])/), | ||
match: regex.concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE, /(?=\s*[({])/), | ||
className: "title.function" | ||
}; | ||
const FUNCTION_DEFINITION = { | ||
match: concat( | ||
either( | ||
concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE), | ||
either(...OPERATORS) | ||
match: regex.concat( | ||
regex.either( | ||
regex.concat(/\b(?!(if|while|for|else|super)\b)/, IDENT_RE), | ||
regex.either(...OPERATORS) | ||
), | ||
@@ -194,3 +136,3 @@ /(?=\s*\([^)]+\)\s*\{)/), | ||
relevance: 0, | ||
match: either(...OPERATORS), | ||
match: regex.either(...OPERATORS), | ||
className: "operator" | ||
@@ -207,3 +149,3 @@ }; | ||
className: "property", | ||
begin: concat(/\./, lookahead(IDENT_RE)), | ||
begin: regex.concat(/\./, regex.lookahead(IDENT_RE)), | ||
end: IDENT_RE, | ||
@@ -216,3 +158,3 @@ excludeBegin: true, | ||
relevance: 0, | ||
match: concat(/\b_/, IDENT_RE), | ||
match: regex.concat(/\b_/, IDENT_RE), | ||
scope: "variable" | ||
@@ -294,3 +236,3 @@ }; | ||
relevance: 0, | ||
match: concat( | ||
match: regex.concat( | ||
"\\b(?!", | ||
@@ -297,0 +239,0 @@ ALL_KWS.join("|"), |
@@ -1,68 +0,1 @@ | ||
/** | ||
* @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 } re | ||
* @returns {string} | ||
*/ | ||
function optional(re) { | ||
return concat('(?:', re, ')?'); | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
function stripOptionsFromArgs(args) { | ||
const opts = args[args.length - 1]; | ||
if (typeof opts === 'object' && opts.constructor === Object) { | ||
args.splice(args.length - 1, 1); | ||
return opts; | ||
} else { | ||
return {}; | ||
} | ||
} | ||
/** | ||
* 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 opts = stripOptionsFromArgs(args); | ||
const joined = '(' + | ||
(opts.capture ? "" : "?:") + | ||
args.map((x) => source(x)).join("|") + ")"; | ||
return joined; | ||
} | ||
/* | ||
@@ -77,4 +10,5 @@ Language: HTML, XML | ||
function xml(hljs) { | ||
const regex = hljs.regex; | ||
// Element names can contain letters, digits, hyphens, underscores, and periods | ||
const TAG_NAME_RE = concat(/[A-Z_]/, optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/); | ||
const TAG_NAME_RE = regex.concat(/[A-Z_]/, regex.optional(/[A-Z0-9_.-]*:/), /[A-Z0-9_.-]*/); | ||
const XML_IDENT_RE = /[A-Za-z0-9._:-]+/; | ||
@@ -255,5 +189,5 @@ const XML_ENTITIES = { | ||
className: 'tag', | ||
begin: concat( | ||
begin: regex.concat( | ||
/</, | ||
lookahead(concat( | ||
regex.lookahead(regex.concat( | ||
TAG_NAME_RE, | ||
@@ -263,3 +197,3 @@ // <tag/> | ||
// <tag ... | ||
either(/\/>/, />/, /\s/) | ||
regex.either(/\/>/, />/, /\s/) | ||
)) | ||
@@ -280,5 +214,5 @@ ), | ||
className: 'tag', | ||
begin: concat( | ||
begin: regex.concat( | ||
/<\//, | ||
lookahead(concat( | ||
regex.lookahead(regex.concat( | ||
TAG_NAME_RE, />/ | ||
@@ -285,0 +219,0 @@ )) |
@@ -9,3 +9,3 @@ { | ||
"homepage": "https://highlightjs.org/", | ||
"version": "11.2.0", | ||
"version": "11.3.0", | ||
"author": { | ||
@@ -58,6 +58,6 @@ "name": "Ivan Sagalaev", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^19.0.0", | ||
"@rollup/plugin-commonjs": "^21.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@types/mocha": "^8.2.2", | ||
"@types/mocha": "^9.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
@@ -68,3 +68,3 @@ "@typescript-eslint/parser": "^4.23.0", | ||
"colors": "^1.1.2", | ||
"commander": "^7.0.0", | ||
"commander": "8.2", | ||
"css": "^3.0.0", | ||
@@ -76,11 +76,11 @@ "deep-freeze-es6": "^1.4.1", | ||
"eslint-config-standard": "^16.0.1", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"glob": "^7.1.7", | ||
"glob-promise": "^4.0.1", | ||
"glob-promise": "^4.2.1", | ||
"handlebars": "^4.7.6", | ||
"jsdom": "^16.6.0", | ||
"jsdom": "^18.0.0", | ||
"lodash": "^4.17.20", | ||
"mocha": "^8.4.0", | ||
"mocha": "^9.1.3", | ||
"refa": "^0.4.1", | ||
@@ -91,3 +91,3 @@ "rollup": "^2.47.0", | ||
"tiny-worker": "^2.3.0", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.4.4" | ||
}, | ||
@@ -94,0 +94,0 @@ "exports": { |
@@ -66,6 +66,2 @@ # Highlight.js | ||
**Upgrading to v10**: You really should probably be upgrading to version 11... but if you're coming from version 9 then these documents may still prove helpful. | ||
- [VERSION_10_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_UPGRADE.md) and [VERSION_10_BREAKING_CHANGES.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_BREAKING_CHANGES.md) | ||
#### Support for older versions <!-- omit in toc --> | ||
@@ -328,6 +324,6 @@ | ||
```html | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/default.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.0/styles/default.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.0/highlight.min.js"></script> | ||
<!-- and it's easy to individually load additional languages --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/languages/go.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.0/languages/go.min.js"></script> | ||
``` | ||
@@ -338,6 +334,6 @@ | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.2.0/build/styles/default.min.css"> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.2.0/build/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.0/build/styles/default.min.css"> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.0/build/highlight.min.js"></script> | ||
<!-- and it's easy to individually load additional languages --> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.2.0/build/languages/go.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.0/build/languages/go.min.js"></script> | ||
``` | ||
@@ -348,6 +344,6 @@ | ||
```html | ||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.2.0/styles/default.min.css"> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.2.0/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.3.0/styles/default.min.css"> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.3.0/highlight.min.js"></script> | ||
<!-- and it's easy to individually load additional languages --> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.2.0/languages/go.min.js"></script> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.3.0/languages/go.min.js"></script> | ||
``` | ||
@@ -354,0 +350,0 @@ |
@@ -10,3 +10,3 @@ # Security Policy | ||
| 11.x | :white_check_mark: | The 11.x series recieves regular updates, new features & security fixes. | | ||
| 10.7.x | :white_check_mark: | The 10.x series is now in maintence mode. EOL TBD.<br>See [VERSION_11_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/master/VERSION_11_UPGRADE.md).| | ||
| 10.7.x | :x: | No longer supported. <br>See [VERSION_11_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/master/VERSION_11_UPGRADE.md).| | ||
| <= 10.4.0 | :x: | Known vulnerabities. | | ||
@@ -13,0 +13,0 @@ | <= 9.18.5 | :x: | Known vulnerabities. [EOL](https://github.com/highlightjs/highlight.js/issues/2877) | |
@@ -12,2 +12,3 @@ # Supported Languages | ||
| 4D | 4d |[highlightjs-4d](https://github.com/highlightjs/highlightjs-4d) | | ||
| ABAP | sap-abap, abap |[highlight-sap-abap](https://github.com/highlightjs/highlightjs-sap-abap) | | ||
| ABNF | abnf | | | ||
@@ -57,4 +58,3 @@ | Access logs | accesslog | | | ||
| D | d | | | ||
| DNS Zone file | dns, zone, bind | | | ||
| DOS | dos, bat, cmd | | | ||
| Dafny | dafny | [highlightjs-dafny](https://github.com/ConsenSys/highlightjs-dafny)| | ||
| Dart | dart | | | ||
@@ -64,3 +64,5 @@ | Delphi | dpr, dfm, pas, pascal | | | ||
| Django | django, jinja | | | ||
| DNS Zone file | dns, zone, bind | | | ||
| Dockerfile | dockerfile, docker | | | ||
| DOS | dos, bat, cmd | | | ||
| dsconfig | dsconfig | | | ||
@@ -127,2 +129,3 @@ | DTS (Device Tree) | dts | | | ||
| Mizar | mizar | | | ||
| MKB | mkb | [highlightjs-mkb](https://github.com/Dereavy/highlightjs-mkb) | | ||
| Mojolicious | mojolicious | | | ||
@@ -129,0 +132,0 @@ | Monkey | monkey | | |
@@ -18,3 +18,3 @@ /* eslint-disable no-unused-vars */ | ||
import { KeywordDict} from "highlight.js/private"; | ||
import { KeywordDict } from "highlight.js/private"; | ||
@@ -138,2 +138,3 @@ export type HLJSApi = PublicApi & ModesAPI | ||
ignoreUnescapedHTML?: boolean | ||
throwUnescapedHTML?: boolean | ||
} | ||
@@ -153,2 +154,3 @@ | ||
name?: string | ||
unicodeRegex?: boolean | ||
rawDefinition?: () => Language | ||
@@ -195,4 +197,9 @@ aliases?: string[] | ||
export type CompiledScope = Record<number, string> & {_emit?: Record<number, boolean>, _multi?: boolean, _wrap?: string}; | ||
export type CompiledMode = Omit<Mode, 'contains'> & | ||
{ | ||
begin?: RegExp | string | ||
end?: RegExp | string | ||
scope?: string | ||
contains: CompiledMode[] | ||
@@ -210,4 +217,4 @@ keywords: KeywordDict | ||
parent?: CompiledMode | ||
beginScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string} | ||
endScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string} | ||
beginScope?: CompiledScope | ||
endScope?: CompiledScope | ||
} | ||
@@ -214,0 +221,0 @@ |
@@ -14,2 +14,3 @@ # Upgrading to Highlight.js v11.0 | ||
- [Small Things](#small-things) | ||
- [Upgrading from Version 9.x](#upgrading-from-version-9x) | ||
@@ -67,3 +68,3 @@ | ||
- The `.hljs` CSS selector is now further scoped. It now targets `code.hljs` (inline code) and `pre code.hljs` (code blocks). If you are using a different element you may need to update your CSS to reapply some styling. | ||
- All [Base16 themes](https://github.com/highlightjs/base16-highlightjs) now live in the `styles/base16` directory - this means some CSS files have moved. Please confirm themes you use reference the new locations. | ||
- All [Base16 themes](https://github.com/highlightjs/base16-highlightjs) now live in the `styles/base16` directory - this means some CSS files have moved. Please confirm themes you use reference the new locations. | ||
@@ -196,2 +197,10 @@ | ||
### Upgrading from Version 9.x | ||
If you're upgrading all the way from version 9 it may still be helpful to review all the breaking changes in version 10 as well: | ||
- [VERSION_10_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_UPGRADE.md) | ||
- [VERSION_10_BREAKING_CHANGES.md](https://github.com/highlightjs/highlight.js/blob/main/VERSION_10_BREAKING_CHANGES.md) | ||
[meta-keyword]: https://github.com/highlightjs/highlight.js/pull/3167 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3837123
112151
421