Plain text inside an html script tag

This commit is contained in:
Fedor Korotkov
2013-04-30 16:40:22 +04:00
parent e40d0a6cea
commit 82856efe3e
3 changed files with 10 additions and 19 deletions
@@ -150,21 +150,11 @@ abstract class BaseHtmlLexer extends DelegateLexer {
@NonNls String mimeType = TreeUtil.getTokenText(lexer);
if (caseInsensitive) mimeType = mimeType.toLowerCase();
if (supportMimeType(mimeType)) {
scriptType = mimeType;
}
else {
seenScript = false;
seenTag = true; // will be switched of on tag name in end
}
scriptType = mimeType;
}
}
}
private boolean supportMimeType(String mimeType) {
return findScriptContentProvider(mimeType) != null;
}
@Nullable
protected IElementType getCurrentScriptElementType() {
HtmlScriptContentProvider scriptContentProvider = findScriptContentProvider(scriptType);
@@ -15,10 +15,7 @@
*/
package com.intellij.lexer;
import com.intellij.lang.HtmlInlineScriptTokenTypesProvider;
import com.intellij.lang.HtmlScriptContentProvider;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageHtmlInlineScriptTokenTypesProvider;
import com.intellij.lang.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
@@ -124,7 +121,11 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer {
if (scriptLexer == null) {
if (hasSeenTag()) {
HtmlScriptContentProvider provider = findScriptContentProvider(scriptType);
scriptLexer = provider != null ? provider.getHighlightingLexer() : null;
if (provider != null) {
scriptLexer = provider.getHighlightingLexer();
} else {
scriptLexer = SyntaxHighlighterFactory.getSyntaxHighlighter(StdLanguages.TEXT, null, null).getHighlightingLexer();
}
}
else if (hasSeenAttribute()) {
SyntaxHighlighter syntaxHighlighter =
@@ -75,10 +75,10 @@ public class HtmlLexer extends BaseHtmlLexer {
tokenType = ourInlineStyleElementType;
}
} else if (hasSeenScript()) {
IElementType currentScriptElementType = getCurrentScriptElementType();
if (hasSeenTag() && currentScriptElementType != null && isStartOfEmbeddmentTagContent(tokenType)) {
if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType)) {
myTokenEnd = skipToTheEndOfTheEmbeddment();
tokenType = currentScriptElementType;
IElementType currentScriptElementType = getCurrentScriptElementType();
tokenType = currentScriptElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentScriptElementType;
} else if (hasSeenAttribute() && isStartOfEmbeddmentAttributeValue(tokenType) && ourInlineScriptElementType!=null) {
myTokenEnd = skipToTheEndOfTheEmbeddment();
tokenType = ourInlineScriptElementType;