diff --git a/src/markdown/markdown.ts b/src/markdown/markdown.ts index c2b852fd..79cbadf4 100644 --- a/src/markdown/markdown.ts +++ b/src/markdown/markdown.ts @@ -8,23 +8,6 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; import ILanguage = monaco.languages.IMonarchLanguage; -const TOKEN_HEADER_LEAD = 'keyword'; -const TOKEN_HEADER = 'keyword'; -const TOKEN_EXT_HEADER = 'keyword'; -const TOKEN_SEPARATOR = 'meta.separator'; -const TOKEN_QUOTE = 'comment'; -const TOKEN_LIST = 'keyword'; -const TOKEN_BLOCK = 'string'; -const TOKEN_BLOCK_CODE = 'variable.source'; - -const DELIM_ASSIGN = 'delimiter.html'; -const ATTRIB_NAME = 'attribute.name.html'; -const ATTRIB_VALUE = 'string.html'; - -function getTag(name: string) { - return 'tag'; -} - export const conf: IRichLanguageConfiguration = { comments: { blockComment: ['',] @@ -75,46 +58,46 @@ export const language = { root: [ // headers (with #) - [/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', TOKEN_HEADER_LEAD, TOKEN_HEADER, TOKEN_HEADER]], + [/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']], // headers (with =) - [/^\s*(=+|\-+)\s*$/, TOKEN_EXT_HEADER], + [/^\s*(=+|\-+)\s*$/, 'keyword'], // headers (with ***) - [/^\s*((\*[ ]?)+)\s*$/, TOKEN_SEPARATOR], + [/^\s*((\*[ ]?)+)\s*$/, 'meta.separator'], // quote - [/^\s*>+/, TOKEN_QUOTE], + [/^\s*>+/, 'comment'], // list (starting with * or number) - [/^\s*([\*\-+:]|\d+\.)\s/, TOKEN_LIST], + [/^\s*([\*\-+:]|\d+\.)\s/, 'keyword'], // code block (4 spaces indent) - [/^(\t|[ ]{4})[^ ].*$/, TOKEN_BLOCK], + [/^(\t|[ ]{4})[^ ].*$/, 'string'], // code block (3 tilde) - [/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }], + [/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: 'string', next: '@codeblock' }], // github style code blocks (with backticks and language) - [/^\s*```\s*((?:\w|[\/\-#])+)\s*$/, { token: TOKEN_BLOCK, next: '@codeblockgh', nextEmbedded: '$1' }], + [/^\s*```\s*((?:\w|[\/\-#])+)\s*$/, { token: 'string', next: '@codeblockgh', nextEmbedded: '$1' }], // github style code blocks (with backticks but no language) - [/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@codeblock' }], + [/^\s*```\s*$/, { token: 'string', next: '@codeblock' }], // markup within lines { include: '@linecontent' }, ], codeblock: [ - [/^\s*~~~\s*$/, { token: TOKEN_BLOCK, next: '@pop' }], - [/^\s*```\s*$/, { token: TOKEN_BLOCK, next: '@pop' }], - [/.*$/, TOKEN_BLOCK_CODE], + [/^\s*~~~\s*$/, { token: 'string', next: '@pop' }], + [/^\s*```\s*$/, { token: 'string', next: '@pop' }], + [/.*$/, 'variable.source'], ], // github style code blocks codeblockgh: [ - [/```\s*$/, { token: TOKEN_BLOCK_CODE, next: '@pop', nextEmbedded: '@pop' }], - [/[^`]+/, TOKEN_BLOCK_CODE], + [/```\s*$/, { token: 'variable.source', next: '@pop', nextEmbedded: '@pop' }], + [/[^`]+/, 'variable.source'], ], linecontent: [ @@ -146,14 +129,14 @@ export const language = { // we cannot correctly tokenize it in that mode yet. html: [ // html tags - [/<(\w+)\/>/, getTag('$1')], + [/<(\w+)\/>/, 'tag'], [/<(\w+)/, { cases: { - '@empty': { token: getTag('$1'), next: '@tag.$1' }, - '@default': { token: getTag('$1'), next: '@tag.$1' } + '@empty': { token: 'tag', next: '@tag.$1' }, + '@default': { token: 'tag', next: '@tag.$1' } } }], - [/<\/(\w+)\s*>/, { token: getTag('$1') }], + [/<\/(\w+)\s*>/, { token: 'tag' }], [/