highlight.js
Advanced tools
Comparing version 11.0.1 to 11.1.0
@@ -146,3 +146,3 @@ /* | ||
name: 'Clojure', | ||
aliases: [ 'clj' ], | ||
aliases: [ 'clj', 'edn' ], | ||
illegal: /\S/, | ||
@@ -149,0 +149,0 @@ contains: [ |
@@ -62,2 +62,3 @@ /* | ||
'case', | ||
'catch', | ||
'class', | ||
@@ -64,0 +65,0 @@ 'const', |
@@ -22,2 +22,3 @@ /* | ||
"img-src", | ||
"manifest-src", | ||
"media-src", | ||
@@ -29,3 +30,6 @@ "object-src", | ||
"script-src", | ||
"style-src" | ||
"style-src", | ||
"trusted-types", | ||
"unsafe-hashes", | ||
"worker-src" | ||
]; | ||
@@ -32,0 +36,0 @@ return { |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -546,2 +550,3 @@ }; | ||
// }, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -548,0 +553,0 @@ className: 'attribute', |
@@ -0,1 +1,26 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -13,7 +38,43 @@ Language: Elixir | ||
const ELIXIR_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; | ||
const ELIXIR_KEYWORDS = { | ||
const KEYWORDS = [ | ||
"after", | ||
"alias", | ||
"and", | ||
"case", | ||
"catch", | ||
"cond", | ||
"defstruct", | ||
"do", | ||
"else", | ||
"end", | ||
"fn", | ||
"for", | ||
"if", | ||
"import", | ||
"in", | ||
"not", | ||
"or", | ||
"quote", | ||
"raise", | ||
"receive", | ||
"require", | ||
"reraise", | ||
"rescue", | ||
"try", | ||
"unless", | ||
"unquote", | ||
"unquote_splicing", | ||
"use", | ||
"when", | ||
"with|0" | ||
]; | ||
const LITERALS = [ | ||
"false", | ||
"nil", | ||
"true" | ||
]; | ||
const KWS = { | ||
$pattern: ELIXIR_IDENT_RE, | ||
keyword: 'and false then defined module in return redo retry end for true self when ' + | ||
'next until do begin unless nil break not case cond alias while ensure or ' + | ||
'include use alias fn quote require import with|0' | ||
keyword: KEYWORDS, | ||
literal: LITERALS | ||
}; | ||
@@ -24,60 +85,75 @@ const SUBST = { | ||
end: /\}/, | ||
keywords: ELIXIR_KEYWORDS | ||
keywords: KWS | ||
}; | ||
const NUMBER = { | ||
className: 'number', | ||
begin: '(\\b0o[0-7_]+)|(\\b0b[01_]+)|(\\b0x[0-9a-fA-F_]+)|(-?\\b[1-9][0-9_]*(\\.[0-9_]+([eE][-+]?[0-9]+)?)?)', | ||
begin: '(\\b0o[0-7_]+)|(\\b0b[01_]+)|(\\b0x[0-9a-fA-F_]+)|(-?\\b[0-9][0-9_]*(\\.[0-9_]+([eE][-+]?[0-9]+)?)?)', | ||
relevance: 0 | ||
}; | ||
// TODO: could be tightened | ||
// https://elixir-lang.readthedocs.io/en/latest/intro/18.html | ||
// but you also need to include closing delemeters in the escape list per | ||
// individual sigil mode from what I can tell, | ||
// ie: \} might or might not be an escape depending on the sigil used | ||
const ESCAPES_RE = /\\[\s\S]/; | ||
// const ESCAPES_RE = /\\["'\\abdefnrstv0]/; | ||
const BACKSLASH_ESCAPE = { | ||
match: ESCAPES_RE, | ||
scope: "char.escape", | ||
relevance: 0 | ||
}; | ||
const SIGIL_DELIMITERS = '[/|([{<"\']'; | ||
const SIGIL_DELIMITER_MODES = [ | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
} | ||
]; | ||
const escapeSigilEnd = (end) => { | ||
return { | ||
scope: "char.escape", | ||
begin: concat(/\\/, end), | ||
relevance: 0 | ||
}; | ||
}; | ||
const LOWERCASE_SIGIL = { | ||
className: 'string', | ||
begin: '~[a-z]' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: [ | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
endsParent: true, | ||
contains: [ | ||
{ | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
], | ||
variants: [ | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
} | ||
] | ||
} | ||
escapeSigilEnd(x.end), | ||
BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
} | ||
] | ||
)) | ||
}; | ||
@@ -88,34 +164,33 @@ | ||
begin: '~[A-Z]' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: [ | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
contains: [ escapeSigilEnd(x.end) ] | ||
} | ||
)) | ||
}; | ||
const REGEX_SIGIL = { | ||
className: 'regex', | ||
variants: [ | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
begin: '~r' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ | ||
escapeSigilEnd(x.end), | ||
BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
} | ||
)) | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
begin: '~R' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ escapeSigilEnd(x.end) ] | ||
}) | ||
) | ||
} | ||
@@ -172,3 +247,3 @@ ] | ||
className: 'function', | ||
beginKeywords: 'def defp defmacro', | ||
beginKeywords: 'def defp defmacro defmacrop', | ||
end: /\B\b/, // the mode is ended by the title | ||
@@ -189,2 +264,3 @@ contains: [ | ||
STRING, | ||
REGEX_SIGIL, | ||
UPCASE_SIGIL, | ||
@@ -221,34 +297,2 @@ LOWERCASE_SIGIL, | ||
begin: '->' | ||
}, | ||
{ // regexp container | ||
begin: '(' + hljs.RE_STARTERS_RE + ')\\s*', | ||
contains: [ | ||
hljs.HASH_COMMENT_MODE, | ||
{ | ||
// to prevent false regex triggers for the division function: | ||
// /: | ||
begin: /\/: (?=\d+\s*[,\]])/, | ||
relevance: 0, | ||
contains: [NUMBER] | ||
}, | ||
{ | ||
className: 'regexp', | ||
illegal: '\\n', | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
], | ||
variants: [ | ||
{ | ||
begin: '/', | ||
end: '/[a-z]*' | ||
}, | ||
{ | ||
begin: '%r\\[', | ||
end: '\\][a-z]*' | ||
} | ||
] | ||
} | ||
], | ||
relevance: 0 | ||
} | ||
@@ -260,3 +304,4 @@ ]; | ||
name: 'Elixir', | ||
keywords: ELIXIR_KEYWORDS, | ||
aliases: ['ex', 'exs'], | ||
keywords: KWS, | ||
contains: ELIXIR_DEFAULT_CONTAINS | ||
@@ -263,0 +308,0 @@ }; |
@@ -472,3 +472,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
relevance: 0, | ||
match: /\b[A-Z][A-Z_]+\b/, | ||
match: /\b[A-Z][A-Z_0-9]+\b/, | ||
className: "variable.constant" | ||
@@ -475,0 +475,0 @@ }; |
@@ -148,3 +148,3 @@ /** | ||
className: 'meta', | ||
begin: '% !TeX', | ||
begin: /% ?!(T[eE]X|tex|BIB|bib)/, | ||
end: '$', | ||
@@ -151,0 +151,0 @@ relevance: 10 |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -555,2 +559,3 @@ }; | ||
}, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -557,0 +562,0 @@ className: 'attribute', |
@@ -131,3 +131,3 @@ /** | ||
{ | ||
begin: /\[.+?\]\(.*?\)/, | ||
begin: /\[.*?\]\(.*?\)/, | ||
relevance: 0 | ||
@@ -139,2 +139,6 @@ } | ||
{ | ||
// empty strings for alt or link text | ||
match: /\[(?=\])/ | ||
}, | ||
{ | ||
className: 'string', | ||
@@ -141,0 +145,0 @@ relevance: 0, |
@@ -330,3 +330,3 @@ /* | ||
'build create index delete drop explain infer|10 insert merge prepare select update upsert|10', | ||
end: /;/, endsWithParent: true, | ||
end: /;/, | ||
keywords: { | ||
@@ -340,15 +340,17 @@ keyword: KEYWORDS, | ||
className: 'string', | ||
begin: '\'', end: '\'', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
begin: '\'', | ||
end: '\'', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
{ | ||
className: 'string', | ||
begin: '"', end: '"', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
begin: '"', | ||
end: '"', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
{ | ||
className: 'symbol', | ||
begin: '`', end: '`', | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
relevance: 2 | ||
begin: '`', | ||
end: '`', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
@@ -355,0 +357,0 @@ hljs.C_NUMBER_MODE, |
@@ -239,3 +239,3 @@ /* | ||
className: 'literal', | ||
begin: /(-)[\w\d]+/, | ||
begin: /(-){1,2}[\w\d-]+/, | ||
relevance: 0 | ||
@@ -317,2 +317,3 @@ } | ||
aliases: [ | ||
"pwsh", | ||
"ps", | ||
@@ -319,0 +320,0 @@ "ps1" |
@@ -88,3 +88,3 @@ /** | ||
const IDENT_RE = '[a-zA-Z]\\w*'; | ||
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; | ||
/** | ||
@@ -545,3 +545,3 @@ * Creates a comment mode | ||
/def/, /\s+/, | ||
IDENT_RE | ||
UNDERSCORE_IDENT_RE | ||
], | ||
@@ -559,4 +559,4 @@ scope: { | ||
/class/, /\s+/, | ||
IDENT_RE, /\s*/, | ||
/\(\s*/, IDENT_RE,/\s*\)/ | ||
UNDERSCORE_IDENT_RE, /\s*/, | ||
/\(\s*/, UNDERSCORE_IDENT_RE,/\s*\)/ | ||
], | ||
@@ -567,3 +567,3 @@ }, | ||
/class/, /\s+/, | ||
IDENT_RE | ||
UNDERSCORE_IDENT_RE | ||
], | ||
@@ -570,0 +570,0 @@ } |
@@ -17,2 +17,19 @@ /** | ||
/** | ||
* @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) { | ||
@@ -129,16 +146,11 @@ const opts = args[args.length - 1]; | ||
scope: 'doctag', | ||
begin: '@examples', | ||
match: /@examples/, | ||
starts: { | ||
contains: [ | ||
{ begin: /\n/ }, | ||
{ | ||
begin: /#'\s*(?=@[a-zA-Z]+)/, | ||
endsParent: true, | ||
}, | ||
{ | ||
begin: /#'/, | ||
end: /$/, | ||
excludeBegin: true, | ||
} | ||
] | ||
end: lookahead(either( | ||
// end if another doc comment | ||
/\n^#'\s*(?=@[a-zA-Z]+)/, | ||
// or a line with no comment | ||
/\n^(?!#')/ | ||
)), | ||
endsParent: true | ||
} | ||
@@ -156,4 +168,4 @@ }, | ||
variants: [ | ||
{ begin: IDENT_RE }, | ||
{ begin: /`(?:\\.|[^`\\])+`/ } | ||
{ match: IDENT_RE }, | ||
{ match: /`(?:\\.|[^`\\])+`/ } | ||
], | ||
@@ -166,7 +178,7 @@ endsParent: true | ||
scope: 'doctag', | ||
begin: /@[a-zA-Z]+/ | ||
match: /@[a-zA-Z]+/ | ||
}, | ||
{ | ||
scope: 'keyword', | ||
begin: /\\[a-zA-Z]+/, | ||
match: /\\[a-zA-Z]+/ | ||
} | ||
@@ -173,0 +185,0 @@ ] |
@@ -286,3 +286,3 @@ /** | ||
{ | ||
// negative-look forward attemps to prevent false matches like: | ||
// negative-look forward attempts to prevent false matches like: | ||
// @ident@ or $ident$ that might indicate this is not ruby at all | ||
@@ -289,0 +289,0 @@ className: "variable", |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -503,2 +507,3 @@ }; | ||
}, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -505,0 +510,0 @@ className: 'attribute', |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -597,2 +601,5 @@ }; | ||
// css variables | ||
modes.CSS_VARIABLE, | ||
// attributes | ||
@@ -599,0 +606,0 @@ // - only from beginning of line + whitespace |
@@ -472,3 +472,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
relevance: 0, | ||
match: /\b[A-Z][A-Z_]+\b/, | ||
match: /\b[A-Z][A-Z_0-9]+\b/, | ||
className: "variable.constant" | ||
@@ -475,0 +475,0 @@ }; |
@@ -219,3 +219,3 @@ /** | ||
relevance: 0, | ||
match: /[A-Z]+[a-z]+([A-Z]+[a-z]+)*/, | ||
match: /\b[A-Z]+[a-z]+([A-Z]+[a-z]+)*/, | ||
scope: "title.class", | ||
@@ -222,0 +222,0 @@ keywords: { |
@@ -146,3 +146,3 @@ /* | ||
name: 'Clojure', | ||
aliases: [ 'clj' ], | ||
aliases: [ 'clj', 'edn' ], | ||
illegal: /\S/, | ||
@@ -149,0 +149,0 @@ contains: [ |
@@ -62,2 +62,3 @@ /* | ||
'case', | ||
'catch', | ||
'class', | ||
@@ -64,0 +65,0 @@ 'const', |
@@ -22,2 +22,3 @@ /* | ||
"img-src", | ||
"manifest-src", | ||
"media-src", | ||
@@ -29,3 +30,6 @@ "object-src", | ||
"script-src", | ||
"style-src" | ||
"style-src", | ||
"trusted-types", | ||
"unsafe-hashes", | ||
"worker-src" | ||
]; | ||
@@ -32,0 +36,0 @@ return { |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -546,2 +550,3 @@ }; | ||
// }, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -548,0 +553,0 @@ className: 'attribute', |
@@ -0,1 +1,26 @@ | ||
/** | ||
* @param {string} value | ||
* @returns {RegExp} | ||
* */ | ||
/** | ||
* @param {RegExp | string } re | ||
* @returns {string} | ||
*/ | ||
function source(re) { | ||
if (!re) return null; | ||
if (typeof re === "string") return re; | ||
return re.source; | ||
} | ||
/** | ||
* @param {...(RegExp | string) } args | ||
* @returns {string} | ||
*/ | ||
function concat(...args) { | ||
const joined = args.map((x) => source(x)).join(""); | ||
return joined; | ||
} | ||
/* | ||
@@ -13,7 +38,43 @@ Language: Elixir | ||
const ELIXIR_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; | ||
const ELIXIR_KEYWORDS = { | ||
const KEYWORDS = [ | ||
"after", | ||
"alias", | ||
"and", | ||
"case", | ||
"catch", | ||
"cond", | ||
"defstruct", | ||
"do", | ||
"else", | ||
"end", | ||
"fn", | ||
"for", | ||
"if", | ||
"import", | ||
"in", | ||
"not", | ||
"or", | ||
"quote", | ||
"raise", | ||
"receive", | ||
"require", | ||
"reraise", | ||
"rescue", | ||
"try", | ||
"unless", | ||
"unquote", | ||
"unquote_splicing", | ||
"use", | ||
"when", | ||
"with|0" | ||
]; | ||
const LITERALS = [ | ||
"false", | ||
"nil", | ||
"true" | ||
]; | ||
const KWS = { | ||
$pattern: ELIXIR_IDENT_RE, | ||
keyword: 'and false then defined module in return redo retry end for true self when ' + | ||
'next until do begin unless nil break not case cond alias while ensure or ' + | ||
'include use alias fn quote require import with|0' | ||
keyword: KEYWORDS, | ||
literal: LITERALS | ||
}; | ||
@@ -24,60 +85,75 @@ const SUBST = { | ||
end: /\}/, | ||
keywords: ELIXIR_KEYWORDS | ||
keywords: KWS | ||
}; | ||
const NUMBER = { | ||
className: 'number', | ||
begin: '(\\b0o[0-7_]+)|(\\b0b[01_]+)|(\\b0x[0-9a-fA-F_]+)|(-?\\b[1-9][0-9_]*(\\.[0-9_]+([eE][-+]?[0-9]+)?)?)', | ||
begin: '(\\b0o[0-7_]+)|(\\b0b[01_]+)|(\\b0x[0-9a-fA-F_]+)|(-?\\b[0-9][0-9_]*(\\.[0-9_]+([eE][-+]?[0-9]+)?)?)', | ||
relevance: 0 | ||
}; | ||
// TODO: could be tightened | ||
// https://elixir-lang.readthedocs.io/en/latest/intro/18.html | ||
// but you also need to include closing delemeters in the escape list per | ||
// individual sigil mode from what I can tell, | ||
// ie: \} might or might not be an escape depending on the sigil used | ||
const ESCAPES_RE = /\\[\s\S]/; | ||
// const ESCAPES_RE = /\\["'\\abdefnrstv0]/; | ||
const BACKSLASH_ESCAPE = { | ||
match: ESCAPES_RE, | ||
scope: "char.escape", | ||
relevance: 0 | ||
}; | ||
const SIGIL_DELIMITERS = '[/|([{<"\']'; | ||
const SIGIL_DELIMITER_MODES = [ | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
} | ||
]; | ||
const escapeSigilEnd = (end) => { | ||
return { | ||
scope: "char.escape", | ||
begin: concat(/\\/, end), | ||
relevance: 0 | ||
}; | ||
}; | ||
const LOWERCASE_SIGIL = { | ||
className: 'string', | ||
begin: '~[a-z]' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: [ | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
endsParent: true, | ||
contains: [ | ||
{ | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
], | ||
variants: [ | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
} | ||
] | ||
} | ||
escapeSigilEnd(x.end), | ||
BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
} | ||
] | ||
)) | ||
}; | ||
@@ -88,34 +164,33 @@ | ||
begin: '~[A-Z]' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: [ | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
begin: /"/, | ||
end: /"/ | ||
}, | ||
contains: [ escapeSigilEnd(x.end) ] | ||
} | ||
)) | ||
}; | ||
const REGEX_SIGIL = { | ||
className: 'regex', | ||
variants: [ | ||
{ | ||
begin: /'/, | ||
end: /'/ | ||
begin: '~r' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ | ||
escapeSigilEnd(x.end), | ||
BACKSLASH_ESCAPE, | ||
SUBST | ||
] | ||
} | ||
)) | ||
}, | ||
{ | ||
begin: /\//, | ||
end: /\// | ||
}, | ||
{ | ||
begin: /\|/, | ||
end: /\|/ | ||
}, | ||
{ | ||
begin: /\(/, | ||
end: /\)/ | ||
}, | ||
{ | ||
begin: /\[/, | ||
end: /\]/ | ||
}, | ||
{ | ||
begin: /\{/, | ||
end: /\}/ | ||
}, | ||
{ | ||
begin: /</, | ||
end: />/ | ||
begin: '~R' + '(?=' + SIGIL_DELIMITERS + ')', | ||
contains: SIGIL_DELIMITER_MODES.map(x => hljs.inherit(x, | ||
{ | ||
end: concat(x.end, /[uismxfU]{0,7}/), | ||
contains: [ escapeSigilEnd(x.end) ] | ||
}) | ||
) | ||
} | ||
@@ -172,3 +247,3 @@ ] | ||
className: 'function', | ||
beginKeywords: 'def defp defmacro', | ||
beginKeywords: 'def defp defmacro defmacrop', | ||
end: /\B\b/, // the mode is ended by the title | ||
@@ -189,2 +264,3 @@ contains: [ | ||
STRING, | ||
REGEX_SIGIL, | ||
UPCASE_SIGIL, | ||
@@ -221,34 +297,2 @@ LOWERCASE_SIGIL, | ||
begin: '->' | ||
}, | ||
{ // regexp container | ||
begin: '(' + hljs.RE_STARTERS_RE + ')\\s*', | ||
contains: [ | ||
hljs.HASH_COMMENT_MODE, | ||
{ | ||
// to prevent false regex triggers for the division function: | ||
// /: | ||
begin: /\/: (?=\d+\s*[,\]])/, | ||
relevance: 0, | ||
contains: [NUMBER] | ||
}, | ||
{ | ||
className: 'regexp', | ||
illegal: '\\n', | ||
contains: [ | ||
hljs.BACKSLASH_ESCAPE, | ||
SUBST | ||
], | ||
variants: [ | ||
{ | ||
begin: '/', | ||
end: '/[a-z]*' | ||
}, | ||
{ | ||
begin: '%r\\[', | ||
end: '\\][a-z]*' | ||
} | ||
] | ||
} | ||
], | ||
relevance: 0 | ||
} | ||
@@ -260,3 +304,4 @@ ]; | ||
name: 'Elixir', | ||
keywords: ELIXIR_KEYWORDS, | ||
aliases: ['ex', 'exs'], | ||
keywords: KWS, | ||
contains: ELIXIR_DEFAULT_CONTAINS | ||
@@ -263,0 +308,0 @@ }; |
@@ -472,3 +472,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
relevance: 0, | ||
match: /\b[A-Z][A-Z_]+\b/, | ||
match: /\b[A-Z][A-Z_0-9]+\b/, | ||
className: "variable.constant" | ||
@@ -475,0 +475,0 @@ }; |
@@ -148,3 +148,3 @@ /** | ||
className: 'meta', | ||
begin: '% !TeX', | ||
begin: /% ?!(T[eE]X|tex|BIB|bib)/, | ||
end: '$', | ||
@@ -151,0 +151,0 @@ relevance: 10 |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -555,2 +559,3 @@ }; | ||
}, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -557,0 +562,0 @@ className: 'attribute', |
@@ -131,3 +131,3 @@ /** | ||
{ | ||
begin: /\[.+?\]\(.*?\)/, | ||
begin: /\[.*?\]\(.*?\)/, | ||
relevance: 0 | ||
@@ -139,2 +139,6 @@ } | ||
{ | ||
// empty strings for alt or link text | ||
match: /\[(?=\])/ | ||
}, | ||
{ | ||
className: 'string', | ||
@@ -141,0 +145,0 @@ relevance: 0, |
@@ -330,3 +330,3 @@ /* | ||
'build create index delete drop explain infer|10 insert merge prepare select update upsert|10', | ||
end: /;/, endsWithParent: true, | ||
end: /;/, | ||
keywords: { | ||
@@ -340,15 +340,17 @@ keyword: KEYWORDS, | ||
className: 'string', | ||
begin: '\'', end: '\'', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
begin: '\'', | ||
end: '\'', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
{ | ||
className: 'string', | ||
begin: '"', end: '"', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
begin: '"', | ||
end: '"', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
{ | ||
className: 'symbol', | ||
begin: '`', end: '`', | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
relevance: 2 | ||
begin: '`', | ||
end: '`', | ||
contains: [ hljs.BACKSLASH_ESCAPE ] | ||
}, | ||
@@ -355,0 +357,0 @@ hljs.C_NUMBER_MODE, |
@@ -239,3 +239,3 @@ /* | ||
className: 'literal', | ||
begin: /(-)[\w\d]+/, | ||
begin: /(-){1,2}[\w\d-]+/, | ||
relevance: 0 | ||
@@ -317,2 +317,3 @@ } | ||
aliases: [ | ||
"pwsh", | ||
"ps", | ||
@@ -319,0 +320,0 @@ "ps1" |
@@ -88,3 +88,3 @@ /** | ||
const IDENT_RE = '[a-zA-Z]\\w*'; | ||
const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; | ||
/** | ||
@@ -545,3 +545,3 @@ * Creates a comment mode | ||
/def/, /\s+/, | ||
IDENT_RE | ||
UNDERSCORE_IDENT_RE | ||
], | ||
@@ -559,4 +559,4 @@ scope: { | ||
/class/, /\s+/, | ||
IDENT_RE, /\s*/, | ||
/\(\s*/, IDENT_RE,/\s*\)/ | ||
UNDERSCORE_IDENT_RE, /\s*/, | ||
/\(\s*/, UNDERSCORE_IDENT_RE,/\s*\)/ | ||
], | ||
@@ -567,3 +567,3 @@ }, | ||
/class/, /\s+/, | ||
IDENT_RE | ||
UNDERSCORE_IDENT_RE | ||
], | ||
@@ -570,0 +570,0 @@ } |
@@ -17,2 +17,19 @@ /** | ||
/** | ||
* @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) { | ||
@@ -129,16 +146,11 @@ const opts = args[args.length - 1]; | ||
scope: 'doctag', | ||
begin: '@examples', | ||
match: /@examples/, | ||
starts: { | ||
contains: [ | ||
{ begin: /\n/ }, | ||
{ | ||
begin: /#'\s*(?=@[a-zA-Z]+)/, | ||
endsParent: true, | ||
}, | ||
{ | ||
begin: /#'/, | ||
end: /$/, | ||
excludeBegin: true, | ||
} | ||
] | ||
end: lookahead(either( | ||
// end if another doc comment | ||
/\n^#'\s*(?=@[a-zA-Z]+)/, | ||
// or a line with no comment | ||
/\n^(?!#')/ | ||
)), | ||
endsParent: true | ||
} | ||
@@ -156,4 +168,4 @@ }, | ||
variants: [ | ||
{ begin: IDENT_RE }, | ||
{ begin: /`(?:\\.|[^`\\])+`/ } | ||
{ match: IDENT_RE }, | ||
{ match: /`(?:\\.|[^`\\])+`/ } | ||
], | ||
@@ -166,7 +178,7 @@ endsParent: true | ||
scope: 'doctag', | ||
begin: /@[a-zA-Z]+/ | ||
match: /@[a-zA-Z]+/ | ||
}, | ||
{ | ||
scope: 'keyword', | ||
begin: /\\[a-zA-Z]+/, | ||
match: /\\[a-zA-Z]+/ | ||
} | ||
@@ -173,0 +185,0 @@ ] |
@@ -286,3 +286,3 @@ /** | ||
{ | ||
// negative-look forward attemps to prevent false matches like: | ||
// negative-look forward attempts to prevent false matches like: | ||
// @ident@ or $ident$ that might indicate this is not ruby at all | ||
@@ -289,0 +289,0 @@ className: "variable", |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -503,2 +507,3 @@ }; | ||
}, | ||
modes.CSS_VARIABLE, | ||
{ | ||
@@ -505,0 +510,0 @@ className: 'attribute', |
@@ -33,2 +33,6 @@ const MODES = (hljs) => { | ||
relevance: 0 | ||
}, | ||
CSS_VARIABLE: { | ||
className: "attr", | ||
begin: /--[A-Za-z][A-Za-z0-9_-]*/ | ||
} | ||
@@ -597,2 +601,5 @@ }; | ||
// css variables | ||
modes.CSS_VARIABLE, | ||
// attributes | ||
@@ -599,0 +606,0 @@ // - only from beginning of line + whitespace |
@@ -472,3 +472,3 @@ const IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
relevance: 0, | ||
match: /\b[A-Z][A-Z_]+\b/, | ||
match: /\b[A-Z][A-Z_0-9]+\b/, | ||
className: "variable.constant" | ||
@@ -475,0 +475,0 @@ }; |
@@ -219,3 +219,3 @@ /** | ||
relevance: 0, | ||
match: /[A-Z]+[a-z]+([A-Z]+[a-z]+)*/, | ||
match: /\b[A-Z]+[a-z]+([A-Z]+[a-z]+)*/, | ||
scope: "title.class", | ||
@@ -222,0 +222,0 @@ keywords: { |
@@ -9,3 +9,3 @@ { | ||
"homepage": "https://highlightjs.org/", | ||
"version": "11.0.1", | ||
"version": "11.1.0", | ||
"author": { | ||
@@ -12,0 +12,0 @@ "name": "Ivan Sagalaev", |
@@ -80,3 +80,3 @@ # Highlight.js | ||
The bare minimum for using highlight.js on a web page is linking to the | ||
library along with one of the styles and calling [`highlightAll`][1]: | ||
library along with one of the themes and calling [`highlightAll`][1]: | ||
@@ -328,6 +328,6 @@ ```html | ||
```html | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/default.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/default.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.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.0.1/languages/go.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/languages/go.min.js"></script> | ||
``` | ||
@@ -338,6 +338,6 @@ | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.0.1/build/styles/default.min.css"> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.0.1/build/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.1.0/build/styles/default.min.css"> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.1.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.0.1/build/languages/go.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.1.0/build/languages/go.min.js"></script> | ||
``` | ||
@@ -348,6 +348,6 @@ | ||
```html | ||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.0.1/styles/default.min.css"> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.0.1/highlight.min.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.1.0/styles/default.min.css"> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.1.0/highlight.min.js"></script> | ||
<!-- and it's easy to individually load additional languages --> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.0.1/languages/go.min.js"></script> | ||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.1.0/languages/go.min.js"></script> | ||
``` | ||
@@ -354,0 +354,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.3 | :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 | :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.4.0 | :x: | Known vulnerabities. | | ||
@@ -13,0 +13,0 @@ | <= 9.18.5 | :x: | Known vulnerabities. [EOL](https://github.com/highlightjs/highlight.js/issues/2877) | |
# Supported Languages | ||
The table below shows the full list of supported languages (and corresponding classes/aliases). Note: Which languages are available may depend on how you've built or included the library in your app. See [Getting the Library][1] in the README. | ||
The table below shows the full list of languages (and corresponding classes/aliases) supported by Highlight.js. Languages that list a **Package** below are 3rd party languages and are not bundled with the core library. You can find their repositories by following the links. | ||
Languages that listed a **Package** below are 3rd party languages and are not bundled with the core library. You can find their repositories by following the links. | ||
**Note:** The languages available will depend on how you've built or are included the library in your app. For example our default minified web build includes only ~40 popular languages. See [Getting the Library][1] and [Importing the Library][2] in the README for examples of how to load additional/specific languages. | ||
<!-- LANGLIST --> | ||
| Language | Classes | Package | | ||
| Language | Aliases | Package | | ||
| :-----------------------| :--------------------- | :------ | | ||
@@ -59,3 +59,3 @@ | 1C | 1c | | | ||
| Dart | dart | | | ||
| Delphi | delphi, dpr, dfm, pas, pascal, freepascal, lazarus, lpr, lfm | | | ||
| Delphi | dpr, dfm, pas, pascal | | | ||
| Diff | diff, patch | | | ||
@@ -142,3 +142,3 @@ | Django | django, jinja | | | ||
| PF | pf, pf.conf | | | ||
| PHP | php, php3, php4, php5, php6, php7, php8 | | | ||
| PHP | php | | | ||
| Papyrus | papyrus, psc |[highlightjs-papyrus](https://github.com/Pickysaurus/highlightjs-papyrus) | | ||
@@ -236,1 +236,2 @@ | Parser3 | parser3 | | | ||
[1]: https://github.com/highlightjs/highlight.js#getting-the-library | ||
[2]: https://github.com/highlightjs/highlight.js#importing-the-library |
@@ -27,3 +27,3 @@ /* eslint-disable no-unused-vars */ | ||
interface PublicApi { | ||
highlight: (codeOrLanguageName: string, optionsOrCode: string | HighlightOptions, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult | ||
highlight: (codeOrLanguageName: string, optionsOrCode: string | HighlightOptions, ignoreIllegals?: boolean) => HighlightResult | ||
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult | ||
@@ -30,0 +30,0 @@ highlightBlock: (element: HTMLElement) => void |
@@ -0,1 +1,3 @@ | ||
# Upgrading to Highlight.js v11.0 | ||
- [Overview of Breaking Changes](#overview-of-breaking-changes) | ||
@@ -64,2 +66,3 @@ - [Built-in set of "Common" Languages](#built-in-set-of-common-languages) | ||
- 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. | ||
@@ -66,0 +69,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4771762
137475