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
|
import {parser} from "./syntax.grammar"
import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language"
import {styleTags, tags as t} from "@lezer/highlight"
export const tabloidLanguage = LRLanguage.define({
parser: parser.configure({
props: [
indentNodeProp.add({
Block: delimitedIndent({closing: "endOfStory", align: false}),
ParenBlock: delimitedIndent({closing: ")", align: false}),
FunctionDecl: context => context.baseIndent + context.unit,
IfStatement: context => context.baseIndent + context.unit,
}),
foldNodeProp.add({
Block: foldInside,
ParenBlock: foldInside,
}),
styleTags({
Identifier: t.variableName,
NumberLiteral: t.number,
StringLiteral: t.string,
BooleanLiteral: t.bool,
FunctionCall: t.function(t.variableName),
discoverHowTo: t.definitionKeyword,
expertsClaim: t.definitionKeyword,
toBe: t.operatorKeyword,
rumorHasIt: t.keyword,
endOfStory: t.keyword,
whatIf: t.controlKeyword,
liesBang: t.controlKeyword,
shockingDevelopment: t.controlKeyword,
youWontWantToMiss: t.keyword,
latestNewsOn: t.keyword,
pleaseLikeAndSubscribe: t.keyword,
"with of": t.keyword,
"isActually beats smallerThan": t.compareOperator,
"and or": t.logicOperator,
"plus minus times dividedBy modulo": t.arithmeticOperator,
"( )": t.paren,
",": t.separator
})
]
}),
languageData: {
commentTokens: {}
}
})
export function tabloid() {
return new LanguageSupport(tabloidLanguage)
}
|