Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol
diffdown.com
1import {styleTags, tags as t} from "@lezer/highlight"
2
3export const jsHighlight = styleTags({
4 "get set async static": t.modifier,
5 "for while do if else switch try catch finally return throw break continue default case defer": t.controlKeyword,
6 "in of await yield void typeof delete instanceof as satisfies": t.operatorKeyword,
7 "let var const using function class extends": t.definitionKeyword,
8 "import export from": t.moduleKeyword,
9 "with debugger new": t.keyword,
10 TemplateString: t.special(t.string),
11 super: t.atom,
12 BooleanLiteral: t.bool,
13 this: t.self,
14 null: t.null,
15 Star: t.modifier,
16 VariableName: t.variableName,
17 "CallExpression/VariableName TaggedTemplateExpression/VariableName": t.function(t.variableName),
18 VariableDefinition: t.definition(t.variableName),
19 Label: t.labelName,
20 PropertyName: t.propertyName,
21 PrivatePropertyName: t.special(t.propertyName),
22 "CallExpression/MemberExpression/PropertyName": t.function(t.propertyName),
23 "FunctionDeclaration/VariableDefinition": t.function(t.definition(t.variableName)),
24 "ClassDeclaration/VariableDefinition": t.definition(t.className),
25 "NewExpression/VariableName": t.className,
26 PropertyDefinition: t.definition(t.propertyName),
27 PrivatePropertyDefinition: t.definition(t.special(t.propertyName)),
28 UpdateOp: t.updateOperator,
29 "LineComment Hashbang": t.lineComment,
30 BlockComment: t.blockComment,
31 Number: t.number,
32 String: t.string,
33 Escape: t.escape,
34 ArithOp: t.arithmeticOperator,
35 LogicOp: t.logicOperator,
36 BitOp: t.bitwiseOperator,
37 CompareOp: t.compareOperator,
38 RegExp: t.regexp,
39 Equals: t.definitionOperator,
40 Arrow: t.function(t.punctuation),
41 ": Spread": t.punctuation,
42 "( )": t.paren,
43 "[ ]": t.squareBracket,
44 "{ }": t.brace,
45 "InterpolationStart InterpolationEnd": t.special(t.brace),
46 ".": t.derefOperator,
47 ", ;": t.separator,
48 "@": t.meta,
49
50 TypeName: t.typeName,
51 TypeDefinition: t.definition(t.typeName),
52 "type enum interface implements namespace module declare": t.definitionKeyword,
53 "abstract global Privacy readonly override": t.modifier,
54 "is keyof unique infer asserts": t.operatorKeyword,
55
56 JSXAttributeValue: t.attributeValue,
57 JSXText: t.content,
58 "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": t.angleBracket,
59 "JSXIdentifier JSXNameSpacedName": t.tagName,
60 "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": t.attributeName,
61 "JSXBuiltin/JSXIdentifier": t.standard(t.tagName)
62})