mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[Monaco] Use syntax highlighting for .srt (#35651)
* [FilePreview] Use syntax highlighting for .srt * Change customTokenColors to customTokenThemeRules * Ignore text on the same line as a timestamp * Update tokenization rules
This commit is contained in:
29
src/Monaco/customLanguages/srt.js
Normal file
29
src/Monaco/customLanguages/srt.js
Normal file
@@ -0,0 +1,29 @@
|
||||
export function srtDefinition() {
|
||||
return {
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/\s*\d+/, 'number', '@block']
|
||||
],
|
||||
|
||||
block: [
|
||||
[/^\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}/, {
|
||||
cases: {
|
||||
'@eos': {token: 'type.identifier', next: '@subtitle'},
|
||||
'@default': {token: 'type.identifier', next: '@ignore'}
|
||||
}
|
||||
}],
|
||||
[/^$/, 'string', '@pop']
|
||||
],
|
||||
|
||||
ignore: [
|
||||
[/.+$/, '', '@subtitle']
|
||||
],
|
||||
|
||||
subtitle: [
|
||||
[/^$/, 'string', '@popall'],
|
||||
[/<\/?(?:[ibu]|font(?:\s+color="[^"]+"\s*)?)>/, 'tag'],
|
||||
[/./, 'string']
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user