tibi-docs/.yarn/unplugged/highlight.js-npm-9.18.5-571500f48d/node_modules/highlight.js/lib/languages/ini.js
2022-11-02 06:40:25 +00:00

76 lines
1.5 KiB
JavaScript

module.exports = function(hljs) {
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: "'" }
]
};
var ARRAY = {
begin: /\[/, end: /\]/,
contains: [
COMMENTS,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS,
'self'
],
relevance:0
};
return {
aliases: ['toml'],
case_insensitive: true,
illegal: /\S/,
contains: [
COMMENTS,
{
className: 'section',
begin: /\[+/, end: /\]+/
},
{
begin: /^[a-z0-9\[\]_\.-]+(?=\s*=\s*)/,
className: 'attr',
starts: {
end: /$/,
contains: [
COMMENTS,
ARRAY,
LITERALS,
VARIABLES,
STRINGS,
NUMBERS
]
}
}
]
};
};