1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
document.addEventListener('DOMContentLoaded', _ => {
hljs.registerLanguage('nessa', function () {
return {
case_insensitive: false, // language is case-insensitive
keywords: {
keyword: 'if else for in while fn op return syntax type class let unary binary nary prefix postfix right from to op interface implement import expr block do break continue',
literal: ['false', 'true'],
},
contains: [
{
className: 'literal',
begin: '\'[a-zA-Z_0-9]+(?![a-zA-Z_0-9]*\')'
},
{
className: 'type',
begin: '[A-Z]+[a-zA-Z_0-9]*'
},
{
className: 'literal',
begin: '@[a-zA-Z_0-9]+(?![a-zA-Z_0-9]*\')(?=\\s*(\n|\\())'
},
{
className: 'title',
begin: '[a-zA-Z_][a-zA-Z_0-9]*(?=\\s*:)'
},
{
className: 'title',
begin: '(?<=\\blet\\s*)[a-zA-Z_][a-zA-Z_0-9]*'
},
{
className: 'string',
begin: '"',
end: '"',
contains: [
{
className: 'escape',
begin: '\\\\.',
relevance: 0
}
],
},
{
className: 'literal',
begin: '\'',
end: '\'',
contains: [
{
className: 'escape',
begin: '\\\\.',
relevance: 0
}
],
},
hljs.COMMENT(
'/\\*', // begin
'\\*/', // end
{
contains: [{
className: 'doc',
begin: '@\\w+'
}]
}
),
hljs.COMMENT(
'//', // begin
'$', // end
{
contains: [{
className: 'doc',
begin: '@\\w+'
}]
}
),
{
className: 'number',
begin: '\\b\\d+(.\\d+)?((E|e)-?\\d+)?\\b',
relevance: 0
},
{
className: 'number',
begin: '\\b0b(0|1)+\\b',
relevance: 0
},
{
className: 'number',
begin: '\\b0x([0-9ABCDEF])+\\b',
relevance: 0
}
]
}
})
hljs.configure({
languages: ['nessa']
})
document.querySelectorAll('code').forEach((block) => {
if (!block.innerHTML.includes('%% mermaid')) {
hljs.highlightElement(block);
hljs.lineNumbersBlock(block);
}
});
});