source: node_modules/highlight.js/lib/languages/elm.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2Language: Elm
3Author: Janis Voigtlaender <janis.voigtlaender@gmail.com>
4Website: https://elm-lang.org
5Category: functional
6*/
7
8/** @type LanguageFn */
9function elm(hljs) {
10 const COMMENT = {
11 variants: [
12 hljs.COMMENT('--', '$'),
13 hljs.COMMENT(
14 /\{-/,
15 /-\}/,
16 {
17 contains: ['self']
18 }
19 )
20 ]
21 };
22
23 const CONSTRUCTOR = {
24 className: 'type',
25 begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (built-in, infix).
26 relevance: 0
27 };
28
29 const LIST = {
30 begin: '\\(',
31 end: '\\)',
32 illegal: '"',
33 contains: [
34 {
35 className: 'type',
36 begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'
37 },
38 COMMENT
39 ]
40 };
41
42 const RECORD = {
43 begin: /\{/,
44 end: /\}/,
45 contains: LIST.contains
46 };
47
48 const CHARACTER = {
49 className: 'string',
50 begin: '\'\\\\?.',
51 end: '\'',
52 illegal: '.'
53 };
54
55 return {
56 name: 'Elm',
57 keywords:
58 'let in if then else case of where module import exposing ' +
59 'type alias as infix infixl infixr port effect command subscription',
60 contains: [
61
62 // Top-level constructions.
63
64 {
65 beginKeywords: 'port effect module',
66 end: 'exposing',
67 keywords: 'port effect module where command subscription exposing',
68 contains: [
69 LIST,
70 COMMENT
71 ],
72 illegal: '\\W\\.|;'
73 },
74 {
75 begin: 'import',
76 end: '$',
77 keywords: 'import as exposing',
78 contains: [
79 LIST,
80 COMMENT
81 ],
82 illegal: '\\W\\.|;'
83 },
84 {
85 begin: 'type',
86 end: '$',
87 keywords: 'type alias',
88 contains: [
89 CONSTRUCTOR,
90 LIST,
91 RECORD,
92 COMMENT
93 ]
94 },
95 {
96 beginKeywords: 'infix infixl infixr',
97 end: '$',
98 contains: [
99 hljs.C_NUMBER_MODE,
100 COMMENT
101 ]
102 },
103 {
104 begin: 'port',
105 end: '$',
106 keywords: 'port',
107 contains: [COMMENT]
108 },
109
110 // Literals and names.
111
112 CHARACTER,
113 hljs.QUOTE_STRING_MODE,
114 hljs.C_NUMBER_MODE,
115 CONSTRUCTOR,
116 hljs.inherit(hljs.TITLE_MODE, {
117 begin: '^[_a-z][\\w\']*'
118 }),
119 COMMENT,
120
121 {
122 begin: '->|<-'
123 } // No markup, relevance booster
124 ],
125 illegal: /;/
126 };
127}
128
129module.exports = elm;
Note: See TracBrowser for help on using the repository browser.