mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Adds Markdown Table syntax highlighting
New styles used are `keyword.table.{header,left,middle,right}`.
This commit is contained in:
parent
0ed9a6c3e9
commit
5b64fd4938
1 changed files with 26 additions and 0 deletions
|
|
@ -57,6 +57,9 @@ export const language = <ILanguage>{
|
||||||
tokenizer: {
|
tokenizer: {
|
||||||
root: [
|
root: [
|
||||||
|
|
||||||
|
// markdown tables
|
||||||
|
[/^\s*\|/, '@rematch', '@table_header'],
|
||||||
|
|
||||||
// headers (with #)
|
// headers (with #)
|
||||||
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']],
|
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']],
|
||||||
|
|
||||||
|
|
@ -88,6 +91,29 @@ export const language = <ILanguage>{
|
||||||
{ include: '@linecontent' },
|
{ 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: [
|
codeblock: [
|
||||||
[/^\s*~~~\s*$/, { token: 'string', next: '@pop' }],
|
[/^\s*~~~\s*$/, { token: 'string', next: '@pop' }],
|
||||||
[/^\s*```\s*$/, { token: 'string', next: '@pop' }],
|
[/^\s*```\s*$/, { token: 'string', next: '@pop' }],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue