-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// https://www.json.org/json-en.html | ||
Prism.languages.json = { | ||
'property': { | ||
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
'string': { | ||
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
'comment': { | ||
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, | ||
greedy: true | ||
}, | ||
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, | ||
'punctuation': /[{}[\],]/, | ||
'operator': /:/, | ||
'boolean': /\b(?:false|true)\b/, | ||
'null': { | ||
pattern: /\bnull\b/, | ||
alias: 'keyword' | ||
} | ||
}; | ||
|
||
Prism.languages.webmanifest = Prism.languages.json; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(function (Prism) { | ||
|
||
Prism.languages.typescript = Prism.languages.extend('javascript', { | ||
'class-name': { | ||
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/, | ||
lookbehind: true, | ||
greedy: true, | ||
inside: null // see below | ||
}, | ||
'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/, | ||
}); | ||
|
||
// The keywords TypeScript adds to JavaScript | ||
Prism.languages.typescript.keyword.push( | ||
/\b(?:abstract|declare|is|keyof|readonly|require)\b/, | ||
// keywords that have to be followed by an identifier | ||
/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/, | ||
// This is for `import type *, {}` | ||
/\btype\b(?=\s*(?:[\{*]|$))/ | ||
); | ||
|
||
// doesn't work with TS because TS is too complex | ||
delete Prism.languages.typescript['parameter']; | ||
delete Prism.languages.typescript['literal-property']; | ||
|
||
// a version of typescript specifically for highlighting types | ||
var typeInside = Prism.languages.extend('typescript', {}); | ||
delete typeInside['class-name']; | ||
|
||
Prism.languages.typescript['class-name'].inside = typeInside; | ||
|
||
Prism.languages.insertBefore('typescript', 'function', { | ||
'decorator': { | ||
pattern: /@[$\w\xA0-\uFFFF]+/, | ||
inside: { | ||
'at': { | ||
pattern: /^@/, | ||
alias: 'operator' | ||
}, | ||
'function': /^[\s\S]+/ | ||
} | ||
}, | ||
'generic-function': { | ||
// e.g. foo<T extends "bar" | "baz">( ... | ||
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/, | ||
greedy: true, | ||
inside: { | ||
'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/, | ||
'generic': { | ||
pattern: /<[\s\S]+/, // everything after the first < | ||
alias: 'class-name', | ||
inside: typeInside | ||
} | ||
} | ||
} | ||
}); | ||
|
||
Prism.languages.ts = Prism.languages.typescript; | ||
|
||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.