MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / classifyTagHTML

Function classifyTagHTML

scintilla/src/LexHTML.cxx:223–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223static int classifyTagHTML(unsigned int start, unsigned int end,
224 WordList &keywords, Accessor &styler, bool &tagDontFold,
225 bool caseSensitive) {
226 char s[30 + 2];
227 // Copy after the '<'
228 unsigned int i = 0;
229 for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
230 char ch = styler[cPos];
231 if ((ch != '<') && (ch != '/')) {
232 s[i++] = caseSensitive ? ch : static_cast<char>(MakeLowerCase(ch));
233 }
234 }
235
236 //The following is only a quick hack, to see if this whole thing would work
237 //we first need the tagname with a trailing space...
238 s[i] = ' ';
239 s[i+1] = '\0';
240
241 //...to find it in the list of no-container-tags
242 // (There are many more. We will need a keywordlist in the property file for this)
243 tagDontFold = (NULL != strstr("meta link img area br hr input ",s));
244
245 //now we can remove the trailing space
246 s[i] = '\0';
247
248 bool isScript = false;
249 char chAttr = SCE_H_TAGUNKNOWN;
250 if (s[0] == '!') {
251 chAttr = SCE_H_SGML_DEFAULT;
252 } else if (s[0] == '/') { // Closing tag
253 if (keywords.InList(s + 1))
254 chAttr = SCE_H_TAG;
255 } else {
256 if (keywords.InList(s)) {
257 chAttr = SCE_H_TAG;
258 isScript = 0 == strcmp(s, "script");
259 }
260 }
261 if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords) {
262 // No keywords -> all are known
263 chAttr = SCE_H_TAG;
264 isScript = 0 == strcmp(s, "script");
265 }
266 styler.ColourTo(end, chAttr);
267 return isScript ? SCE_H_SCRIPT : chAttr;
268}
269
270static void classifyWordHTJS(unsigned int start, unsigned int end,
271 WordList &keywords, Accessor &styler, script_mode inScriptType) {

Callers 1

ColouriseHyperTextDocFunction · 0.85

Calls 3

InListMethod · 0.80
MakeLowerCaseFunction · 0.70
ColourToMethod · 0.45

Tested by

no test coverage detected