Skip to content

Commit

Permalink
Merge pull request #2864 from rcjsuen/md-hyphenated-html-tags
Browse files Browse the repository at this point in the history
Support hyphenated HTML tags in Markdown syntax
  • Loading branch information
hediet authored Jan 3, 2022
2 parents 25e85af + be3ac39 commit a385674
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
48 changes: 48 additions & 0 deletions src/basic-languages/markdown/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,53 @@ testTokenization('markdown', [
{ startIndex: 11, type: 'string.link.md' }
]
}
],

// simple HTML content
[
{
line: '<div>content</div>',
tokens: [
{ startIndex: 0, type: 'tag.md' },
{ startIndex: 5, type: '' },
{ startIndex: 12, type: 'tag.md' }
]
}
],

// hyphenated HTML tag
[
{
line: '<custom-component>content</custom-component>',
tokens: [
{ startIndex: 0, type: 'tag.md' },
{ startIndex: 18, type: '' },
{ startIndex: 25, type: 'tag.md' }
]
}
],

// unclosed HTML tag without hyphens and a trailing character
[
{
line: '<div',
tokens: [{ startIndex: 0, type: 'tag.md' }]
}
],

// unclosed HTML tag with trailing hyphen
[
{
line: '<custom-',
tokens: [{ startIndex: 0, type: 'tag.md' }]
}
],

// unclosed HTML tag with hyphen and a trailing characer
[
{
line: '<custom-component',
tokens: [{ startIndex: 0, type: 'tag.md' }]
}
]
]);
4 changes: 2 additions & 2 deletions src/basic-languages/markdown/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ export const language = <languages.IMonarchLanguage>{
// html tags
[/<(\w+)\/>/, 'tag'],
[
/<(\w+)/,
/<(\w+)(\-|\w)*/,
{
cases: {
'@empty': { token: 'tag', next: '@tag.$1' },
'@default': { token: 'tag', next: '@tag.$1' }
}
}
],
[/<\/(\w+)\s*>/, { token: 'tag' }],
[/<\/(\w+)(\-|\w)*\s*>/, { token: 'tag' }],

[/<!--/, 'comment', '@comment']
],
Expand Down

0 comments on commit a385674

Please sign in to comment.