1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/nix.js

66 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Nix
Author: Domen Kožar <domen@dev.si>
Description: Nix functional language
Website: http://nixos.org/nix
*/
function nix(hljs) {
const NIX_KEYWORDS = {
2023-12-18 13:12:25 +08:00
keyword:
'rec with let in inherit assert if else then',
literal:
'true false or and null',
built_in:
'import abort baseNameOf dirOf isNull builtins map removeAttrs throw ' +
'toString derivation'
};
2024-01-16 21:26:16 +08:00
const ANTIQUOTE = {
2023-12-18 13:12:25 +08:00
className: 'subst',
begin: /\$\{/,
2024-01-16 21:26:16 +08:00
end: /\}/,
2023-12-18 13:12:25 +08:00
keywords: NIX_KEYWORDS
};
2024-01-16 21:26:16 +08:00
const ATTRS = {
begin: /[a-zA-Z0-9-_]+(\s*=)/,
returnBegin: true,
2023-12-18 13:12:25 +08:00
relevance: 0,
contains: [
{
className: 'attr',
begin: /\S+/
}
]
};
2024-01-16 21:26:16 +08:00
const STRING = {
2023-12-18 13:12:25 +08:00
className: 'string',
2024-01-16 21:26:16 +08:00
contains: [ ANTIQUOTE ],
2023-12-18 13:12:25 +08:00
variants: [
2024-01-16 21:26:16 +08:00
{
begin: "''",
end: "''"
},
{
begin: '"',
end: '"'
}
2023-12-18 13:12:25 +08:00
]
};
2024-01-16 21:26:16 +08:00
const EXPRESSIONS = [
2023-12-18 13:12:25 +08:00
hljs.NUMBER_MODE,
hljs.HASH_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
ATTRS
];
ANTIQUOTE.contains = EXPRESSIONS;
return {
2024-01-16 21:26:16 +08:00
name: 'Nix',
aliases: [ "nixos" ],
2023-12-18 13:12:25 +08:00
keywords: NIX_KEYWORDS,
contains: EXPRESSIONS
};
2024-01-16 21:26:16 +08:00
}
module.exports = nix;