From 152d797ce374a8da9b41f6631f0449802b1761e1 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 6 Jun 2000 14:38:23 +0000 Subject: Handle CDATA sections in XML. --- src/LexHTML.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/LexHTML.cxx') diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index 9a9377292..678398742 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -71,9 +71,12 @@ static int classifyTagHTML(unsigned int start, unsigned int end, s[i++] = static_cast(tolower(ch)); } s[i] = '\0'; +Platform::DebugPrintf("Classify =%s=\n", s); char chAttr = SCE_H_TAGUNKNOWN; if (s[0] == '!' && s[1] == '-' && s[2] == '-') { //Comment chAttr = SCE_H_COMMENT; + } else if (strcmp(s, "![cdata[") == 0) { // In lower case because already converted + chAttr = SCE_H_CDATA; } else if (s[0] == '/') { // Closing tag if (keywords.InList(s + 1)) chAttr = SCE_H_TAG; @@ -354,6 +357,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i, state); state = SCE_H_DEFAULT; } + } else if (state == SCE_H_CDATA) { + if ((ch == '>') && (chPrev == ']') && (chPrev2 == ']')) { + styler.ColourTo(i, state); + state = SCE_H_DEFAULT; + } } else if (state == SCE_H_ENTITY) { if (ch == ';') { styler.ColourTo(i, state); @@ -364,7 +372,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_DEFAULT; } } else if (state == SCE_H_TAGUNKNOWN) { - if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') { + if (!ishtmlwordchar(ch) && ch != '/' && ch != '-' && ch != '[') { int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler); lastTagWasScript = eClass == SCE_H_SCRIPT; if (lastTagWasScript) { @@ -386,6 +394,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else { if (eClass == SCE_H_COMMENT) { state = SCE_H_COMMENT; + } else if (eClass == SCE_H_CDATA) { + state = SCE_H_CDATA; } else { state = SCE_H_OTHER; } -- cgit v1.2.3