highlight.js
Advanced tools
Comparing version 9.17.1 to 9.18.0
@@ -516,12 +516,20 @@ /* | ||
/* | ||
Core highlighting function. Accepts a language name, or an alias, and a | ||
string with the code to highlight. Returns an object with the following | ||
properties: | ||
- relevance (int) | ||
- value (an HTML string with highlighting markup) | ||
/** | ||
* Core highlighting function. | ||
* | ||
* @param {string} languageName - the language to use for highlighting | ||
* @param {string} code - the code to highlight | ||
* @param {boolean} ignore_illegals - whether to ignore illegal matches, default is to bail | ||
* @param {array<mode>} continuation - array of continuation modes | ||
* | ||
* @returns an object that represents the result | ||
* @property {string} language - the language name | ||
* @property {number} relevance - the relevance score | ||
* @property {string} value - the highlighted HTML code | ||
* @property {mode} top - top of the current mode stack | ||
* @property {boolean} illegal - indicates whether any illegal matches were found | ||
*/ | ||
function highlight(name, value, ignore_illegals, continuation) { | ||
function highlight(languageName, code, ignore_illegals, continuation) { | ||
var codeToHighlight = code; | ||
@@ -647,3 +655,3 @@ function escapeRe(value) { | ||
var lexeme = match[0]; | ||
var matchPlusRemainder = value.substr(match.index); | ||
var matchPlusRemainder = codeToHighlight.substr(match.index); | ||
var end_mode = endOfMode(top, matchPlusRemainder); | ||
@@ -701,3 +709,3 @@ if (!end_mode) { return; } | ||
// spit the "skipped" character that our regex choked on back into the output sequence | ||
mode_buffer += value.slice(match.index, match.index + 1); | ||
mode_buffer += codeToHighlight.slice(match.index, match.index + 1); | ||
return 1; | ||
@@ -734,6 +742,6 @@ } | ||
var language = getLanguage(name); | ||
var language = getLanguage(languageName); | ||
if (!language) { | ||
console.error(LANGUAGE_NOT_FOUND.replace("{}", name)); | ||
throw new Error('Unknown language: "' + name + '"'); | ||
console.error(LANGUAGE_NOT_FOUND.replace("{}", languageName)); | ||
throw new Error('Unknown language: "' + languageName + '"'); | ||
} | ||
@@ -756,9 +764,9 @@ | ||
top.terminators.lastIndex = index; | ||
match = top.terminators.exec(value); | ||
match = top.terminators.exec(codeToHighlight); | ||
if (!match) | ||
break; | ||
count = processLexeme(value.substring(index, match.index), match); | ||
count = processLexeme(codeToHighlight.substring(index, match.index), match); | ||
index = match.index + count; | ||
} | ||
processLexeme(value.substr(index)); | ||
processLexeme(codeToHighlight.substr(index)); | ||
for(current = top; current.parent; current = current.parent) { // close dangling modes | ||
@@ -773,3 +781,3 @@ if (current.className) { | ||
illegal:false, | ||
language: name, | ||
language: languageName, | ||
top: top | ||
@@ -782,3 +790,3 @@ }; | ||
relevance: 0, | ||
value: escape(value) | ||
value: escape(codeToHighlight) | ||
}; | ||
@@ -788,4 +796,4 @@ } else if (SAFE_MODE) { | ||
relevance: 0, | ||
value: escape(value), | ||
language: name, | ||
value: escape(codeToHighlight), | ||
language: languageName, | ||
top: top, | ||
@@ -811,11 +819,11 @@ errorRaised: err | ||
*/ | ||
function highlightAuto(text, languageSubset) { | ||
function highlightAuto(code, languageSubset) { | ||
languageSubset = languageSubset || options.languages || objectKeys(languages); | ||
var result = { | ||
relevance: 0, | ||
value: escape(text) | ||
value: escape(code) | ||
}; | ||
var second_best = result; | ||
languageSubset.filter(getLanguage).filter(autoDetection).forEach(function(name) { | ||
var current = highlight(name, text, false); | ||
var current = highlight(name, code, false); | ||
current.language = name; | ||
@@ -822,0 +830,0 @@ if (current.relevance > second_best.relevance) { |
module.exports = function(hljs) { | ||
function optional(s) { | ||
return '(?:' + s + ')?'; | ||
} | ||
var DECLTYPE_AUTO_RE = 'decltype\\(auto\\)' | ||
var NAMESPACE_RE = '[a-zA-Z_]\\w*::' | ||
var TEMPLATE_ARGUMENT_RE = '<.*?>'; | ||
var FUNCTION_TYPE_RE = '(' + | ||
DECLTYPE_AUTO_RE + '|' + | ||
optional(NAMESPACE_RE) +'[a-zA-Z_]\\w*' + optional(TEMPLATE_ARGUMENT_RE) + | ||
')'; | ||
var CPP_PRIMITIVE_TYPES = { | ||
@@ -59,4 +69,10 @@ className: 'keyword', | ||
var FUNCTION_TITLE = hljs.IDENT_RE + '\\s*\\('; | ||
var TITLE_MODE = { | ||
className: 'title', | ||
begin: optional(NAMESPACE_RE) + hljs.IDENT_RE, | ||
relevance: 0 | ||
}; | ||
var FUNCTION_TITLE = optional(NAMESPACE_RE) + hljs.IDENT_RE + '\\s*\\('; | ||
var CPP_KEYWORDS = { | ||
@@ -95,52 +111,55 @@ keyword: 'int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof ' + | ||
return { | ||
aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'], | ||
var EXPRESSION_CONTEXT = { | ||
// This mode covers expression context where we can't expect a function | ||
// definition and shouldn't highlight anything that looks like one: | ||
// `return some()`, `else if()`, `(x*sum(1, 2))` | ||
variants: [ | ||
{begin: /=/, end: /;/}, | ||
{begin: /\(/, end: /\)/}, | ||
{beginKeywords: 'new throw return else', end: /;/} | ||
], | ||
keywords: CPP_KEYWORDS, | ||
illegal: '</', | ||
contains: EXPRESSION_CONTAINS.concat([ | ||
PREPROCESSOR, | ||
{ | ||
begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>', | ||
begin: /\(/, end: /\)/, | ||
keywords: CPP_KEYWORDS, | ||
contains: ['self', CPP_PRIMITIVE_TYPES] | ||
contains: EXPRESSION_CONTAINS.concat(['self']), | ||
relevance: 0 | ||
} | ||
]), | ||
relevance: 0 | ||
}; | ||
var FUNCTION_DECLARATION = { | ||
className: 'function', | ||
begin: '(' + FUNCTION_TYPE_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE, | ||
returnBegin: true, end: /[{;=]/, | ||
excludeEnd: true, | ||
keywords: CPP_KEYWORDS, | ||
illegal: /[^\w\s\*&:<>]/, | ||
contains: [ | ||
{ // to prevent it from being confused as the function title | ||
begin: DECLTYPE_AUTO_RE, | ||
keywords: CPP_KEYWORDS, | ||
relevance: 0, | ||
}, | ||
{ | ||
begin: hljs.IDENT_RE + '::', | ||
keywords: CPP_KEYWORDS | ||
}, | ||
{ | ||
// This mode covers expression context where we can't expect a function | ||
// definition and shouldn't highlight anything that looks like one: | ||
// `return some()`, `else if()`, `(x*sum(1, 2))` | ||
variants: [ | ||
{begin: /=/, end: /;/}, | ||
{begin: /\(/, end: /\)/}, | ||
{beginKeywords: 'new throw return else', end: /;/} | ||
], | ||
keywords: CPP_KEYWORDS, | ||
contains: EXPRESSION_CONTAINS.concat([ | ||
{ | ||
begin: /\(/, end: /\)/, | ||
keywords: CPP_KEYWORDS, | ||
contains: EXPRESSION_CONTAINS.concat(['self']), | ||
relevance: 0 | ||
} | ||
]), | ||
begin: FUNCTION_TITLE, returnBegin: true, | ||
contains: [TITLE_MODE], | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'function', | ||
begin: '(' + hljs.IDENT_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE, | ||
returnBegin: true, end: /[{;=]/, | ||
excludeEnd: true, | ||
className: 'params', | ||
begin: /\(/, end: /\)/, | ||
keywords: CPP_KEYWORDS, | ||
illegal: /[^\w\s\*&]/, | ||
relevance: 0, | ||
contains: [ | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
STRINGS, | ||
NUMBERS, | ||
CPP_PRIMITIVE_TYPES, | ||
// Count matching parentheses. | ||
{ | ||
begin: FUNCTION_TITLE, returnBegin: true, | ||
contains: [hljs.TITLE_MODE], | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'params', | ||
begin: /\(/, end: /\)/, | ||
@@ -150,2 +169,3 @@ keywords: CPP_KEYWORDS, | ||
contains: [ | ||
'self', | ||
hljs.C_LINE_COMMENT_MODE, | ||
@@ -155,25 +175,34 @@ hljs.C_BLOCK_COMMENT_MODE, | ||
NUMBERS, | ||
CPP_PRIMITIVE_TYPES, | ||
// Count matching parentheses. | ||
{ | ||
begin: /\(/, end: /\)/, | ||
keywords: CPP_KEYWORDS, | ||
relevance: 0, | ||
contains: [ | ||
'self', | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
STRINGS, | ||
NUMBERS, | ||
CPP_PRIMITIVE_TYPES | ||
] | ||
} | ||
CPP_PRIMITIVE_TYPES | ||
] | ||
}, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
PREPROCESSOR | ||
} | ||
] | ||
}, | ||
CPP_PRIMITIVE_TYPES, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
PREPROCESSOR | ||
] | ||
}; | ||
return { | ||
aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp', 'hh', 'hxx', 'cxx'], | ||
keywords: CPP_KEYWORDS, | ||
illegal: '</', | ||
contains: [].concat( | ||
EXPRESSION_CONTEXT, | ||
FUNCTION_DECLARATION, | ||
EXPRESSION_CONTAINS, | ||
[ | ||
PREPROCESSOR, | ||
{ | ||
begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>', | ||
keywords: CPP_KEYWORDS, | ||
contains: ['self', CPP_PRIMITIVE_TYPES] | ||
}, | ||
{ | ||
begin: hljs.IDENT_RE + '::', | ||
keywords: CPP_KEYWORDS | ||
}, | ||
{ | ||
className: 'class', | ||
@@ -180,0 +209,0 @@ beginKeywords: 'class struct', end: /[{;:]/, |
@@ -10,3 +10,3 @@ module.exports = function(hljs) { | ||
keyword: 'kind do while private call intrinsic where elsewhere ' + | ||
'type endtype endmodule endselect endinterface end enddo endif if forall endforall only contains default return stop then ' + | ||
'type endtype endmodule endselect endinterface end enddo endif if forall endforall only contains default return stop then block endblock ' + | ||
'public subroutine|10 function program .and. .or. .not. .le. .eq. .ge. .gt. .lt. ' + | ||
@@ -13,0 +13,0 @@ 'goto save else use module select case ' + |
module.exports = function(hljs) { | ||
var STRING = { | ||
var NUMBERS = { | ||
className: 'number', | ||
relevance: 0, | ||
variants: [ | ||
{ begin: /([\+\-]+)?[\d]+_[\d_]+/ }, | ||
{ begin: hljs.NUMBER_RE } | ||
] | ||
}; | ||
var COMMENTS = hljs.COMMENT(); | ||
COMMENTS.variants = [ | ||
{begin: /;/, end: /$/}, | ||
{begin: /#/, end: /$/}, | ||
]; | ||
var VARIABLES = { | ||
className: 'variable', | ||
variants: [ | ||
{ begin: /\$[\w\d"][\w\d_]*/ }, | ||
{ begin: /\$\{(.*?)}/ } | ||
] | ||
}; | ||
var LITERALS = { | ||
className: 'literal', | ||
begin: /\bon|off|true|false|yes|no\b/ | ||
}; | ||
var STRINGS = { | ||
className: "string", | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
variants: [ | ||
{ | ||
begin: "'''", end: "'''", | ||
relevance: 10 | ||
}, { | ||
begin: '"""', end: '"""', | ||
relevance: 10 | ||
}, { | ||
begin: '"', end: '"' | ||
}, { | ||
begin: "'", end: "'" | ||
} | ||
{ begin: "'''", end: "'''", relevance: 10 }, | ||
{ begin: '"""', end: '"""', relevance: 10 }, | ||
{ begin: '"', end: '"' }, | ||
{ begin: "'", end: "'" } | ||
] | ||
}; | ||
var ARRAY = { | ||
begin: /\[/, end: /\]/, | ||
contains: [ | ||
COMMENTS, | ||
LITERALS, | ||
VARIABLES, | ||
STRINGS, | ||
NUMBERS, | ||
'self' | ||
], | ||
relevance:0 | ||
}; | ||
return { | ||
@@ -24,42 +54,21 @@ aliases: ['toml'], | ||
contains: [ | ||
hljs.COMMENT(';', '$'), | ||
hljs.HASH_COMMENT_MODE, | ||
COMMENTS, | ||
{ | ||
className: 'section', | ||
begin: /^\s*\[+/, end: /\]+/ | ||
begin: /\[+/, end: /\]+/ | ||
}, | ||
{ | ||
begin: /^[a-z0-9\[\]_\.-]+\s*=\s*/, end: '$', | ||
returnBegin: true, | ||
contains: [ | ||
{ | ||
className: 'attr', | ||
begin: /[a-z0-9\[\]_\.-]+/ | ||
}, | ||
{ | ||
begin: /=/, endsWithParent: true, | ||
relevance: 0, | ||
contains: [ | ||
hljs.COMMENT(';', '$'), | ||
hljs.HASH_COMMENT_MODE, | ||
{ | ||
className: 'literal', | ||
begin: /\bon|off|true|false|yes|no\b/ | ||
}, | ||
{ | ||
className: 'variable', | ||
variants: [ | ||
{begin: /\$[\w\d"][\w\d_]*/}, | ||
{begin: /\$\{(.*?)}/} | ||
] | ||
}, | ||
STRING, | ||
{ | ||
className: 'number', | ||
begin: /([\+\-]+)?[\d]+_[\d_]+/ | ||
}, | ||
hljs.NUMBER_MODE | ||
] | ||
} | ||
] | ||
begin: /^[a-z0-9\[\]_\.-]+(?=\s*=\s*)/, | ||
className: 'attr', | ||
starts: { | ||
end: /$/, | ||
contains: [ | ||
COMMENTS, | ||
ARRAY, | ||
LITERALS, | ||
VARIABLES, | ||
STRINGS, | ||
NUMBERS | ||
] | ||
} | ||
} | ||
@@ -66,0 +75,0 @@ ] |
module.exports = function(hljs) { | ||
var FRAGMENT = { | ||
begin: '<>', | ||
end: '</>' | ||
}; | ||
var XML_TAG = { | ||
begin: /<[A-Za-z0-9\\._:-]+/, | ||
end: /\/[A-Za-z0-9\\._:-]+>|\/>/ | ||
}; | ||
var IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
@@ -183,16 +191,15 @@ var KEYWORDS = { | ||
}, | ||
{ // E4X / JSX | ||
begin: /</, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/, | ||
{ // JSX | ||
variants: [ | ||
{ begin: FRAGMENT.begin, end: FRAGMENT.end }, | ||
{ begin: XML_TAG.begin, end: XML_TAG.end } | ||
], | ||
subLanguage: 'xml', | ||
contains: [ | ||
{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true }, | ||
{ | ||
begin: /<[A-Za-z0-9\\._:-]+/, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/, skip: true, | ||
contains: [ | ||
{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true }, | ||
'self' | ||
] | ||
begin: XML_TAG.begin, end: XML_TAG.end, skip: true, | ||
contains: ['self'] | ||
} | ||
] | ||
} | ||
}, | ||
], | ||
@@ -199,0 +206,0 @@ relevance: 0 |
module.exports = function(hljs) { | ||
// variable names cannot conflict with block identifiers | ||
var BLOCKS = [ | ||
'functions', | ||
'model', | ||
'data', | ||
'parameters', | ||
'quantities', | ||
'transformed', | ||
'generated' | ||
]; | ||
var STATEMENTS = [ | ||
'for', | ||
'in', | ||
'if', | ||
'else', | ||
'while', | ||
'break', | ||
'continue', | ||
'return' | ||
]; | ||
var SPECIAL_FUNCTIONS = [ | ||
'print', | ||
'reject', | ||
'increment_log_prob|10', | ||
'integrate_ode|10', | ||
'integrate_ode_rk45|10', | ||
'integrate_ode_bdf|10', | ||
'algebra_solver' | ||
]; | ||
var VAR_TYPES = [ | ||
'int', | ||
'real', | ||
'vector', | ||
'ordered', | ||
'positive_ordered', | ||
'simplex', | ||
'unit_vector', | ||
'row_vector', | ||
'matrix', | ||
'cholesky_factor_corr|10', | ||
'cholesky_factor_cov|10', | ||
'corr_matrix|10', | ||
'cov_matrix|10', | ||
'void' | ||
]; | ||
var FUNCTIONS = [ | ||
'Phi', 'Phi_approx', 'abs', 'acos', 'acosh', 'algebra_solver', 'append_array', | ||
'append_col', 'append_row', 'asin', 'asinh', 'atan', 'atan2', 'atanh', | ||
'bernoulli_cdf', 'bernoulli_lccdf', 'bernoulli_lcdf', 'bernoulli_logit_lpmf', | ||
'bernoulli_logit_rng', 'bernoulli_lpmf', 'bernoulli_rng', 'bessel_first_kind', | ||
'bessel_second_kind', 'beta_binomial_cdf', 'beta_binomial_lccdf', | ||
'beta_binomial_lcdf', 'beta_binomial_lpmf', 'beta_binomial_rng', 'beta_cdf', | ||
'beta_lccdf', 'beta_lcdf', 'beta_lpdf', 'beta_rng', 'binary_log_loss', | ||
'binomial_cdf', 'binomial_coefficient_log', 'binomial_lccdf', 'binomial_lcdf', | ||
'binomial_logit_lpmf', 'binomial_lpmf', 'binomial_rng', 'block', | ||
'categorical_logit_lpmf', 'categorical_logit_rng', 'categorical_lpmf', | ||
'categorical_rng', 'cauchy_cdf', 'cauchy_lccdf', 'cauchy_lcdf', 'cauchy_lpdf', | ||
'cauchy_rng', 'cbrt', 'ceil', 'chi_square_cdf', 'chi_square_lccdf', | ||
'chi_square_lcdf', 'chi_square_lpdf', 'chi_square_rng', 'cholesky_decompose', | ||
'choose', 'col', 'cols', 'columns_dot_product', 'columns_dot_self', 'cos', | ||
'cosh', 'cov_exp_quad', 'crossprod', 'csr_extract_u', 'csr_extract_v', | ||
'csr_extract_w', 'csr_matrix_times_vector', 'csr_to_dense_matrix', | ||
'cumulative_sum', 'determinant', 'diag_matrix', 'diag_post_multiply', | ||
'diag_pre_multiply', 'diagonal', 'digamma', 'dims', 'dirichlet_lpdf', | ||
'dirichlet_rng', 'distance', 'dot_product', 'dot_self', | ||
'double_exponential_cdf', 'double_exponential_lccdf', 'double_exponential_lcdf', | ||
'double_exponential_lpdf', 'double_exponential_rng', 'e', 'eigenvalues_sym', | ||
'eigenvectors_sym', 'erf', 'erfc', 'exp', 'exp2', 'exp_mod_normal_cdf', | ||
'exp_mod_normal_lccdf', 'exp_mod_normal_lcdf', 'exp_mod_normal_lpdf', | ||
'exp_mod_normal_rng', 'expm1', 'exponential_cdf', 'exponential_lccdf', | ||
'exponential_lcdf', 'exponential_lpdf', 'exponential_rng', 'fabs', | ||
'falling_factorial', 'fdim', 'floor', 'fma', 'fmax', 'fmin', 'fmod', | ||
'frechet_cdf', 'frechet_lccdf', 'frechet_lcdf', 'frechet_lpdf', 'frechet_rng', | ||
'gamma_cdf', 'gamma_lccdf', 'gamma_lcdf', 'gamma_lpdf', 'gamma_p', 'gamma_q', | ||
'gamma_rng', 'gaussian_dlm_obs_lpdf', 'get_lp', 'gumbel_cdf', 'gumbel_lccdf', | ||
'gumbel_lcdf', 'gumbel_lpdf', 'gumbel_rng', 'head', 'hypergeometric_lpmf', | ||
'hypergeometric_rng', 'hypot', 'inc_beta', 'int_step', 'integrate_ode', | ||
'integrate_ode_bdf', 'integrate_ode_rk45', 'inv', 'inv_Phi', | ||
'inv_chi_square_cdf', 'inv_chi_square_lccdf', 'inv_chi_square_lcdf', | ||
'inv_chi_square_lpdf', 'inv_chi_square_rng', 'inv_cloglog', 'inv_gamma_cdf', | ||
'inv_gamma_lccdf', 'inv_gamma_lcdf', 'inv_gamma_lpdf', 'inv_gamma_rng', | ||
'inv_logit', 'inv_sqrt', 'inv_square', 'inv_wishart_lpdf', 'inv_wishart_rng', | ||
'inverse', 'inverse_spd', 'is_inf', 'is_nan', 'lbeta', 'lchoose', 'lgamma', | ||
'lkj_corr_cholesky_lpdf', 'lkj_corr_cholesky_rng', 'lkj_corr_lpdf', | ||
'lkj_corr_rng', 'lmgamma', 'lmultiply', 'log', 'log10', 'log1m', 'log1m_exp', | ||
'log1m_inv_logit', 'log1p', 'log1p_exp', 'log2', 'log_determinant', | ||
'log_diff_exp', 'log_falling_factorial', 'log_inv_logit', 'log_mix', | ||
'log_rising_factorial', 'log_softmax', 'log_sum_exp', 'logistic_cdf', | ||
'logistic_lccdf', 'logistic_lcdf', 'logistic_lpdf', 'logistic_rng', 'logit', | ||
'lognormal_cdf', 'lognormal_lccdf', 'lognormal_lcdf', 'lognormal_lpdf', | ||
'lognormal_rng', 'machine_precision', 'matrix_exp', 'max', 'mdivide_left_spd', | ||
'mdivide_left_tri_low', 'mdivide_right_spd', 'mdivide_right_tri_low', 'mean', | ||
'min', 'modified_bessel_first_kind', 'modified_bessel_second_kind', | ||
'multi_gp_cholesky_lpdf', 'multi_gp_lpdf', 'multi_normal_cholesky_lpdf', | ||
'multi_normal_cholesky_rng', 'multi_normal_lpdf', 'multi_normal_prec_lpdf', | ||
'multi_normal_rng', 'multi_student_t_lpdf', 'multi_student_t_rng', | ||
'multinomial_lpmf', 'multinomial_rng', 'multiply_log', | ||
'multiply_lower_tri_self_transpose', 'neg_binomial_2_cdf', | ||
'neg_binomial_2_lccdf', 'neg_binomial_2_lcdf', 'neg_binomial_2_log_lpmf', | ||
'neg_binomial_2_log_rng', 'neg_binomial_2_lpmf', 'neg_binomial_2_rng', | ||
'neg_binomial_cdf', 'neg_binomial_lccdf', 'neg_binomial_lcdf', | ||
'neg_binomial_lpmf', 'neg_binomial_rng', 'negative_infinity', 'normal_cdf', | ||
'normal_lccdf', 'normal_lcdf', 'normal_lpdf', 'normal_rng', 'not_a_number', | ||
'num_elements', 'ordered_logistic_lpmf', 'ordered_logistic_rng', 'owens_t', | ||
'pareto_cdf', 'pareto_lccdf', 'pareto_lcdf', 'pareto_lpdf', 'pareto_rng', | ||
'pareto_type_2_cdf', 'pareto_type_2_lccdf', 'pareto_type_2_lcdf', | ||
'pareto_type_2_lpdf', 'pareto_type_2_rng', 'pi', 'poisson_cdf', 'poisson_lccdf', | ||
'poisson_lcdf', 'poisson_log_lpmf', 'poisson_log_rng', 'poisson_lpmf', | ||
'poisson_rng', 'positive_infinity', 'pow', 'print', 'prod', 'qr_Q', 'qr_R', | ||
'quad_form', 'quad_form_diag', 'quad_form_sym', 'rank', 'rayleigh_cdf', | ||
'rayleigh_lccdf', 'rayleigh_lcdf', 'rayleigh_lpdf', 'rayleigh_rng', 'reject', | ||
'rep_array', 'rep_matrix', 'rep_row_vector', 'rep_vector', 'rising_factorial', | ||
'round', 'row', 'rows', 'rows_dot_product', 'rows_dot_self', | ||
'scaled_inv_chi_square_cdf', 'scaled_inv_chi_square_lccdf', | ||
'scaled_inv_chi_square_lcdf', 'scaled_inv_chi_square_lpdf', | ||
'scaled_inv_chi_square_rng', 'sd', 'segment', 'sin', 'singular_values', 'sinh', | ||
'size', 'skew_normal_cdf', 'skew_normal_lccdf', 'skew_normal_lcdf', | ||
'skew_normal_lpdf', 'skew_normal_rng', 'softmax', 'sort_asc', 'sort_desc', | ||
'sort_indices_asc', 'sort_indices_desc', 'sqrt', 'sqrt2', 'square', | ||
'squared_distance', 'step', 'student_t_cdf', 'student_t_lccdf', | ||
'student_t_lcdf', 'student_t_lpdf', 'student_t_rng', 'sub_col', 'sub_row', | ||
'sum', 'tail', 'tan', 'tanh', 'target', 'tcrossprod', 'tgamma', 'to_array_1d', | ||
'to_array_2d', 'to_matrix', 'to_row_vector', 'to_vector', 'trace', | ||
'trace_gen_quad_form', 'trace_quad_form', 'trigamma', 'trunc', 'uniform_cdf', | ||
'uniform_lccdf', 'uniform_lcdf', 'uniform_lpdf', 'uniform_rng', 'variance', | ||
'von_mises_lpdf', 'von_mises_rng', 'weibull_cdf', 'weibull_lccdf', | ||
'weibull_lcdf', 'weibull_lpdf', 'weibull_rng', 'wiener_lpdf', 'wishart_lpdf', | ||
'wishart_rng' | ||
]; | ||
var DISTRIBUTIONS = [ | ||
'bernoulli', 'bernoulli_logit', 'beta', 'beta_binomial', 'binomial', | ||
'binomial_logit', 'categorical', 'categorical_logit', 'cauchy', 'chi_square', | ||
'dirichlet', 'double_exponential', 'exp_mod_normal', 'exponential', 'frechet', | ||
'gamma', 'gaussian_dlm_obs', 'gumbel', 'hypergeometric', 'inv_chi_square', | ||
'inv_gamma', 'inv_wishart', 'lkj_corr', 'lkj_corr_cholesky', 'logistic', | ||
'lognormal', 'multi_gp', 'multi_gp_cholesky', 'multi_normal', | ||
'multi_normal_cholesky', 'multi_normal_prec', 'multi_student_t', 'multinomial', | ||
'neg_binomial', 'neg_binomial_2', 'neg_binomial_2_log', 'normal', | ||
'ordered_logistic', 'pareto', 'pareto_type_2', 'poisson', 'poisson_log', | ||
'rayleigh', 'scaled_inv_chi_square', 'skew_normal', 'student_t', 'uniform', | ||
'von_mises', 'weibull', 'wiener', 'wishart' | ||
]; | ||
return { | ||
aliases: ['stanfuncs'], | ||
keywords: { | ||
'title': BLOCKS.join(' '), | ||
'keyword': STATEMENTS.concat(VAR_TYPES).concat(SPECIAL_FUNCTIONS).join(' '), | ||
'built_in': FUNCTIONS.join(' ') | ||
}, | ||
lexemes: hljs.IDENT_RE, | ||
contains: [ | ||
hljs.HASH_COMMENT_MODE, | ||
hljs.C_LINE_COMMENT_MODE, | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
hljs.COMMENT( | ||
/#/, | ||
/$/, | ||
{ | ||
relevance: 0, | ||
keywords: { | ||
'meta-keyword': 'include' | ||
} | ||
} | ||
), | ||
hljs.COMMENT( | ||
/\/\*/, | ||
/\*\//, | ||
{ | ||
relevance: 0, | ||
// highlight doc strings mentioned in Stan reference | ||
contains: [ | ||
{ | ||
className: 'doctag', | ||
begin: /@(return|param)/ | ||
} | ||
] | ||
} | ||
), | ||
{ | ||
begin: hljs.UNDERSCORE_IDENT_RE, | ||
lexemes: hljs.UNDERSCORE_IDENT_RE, | ||
keywords: { | ||
// Stan's keywords | ||
name: | ||
'for in while repeat until if then else', | ||
// Stan's probablity distributions (less beta and gamma, as commonly | ||
// used for parameter names). So far, _log and _rng variants are not | ||
// included | ||
symbol: | ||
'bernoulli bernoulli_logit binomial binomial_logit ' + | ||
'beta_binomial hypergeometric categorical categorical_logit ' + | ||
'ordered_logistic neg_binomial neg_binomial_2 ' + | ||
'neg_binomial_2_log poisson poisson_log multinomial normal ' + | ||
'exp_mod_normal skew_normal student_t cauchy double_exponential ' + | ||
'logistic gumbel lognormal chi_square inv_chi_square ' + | ||
'scaled_inv_chi_square exponential inv_gamma weibull frechet ' + | ||
'rayleigh wiener pareto pareto_type_2 von_mises uniform ' + | ||
'multi_normal multi_normal_prec multi_normal_cholesky multi_gp ' + | ||
'multi_gp_cholesky multi_student_t gaussian_dlm_obs dirichlet ' + | ||
'lkj_corr lkj_corr_cholesky wishart inv_wishart', | ||
// Stan's data types | ||
'selector-tag': | ||
'int real vector simplex unit_vector ordered positive_ordered ' + | ||
'row_vector matrix cholesky_factor_corr cholesky_factor_cov ' + | ||
'corr_matrix cov_matrix', | ||
// Stan's model blocks | ||
title: | ||
'functions model data parameters quantities transformed ' + | ||
'generated', | ||
literal: | ||
'true false' | ||
}, | ||
relevance: 0 | ||
// hack: in range constraints, lower must follow "<" | ||
begin: /<\s*lower\s*=/, | ||
keywords: 'lower' | ||
}, | ||
// The below is all taken from the R language definition | ||
{ | ||
// hex value | ||
className: 'number', | ||
begin: "0[xX][0-9a-fA-F]+[Li]?\\b", | ||
relevance: 0 | ||
// hack: in range constraints, upper must follow either , or < | ||
// <lower = ..., upper = ...> or <upper = ...> | ||
begin: /[<,]*upper\s*=/, | ||
keywords: 'upper' | ||
}, | ||
{ | ||
// hex value | ||
className: 'number', | ||
begin: "0[xX][0-9a-fA-F]+[Li]?\\b", | ||
relevance: 0 | ||
className: 'keyword', | ||
begin: /\btarget\s*\+=/, | ||
relevance: 10 | ||
}, | ||
{ | ||
// explicit integer | ||
className: 'number', | ||
begin: "\\d+(?:[eE][+\\-]?\\d*)?L\\b", | ||
relevance: 0 | ||
begin: '~\\s*(' + hljs.IDENT_RE + ')\\s*\\(', | ||
keywords: DISTRIBUTIONS.join(' ') | ||
}, | ||
{ | ||
// number with trailing decimal | ||
className: 'number', | ||
begin: "\\d+\\.(?!\\d)(?:i\\b)?", | ||
variants: [ | ||
{ | ||
begin: /\b\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/ | ||
}, | ||
{ | ||
begin: /\.\d+(?:[eE][+-]?\d+)?\b/ | ||
} | ||
], | ||
relevance: 0 | ||
}, | ||
{ | ||
// number | ||
className: 'number', | ||
begin: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b", | ||
className: 'string', | ||
begin: '"', | ||
end: '"', | ||
relevance: 0 | ||
}, | ||
{ | ||
// number with leading decimal | ||
className: 'number', | ||
begin: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b", | ||
relevance: 0 | ||
} | ||
] | ||
}; | ||
} | ||
}; |
@@ -12,3 +12,3 @@ module.exports = function(hljs) { | ||
'join key let lib like loop me mid mod module mustinherit mustoverride mybase myclass ' + /* j-m */ | ||
'namespace narrowing new next not notinheritable notoverridable ' + /* n */ | ||
'nameof namespace narrowing new next not notinheritable notoverridable ' + /* n */ | ||
'of off on operator option optional or order orelse overloads overridable overrides ' + /* o */ | ||
@@ -15,0 +15,0 @@ 'paramarray partial preserve private property protected public ' + /* p */ |
@@ -9,3 +9,3 @@ { | ||
"homepage": "https://highlightjs.org/", | ||
"version": "9.17.1", | ||
"version": "9.18.0", | ||
"author": { | ||
@@ -1061,2 +1061,6 @@ "name": "Ivan Sagalaev", | ||
{ | ||
"name": "Jeffrey Arnold", | ||
"email": "jeffrey.arnold@gmail.com" | ||
}, | ||
{ | ||
"name": "Antoine Boisier-Michaud", | ||
@@ -1136,4 +1140,5 @@ "email": "aboisiermichaud@gmail.com" | ||
"glob": "^7.1.4", | ||
"handlebars": "^4.5.3", | ||
"js-beautify": "^1.10.2", | ||
"jsdom": "^15.1.1", | ||
"jsdom": "^16.0.1", | ||
"lodash": "^4.17.15", | ||
@@ -1146,5 +1151,3 @@ "mocha": "^6.2.0", | ||
}, | ||
"dependencies": { | ||
"handlebars": "^4.5.3" | ||
} | ||
"dependencies": {} | ||
} |
# Highlight.js | ||
[![Build Status](https://travis-ci.org/highlightjs/highlight.js.svg?branch=master)](https://travis-ci.org/highlightjs/highlight.js) [![Greenkeeper badge](https://badges.greenkeeper.io/highlightjs/highlight.js.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/highlightjs/highlight.js.svg?branch=master)](https://travis-ci.org/highlightjs/highlight.js) [![Greenkeeper badge](https://badges.greenkeeper.io/highlightjs/highlight.js.svg)](https://greenkeeper.io/) [![install size](https://packagephobia.now.sh/badge?p=highlight.js)](https://packagephobia.now.sh/result?p=highlight.js) | ||
@@ -124,2 +124,3 @@ Highlight.js is a syntax highlighter written in JavaScript. It works in | ||
| Go | go, golang | | | ||
| Grammatical Framework | gf | [highlightjs-gf](https://github.com/johnjcamilleri/highlightjs-gf) | | ||
| Golo | golo, gololang | | | ||
@@ -174,3 +175,3 @@ | Gradle | gradle | | | ||
| PF | pf, pf.conf | | | ||
| PHP | php, php3, php4, php5, php6 | | | ||
| PHP | php, php3, php4, php5, php6, php7 | | | ||
| Parser3 | parser3 | | | ||
@@ -213,3 +214,3 @@ | Perl | perl, pl, pm | | | ||
| Solidity | solidity, sol | [highlightjs-solidity](https://github.com/highlightjs/highlightjs-solidity) | | ||
| Stan | stan | | | ||
| Stan | stan, stanfuncs | | | ||
| Stata | stata | | | ||
@@ -216,0 +217,0 @@ | Structured Text | iecst, scl, stl, structured-text | [highlightjs-structured-text](https://github.com/highlightjs/highlightjs-structured-text) | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1439512
0
29419
408
17
- Removedhandlebars@^4.5.3
- Removedhandlebars@4.7.8(transitive)
- Removedminimist@1.2.8(transitive)
- Removedneo-async@2.6.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removeduglify-js@3.19.3(transitive)
- Removedwordwrap@1.0.0(transitive)