Skip to content

Commit a385674

Browse files
authored
Merge pull request #2864 from rcjsuen/md-hyphenated-html-tags
Support hyphenated HTML tags in Markdown syntax
2 parents 25e85af + be3ac39 commit a385674

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

src/basic-languages/markdown/markdown.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,53 @@ testTokenization('markdown', [
4343
{ startIndex: 11, type: 'string.link.md' }
4444
]
4545
}
46+
],
47+
48+
// simple HTML content
49+
[
50+
{
51+
line: '<div>content</div>',
52+
tokens: [
53+
{ startIndex: 0, type: 'tag.md' },
54+
{ startIndex: 5, type: '' },
55+
{ startIndex: 12, type: 'tag.md' }
56+
]
57+
}
58+
],
59+
60+
// hyphenated HTML tag
61+
[
62+
{
63+
line: '<custom-component>content</custom-component>',
64+
tokens: [
65+
{ startIndex: 0, type: 'tag.md' },
66+
{ startIndex: 18, type: '' },
67+
{ startIndex: 25, type: 'tag.md' }
68+
]
69+
}
70+
],
71+
72+
// unclosed HTML tag without hyphens and a trailing character
73+
[
74+
{
75+
line: '<div',
76+
tokens: [{ startIndex: 0, type: 'tag.md' }]
77+
}
78+
],
79+
80+
// unclosed HTML tag with trailing hyphen
81+
[
82+
{
83+
line: '<custom-',
84+
tokens: [{ startIndex: 0, type: 'tag.md' }]
85+
}
86+
],
87+
88+
// unclosed HTML tag with hyphen and a trailing characer
89+
[
90+
{
91+
line: '<custom-component',
92+
tokens: [{ startIndex: 0, type: 'tag.md' }]
93+
}
4694
]
4795
]);

src/basic-languages/markdown/markdown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ export const language = <languages.IMonarchLanguage>{
166166
// html tags
167167
[/<(\w+)\/>/, 'tag'],
168168
[
169-
/<(\w+)/,
169+
/<(\w+)(\-|\w)*/,
170170
{
171171
cases: {
172172
'@empty': { token: 'tag', next: '@tag.$1' },
173173
'@default': { token: 'tag', next: '@tag.$1' }
174174
}
175175
}
176176
],
177-
[/<\/(\w+)\s*>/, { token: 'tag' }],
177+
[/<\/(\w+)(\-|\w)*\s*>/, { token: 'tag' }],
178178

179179
[/<!--/, 'comment', '@comment']
180180
],

0 commit comments

Comments
 (0)