Skip to content

Commit

Permalink
Merge pull request #3226 from luisscholl-at-software-ag/html-syntax-h…
Browse files Browse the repository at this point in the history
…ighlighting-script-type-module

Add script type module syntax highlighting to html
  • Loading branch information
hediet committed Aug 3, 2022
2 parents f90ab42 + 83cb8fa commit acc3d9a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/basic-languages/html/html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,32 @@ testTokenization(
}
],

// Embedded Content #10
[
{
line: '<script type="module">var i= 10;</script>',
tokens: [
{ startIndex: 0, type: 'delimiter.html' },
{ startIndex: 1, type: 'tag.html' },
{ startIndex: 7, type: '' },
{ startIndex: 8, type: 'attribute.name.html' },
{ startIndex: 12, type: 'delimiter.html' },
{ startIndex: 13, type: 'attribute.value.html' },
{ startIndex: 21, type: 'delimiter.html' },
{ startIndex: 22, type: 'keyword.js' },
{ startIndex: 25, type: '' },
{ startIndex: 26, type: 'identifier.js' },
{ startIndex: 27, type: 'delimiter.js' },
{ startIndex: 28, type: '' },
{ startIndex: 29, type: 'number.js' },
{ startIndex: 31, type: 'delimiter.js' },
{ startIndex: 32, type: 'delimiter.html' },
{ startIndex: 34, type: 'tag.html' },
{ startIndex: 40, type: 'delimiter.html' }
]
}
],

// Tag with Attribute
[
{
Expand Down
14 changes: 14 additions & 0 deletions src/basic-languages/html/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ export const language = <languages.IMonarchLanguage>{

// After <script ... type =
scriptAfterTypeEquals: [
[
/"module"/,
{
token: 'attribute.value',
switchTo: '@scriptWithCustomType.text/javascript'
}
],
[
/'module'/,
{
token: 'attribute.value',
switchTo: '@scriptWithCustomType.text/javascript'
}
],
[
/"([^"]*)"/,
{
Expand Down

0 comments on commit acc3d9a

Please sign in to comment.