diff --git a/src/basic-languages/mdx/mdx.test.ts b/src/basic-languages/mdx/mdx.test.ts index 7e64f0a2..99ef43cc 100644 --- a/src/basic-languages/mdx/mdx.test.ts +++ b/src/basic-languages/mdx/mdx.test.ts @@ -5,4 +5,167 @@ import { testTokenization } from '../test/testRunner'; -testTokenization('mdx', []); +testTokenization( + ['mdx', 'yaml'], + [ + // headers + [ + { + line: '# header 1', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + }, + { + line: '## header 2', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + }, + { + line: '### header 3', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + }, + { + line: '#### header 4', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + }, + { + line: '##### header 5', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + }, + { + line: '###### header 6', + tokens: [{ startIndex: 0, type: 'keyword.mdx' }] + } + ], + + // Lists + [ + { + line: '- apple', + tokens: [ + { startIndex: 0, type: 'keyword.mdx' }, + { startIndex: 1, type: 'white.mdx' }, + { startIndex: 2, type: '' } + ] + }, + { + line: '* pear', + tokens: [ + { startIndex: 0, type: 'keyword.mdx' }, + { startIndex: 1, type: 'white.mdx' }, + { startIndex: 2, type: '' } + ] + }, + { + line: '+ pineapple', + tokens: [ + { startIndex: 0, type: 'keyword.mdx' }, + { startIndex: 1, type: 'white.mdx' }, + { startIndex: 2, type: '' } + ] + }, + { + line: '1. orange', + tokens: [ + { startIndex: 0, type: 'number.mdx' }, + { startIndex: 2, type: 'white.mdx' }, + { startIndex: 3, type: '' } + ] + } + ], + + // Frontmatter + [ + { + line: '---', + tokens: [{ startIndex: 0, type: 'meta.content.mdx' }] + }, + { + line: 'frontmatter: yaml', + tokens: [ + { startIndex: 0, type: 'type.yaml' }, + { startIndex: 11, type: 'operators.yaml' }, + { startIndex: 12, type: 'white.yaml' }, + { startIndex: 13, type: 'string.yaml' } + ] + }, + { + line: '---', + tokens: [{ startIndex: 0, type: 'meta.content.mdx' }] + } + ], + + // links + [ + { + line: '[MDX](https://mdxjs.com)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'type.identifier.mdx' }, + { startIndex: 4, type: '' }, + { startIndex: 6, type: 'string.link.mdx' }, + { startIndex: 23, type: '' } + ] + }, + { + line: '[monaco][monaco]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'type.identifier.mdx' }, + { startIndex: 7, type: '' }, + { startIndex: 9, type: 'type.identifier.mdx' }, + { startIndex: 15, type: '' } + ] + }, + { + line: '[monaco][]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'type.identifier.mdx' }, + { startIndex: 9, type: '' } + ] + }, + { + line: '[monaco]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'type.identifier.mdx' }, + { startIndex: 7, type: '' } + ] + }, + { + line: '[monaco]: https://github.com/microsoft/monaco-editor', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'type.identifier.mdx' }, + { startIndex: 7, type: '' }, + { startIndex: 10, type: 'string.link.mdx' } + ] + } + ], + + // JSX + [ + { + line: '
Hi, {name}!
+ +and some more things
+