Adds Markdown Table syntax highlighting

New styles used are `keyword.table.{header,left,middle,right}`.
pull/2748/head
Steven Degutis 5 years ago committed by GitHub
parent 0ed9a6c3e9
commit 5b64fd4938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,6 +57,9 @@ export const language = <ILanguage>{
tokenizer: {
root: [
// markdown tables
[/^\s*\|/, '@rematch', '@table_header'],
// headers (with #)
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']],
@ -88,6 +91,29 @@ export const language = <ILanguage>{
{ include: '@linecontent' },
],
table_header: [
{ include: '@table_common' },
[/[^\|]+/, 'keyword.table.header'], // table header
],
table_body: [
{ include: '@table_common' },
{ include: '@linecontent' },
],
table_common: [
[/\s*[\-:]+\s*/, { token: 'keyword', switchTo: 'table_body' }], // header-divider
[/^\s*\|/, 'keyword.table.left'], // opening |
[/^\s*[^\|]/, '@rematch', '@pop'], // exiting
[/^\s*$/, '@rematch', '@pop'], // exiting
[/\|/, {
cases: {
'@eos': 'keyword.table.right', // closing |
'@default': 'keyword.table.middle', // inner |
}
}],
],
codeblock: [
[/^\s*~~~\s*$/, { token: 'string', next: '@pop' }],
[/^\s*```\s*$/, { token: 'string', next: '@pop' }],

Loading…
Cancel
Save