-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
prism-flow.js
35 lines (32 loc) · 1.06 KB
/
prism-flow.js
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
(function (Prism) {
Prism.languages.flow = Prism.languages.extend('javascript', {});
Prism.languages.insertBefore('flow', 'keyword', {
'type': [
{
pattern: /\b(?:[Bb]oolean|Function|[Nn]umber|[Ss]tring|any|mixed|null|void)\b/,
alias: 'tag'
}
]
});
Prism.languages.flow['function-variable'].pattern = /(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/i;
delete Prism.languages.flow['parameter'];
Prism.languages.insertBefore('flow', 'operator', {
'flow-punctuation': {
pattern: /\{\||\|\}/,
alias: 'punctuation'
}
});
if (!Array.isArray(Prism.languages.flow.keyword)) {
Prism.languages.flow.keyword = [Prism.languages.flow.keyword];
}
Prism.languages.flow.keyword.unshift(
{
pattern: /(^|[^$]\b)(?:Class|declare|opaque|type)\b(?!\$)/,
lookbehind: true
},
{
pattern: /(^|[^$]\B)\$(?:Diff|Enum|Exact|Keys|ObjMap|PropertyType|Record|Shape|Subtype|Supertype|await)\b(?!\$)/,
lookbehind: true
}
);
}(Prism));