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

130 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Elm
Author: Janis Voigtlaender <janis.voigtlaender@gmail.com>
Website: https://elm-lang.org
Category: functional
*/
/** @type LanguageFn */
function elm(hljs) {
const COMMENT = {
2023-12-18 13:12:25 +08:00
variants: [
hljs.COMMENT('--', '$'),
hljs.COMMENT(
2024-01-16 21:26:16 +08:00
/\{-/,
/-\}/,
2023-12-18 13:12:25 +08:00
{
contains: ['self']
}
)
]
};
2024-01-16 21:26:16 +08:00
const CONSTRUCTOR = {
2023-12-18 13:12:25 +08:00
className: 'type',
begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (built-in, infix).
relevance: 0
};
2024-01-16 21:26:16 +08:00
const LIST = {
begin: '\\(',
end: '\\)',
2023-12-18 13:12:25 +08:00
illegal: '"',
contains: [
2024-01-16 21:26:16 +08:00
{
className: 'type',
begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'
},
2023-12-18 13:12:25 +08:00
COMMENT
]
};
2024-01-16 21:26:16 +08:00
const RECORD = {
begin: /\{/,
end: /\}/,
2023-12-18 13:12:25 +08:00
contains: LIST.contains
};
2024-01-16 21:26:16 +08:00
const CHARACTER = {
2023-12-18 13:12:25 +08:00
className: 'string',
2024-01-16 21:26:16 +08:00
begin: '\'\\\\?.',
end: '\'',
2023-12-18 13:12:25 +08:00
illegal: '.'
};
return {
2024-01-16 21:26:16 +08:00
name: 'Elm',
2023-12-18 13:12:25 +08:00
keywords:
'let in if then else case of where module import exposing ' +
'type alias as infix infixl infixr port effect command subscription',
contains: [
// Top-level constructions.
{
2024-01-16 21:26:16 +08:00
beginKeywords: 'port effect module',
end: 'exposing',
2023-12-18 13:12:25 +08:00
keywords: 'port effect module where command subscription exposing',
2024-01-16 21:26:16 +08:00
contains: [
LIST,
COMMENT
],
2023-12-18 13:12:25 +08:00
illegal: '\\W\\.|;'
},
{
2024-01-16 21:26:16 +08:00
begin: 'import',
end: '$',
2023-12-18 13:12:25 +08:00
keywords: 'import as exposing',
2024-01-16 21:26:16 +08:00
contains: [
LIST,
COMMENT
],
2023-12-18 13:12:25 +08:00
illegal: '\\W\\.|;'
},
{
2024-01-16 21:26:16 +08:00
begin: 'type',
end: '$',
2023-12-18 13:12:25 +08:00
keywords: 'type alias',
2024-01-16 21:26:16 +08:00
contains: [
CONSTRUCTOR,
LIST,
RECORD,
COMMENT
]
2023-12-18 13:12:25 +08:00
},
{
2024-01-16 21:26:16 +08:00
beginKeywords: 'infix infixl infixr',
end: '$',
contains: [
hljs.C_NUMBER_MODE,
COMMENT
]
2023-12-18 13:12:25 +08:00
},
{
2024-01-16 21:26:16 +08:00
begin: 'port',
end: '$',
2023-12-18 13:12:25 +08:00
keywords: 'port',
contains: [COMMENT]
},
// Literals and names.
CHARACTER,
hljs.QUOTE_STRING_MODE,
hljs.C_NUMBER_MODE,
CONSTRUCTOR,
2024-01-16 21:26:16 +08:00
hljs.inherit(hljs.TITLE_MODE, {
begin: '^[_a-z][\\w\']*'
}),
2023-12-18 13:12:25 +08:00
COMMENT,
2024-01-16 21:26:16 +08:00
{
begin: '->|<-'
} // No markup, relevance booster
2023-12-18 13:12:25 +08:00
],
illegal: /;/
};
2024-01-16 21:26:16 +08:00
}
module.exports = elm;