mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Handle text and whitespace in HTML
This commit is contained in:
parent
0eadaef95c
commit
712fb631b5
1 changed files with 12 additions and 2 deletions
14
src/html.ts
14
src/html.ts
|
|
@ -65,7 +65,8 @@ export var language = <ILanguage> {
|
||||||
[/<script/, 'tag', '@script'],
|
[/<script/, 'tag', '@script'],
|
||||||
[/<style/, 'tag', '@style'],
|
[/<style/, 'tag', '@style'],
|
||||||
[/<\w+/, 'tag', '@otherTag'],
|
[/<\w+/, 'tag', '@otherTag'],
|
||||||
[/<\/\w+/, 'tag', '@otherTag']
|
[/<\/\w+/, 'tag', '@otherTag'],
|
||||||
|
[/[^<]+/] // text
|
||||||
],
|
],
|
||||||
|
|
||||||
doctype: [
|
doctype: [
|
||||||
|
|
@ -84,7 +85,8 @@ export var language = <ILanguage> {
|
||||||
[/"([^"]*)"/, 'attribute.value'],
|
[/"([^"]*)"/, 'attribute.value'],
|
||||||
[/'([^']*)'/, 'attribute.value'],
|
[/'([^']*)'/, 'attribute.value'],
|
||||||
[/[\w\-]+/, 'attribute.name'],
|
[/[\w\-]+/, 'attribute.name'],
|
||||||
[/=/, 'delimiter']
|
[/=/, 'delimiter'],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
],
|
],
|
||||||
|
|
||||||
// -- BEGIN <script> tags handling
|
// -- BEGIN <script> tags handling
|
||||||
|
|
@ -97,12 +99,14 @@ export var language = <ILanguage> {
|
||||||
[/[\w\-]+/, 'attribute.name'],
|
[/[\w\-]+/, 'attribute.name'],
|
||||||
[/=/, 'delimiter'],
|
[/=/, 'delimiter'],
|
||||||
[/>/, { token: 'tag', next: '@scriptEmbedded', nextEmbedded: 'text/javascript'} ],
|
[/>/, { token: 'tag', next: '@scriptEmbedded', nextEmbedded: 'text/javascript'} ],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, 'tag', '@pop']
|
[/<\/script\s*>/, 'tag', '@pop']
|
||||||
],
|
],
|
||||||
|
|
||||||
// After <script ... type
|
// After <script ... type
|
||||||
scriptAfterType: [
|
scriptAfterType: [
|
||||||
[/=/,'delimiter', '@scriptAfterTypeEquals'],
|
[/=/,'delimiter', '@scriptAfterTypeEquals'],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -110,12 +114,14 @@ export var language = <ILanguage> {
|
||||||
scriptAfterTypeEquals: [
|
scriptAfterTypeEquals: [
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' } ],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
// After <script ... type = $S2
|
// After <script ... type = $S2
|
||||||
scriptWithCustomType: [
|
scriptWithCustomType: [
|
||||||
[/>/, { token: 'tag', next: '@scriptEmbedded', nextEmbedded: '$S2'}],
|
[/>/, { token: 'tag', next: '@scriptEmbedded', nextEmbedded: '$S2'}],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -136,12 +142,14 @@ export var language = <ILanguage> {
|
||||||
[/[\w\-]+/, 'attribute.name'],
|
[/[\w\-]+/, 'attribute.name'],
|
||||||
[/=/, 'delimiter'],
|
[/=/, 'delimiter'],
|
||||||
[/>/, { token: 'tag', next: '@styleEmbedded', nextEmbedded: 'text/css'} ],
|
[/>/, { token: 'tag', next: '@styleEmbedded', nextEmbedded: 'text/css'} ],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, 'tag', '@pop']
|
[/<\/style\s*>/, 'tag', '@pop']
|
||||||
],
|
],
|
||||||
|
|
||||||
// After <style ... type
|
// After <style ... type
|
||||||
styleAfterType: [
|
styleAfterType: [
|
||||||
[/=/,'delimiter', '@styleAfterTypeEquals'],
|
[/=/,'delimiter', '@styleAfterTypeEquals'],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -149,12 +157,14 @@ export var language = <ILanguage> {
|
||||||
styleAfterTypeEquals: [
|
styleAfterTypeEquals: [
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' } ],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
// After <style ... type = $S2
|
// After <style ... type = $S2
|
||||||
styleWithCustomType: [
|
styleWithCustomType: [
|
||||||
[/>/, { token: 'tag', next: '@styleEmbedded', nextEmbedded: '$S2'}],
|
[/>/, { token: 'tag', next: '@styleEmbedded', nextEmbedded: '$S2'}],
|
||||||
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue