From be3ac39fbf0f2c2df808686df17277f994ac88af Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Thu, 30 Dec 2021 08:00:31 -0500 Subject: [PATCH] Support hyphenated HTML tags in Markdown syntax Signed-off-by: Remy Suen --- src/basic-languages/markdown/markdown.test.ts | 48 +++++++++++++++++++ src/basic-languages/markdown/markdown.ts | 4 +- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/basic-languages/markdown/markdown.test.ts b/src/basic-languages/markdown/markdown.test.ts index 7253cbe6a7..9c08ec60e3 100644 --- a/src/basic-languages/markdown/markdown.test.ts +++ b/src/basic-languages/markdown/markdown.test.ts @@ -43,5 +43,53 @@ testTokenization('markdown', [ { startIndex: 11, type: 'string.link.md' } ] } + ], + + // simple HTML content + [ + { + line: '
content
', + tokens: [ + { startIndex: 0, type: 'tag.md' }, + { startIndex: 5, type: '' }, + { startIndex: 12, type: 'tag.md' } + ] + } + ], + + // hyphenated HTML tag + [ + { + line: 'content', + tokens: [ + { startIndex: 0, type: 'tag.md' }, + { startIndex: 18, type: '' }, + { startIndex: 25, type: 'tag.md' } + ] + } + ], + + // unclosed HTML tag without hyphens and a trailing character + [ + { + line: '{ // html tags [/<(\w+)\/>/, 'tag'], [ - /<(\w+)/, + /<(\w+)(\-|\w)*/, { cases: { '@empty': { token: 'tag', next: '@tag.$1' }, @@ -174,7 +174,7 @@ export const language = { } } ], - [/<\/(\w+)\s*>/, { token: 'tag' }], + [/<\/(\w+)(\-|\w)*\s*>/, { token: 'tag' }], [/