Handle text and whitespace in HTML

This commit is contained in:
Alex Dima 2016-09-16 16:42:13 +02:00
parent 0eadaef95c
commit 712fb631b5

View file

@ -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' }]
], ],