diff --git a/scintilla/lexers/LexHTML.cxx b/scintilla/lexers/LexHTML.cxx
index 8cf8d84233..cb3bdc35e6 100644
--- a/scintilla/lexers/LexHTML.cxx
+++ b/scintilla/lexers/LexHTML.cxx
@@ -153,14 +153,14 @@ constexpr bool isCommentASPState(int state) noexcept {
}
bool classifyAttribHTML(Sci_PositionU end, LexerWordList keywordLists, LexAccessor &styler, script_mode inScriptType, bool isXml) {
+ char s[MaxKeywordSize];
int chAttr = SCE_H_ATTRIBUTEUNKNOWN;
bool isLanguageType = false;
const Sci_PositionU start = styler.GetStartSegment();
- if (IsNumberChar(styler[start])) {
+ styler.GetRangeLowered(start, end, s, sizeof(s));
+ if (IsNumberChar(s[0])) {
chAttr = SCE_H_NUMBER;
} else {
- char s[MaxKeywordSize];
- styler.GetRangeLowered(start, end, s, sizeof(s));
if (inScriptType == eNonHtmlScript) {
// see https://html.spec.whatwg.org/multipage/scripting.html
if (StrEqualsAny(s, "type", "language")) {
@@ -186,25 +186,15 @@ bool isHTMLCustomElement(const char *tag, size_t length, bool dashColon) noexcep
}
int classifyTagHTML(Sci_PositionU end, LexerWordList keywordLists, LexAccessor &styler, bool &tagDontFold, bool isXml, bool allowScripts) {
- char tag[127 + 1];
- // Copy after the '<' and stop before space
- Sci_PositionU length = 0;
- bool dashColon = false;
+ char s[63 + 1];
+ memset(s, '\0', 4);
const Sci_PositionU start = styler.GetStartSegment();
- for (Sci_PositionU cPos = start; cPos < end && length < sizeof(tag) - 1; cPos++) {
- const char ch = styler[cPos];
- if (static_cast(ch) <= ' ') {
- break;
- }
- if ((ch != '<') && (ch != '/')) {
- tag[length++] = isXml ? ch : MakeLowerCase(ch);
- if (ch == ':' || ch == '-') {
- dashColon = true;
- }
- }
+ styler.GetRange(start, end, s, sizeof(s));
+ char *tag = s;
+ if (tag[0] == '<') {
+ tag += (tag[1] == '/') ? 2 : 1;
}
- tag[length] = '\0';
int chAttr = SCE_H_TAGUNKNOWN;
bool customElement = false;
if (tag[0] == '!') {
@@ -212,10 +202,20 @@ int classifyTagHTML(Sci_PositionU end, LexerWordList keywordLists, LexAccessor &
} else if (isXml) {
chAttr = SCE_H_TAG;
} else {
+ bool dashColon = false;
+ char *t = tag;
+ while (*t) {
+ if (*t >= 'A' && *t <= 'Z') {
+ *t |= 'a' - 'A';
+ } else if (*t == ':' || *t == '-') {
+ dashColon = true;
+ }
+ ++t;
+ }
tagDontFold = keywordLists[KeywordIndex_VoidTag].InList(tag);
if (tagDontFold || keywordLists[KeywordIndex_Tag].InList(tag)) {
chAttr = SCE_H_TAG;
- } else if (isHTMLCustomElement(tag, length, dashColon)) {
+ } else if (isHTMLCustomElement(tag, t - tag, dashColon)) {
customElement = true;
chAttr = SCE_H_TAG;
}
@@ -227,7 +227,7 @@ int classifyTagHTML(Sci_PositionU end, LexerWordList keywordLists, LexAccessor &
if (allowScripts && StrEqual(tag, "script")) {
// check to see if this is a self-closing tag by sniffing ahead
bool isSelfClose = false;
- for (Sci_PositionU cPos = end - 1; cPos < end + maxLengthCheck; cPos++) {
+ for (Sci_PositionU cPos = end; cPos < end + maxLengthCheck; cPos++) {
const char ch = styler.SafeGetCharAt(cPos);
if (ch == '\0' || ch == '>')
break;
diff --git a/scintilla/lexers/LexPHP.cxx b/scintilla/lexers/LexPHP.cxx
index 401756708d..ae7d180b14 100644
--- a/scintilla/lexers/LexPHP.cxx
+++ b/scintilla/lexers/LexPHP.cxx
@@ -225,14 +225,18 @@ void PHPLexer::ClassifyHtmlTag(LexerWordList keywordLists) {
sc.SetState((tagType == HtmlTagType::Question) ? SCE_H_QUESTION : SCE_H_TAG);
} else if (tagType == HtmlTagType::None) {
char s[16];
+ memset(s, '\0', 4);
sc.GetCurrentLowered(s, sizeof(s));
- const char * const p = s + 1;
+ const char *p = s + 1;
if (StrEqual(p, "script")) {
tagType = HtmlTagType::Script;
} else if (StrEqual(p, "style")) {
tagType = HtmlTagType::Style;
} else {
tagType = HtmlTagType::Normal;
+ if (p[0] == '/') {
+ ++p;
+ }
if (keywordLists[KeywordIndex_VoidTag].InList(p)) {
tagType = HtmlTagType::Void;
}
diff --git a/src/EditLexers/stlHTML.cpp b/src/EditLexers/stlHTML.cpp
index c364d7114e..c6b8c549a8 100644
--- a/src/EditLexers/stlHTML.cpp
+++ b/src/EditLexers/stlHTML.cpp
@@ -13,12 +13,15 @@ static KEYWORDLIST Keywords_HTML = {{
"s samp script search section select slot small source spacer span strike strong style sub summary sup svg "
"table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr xml xmp "
-, // 1 JavaScript
+, // 1 void tag
+" area base basefont br col command embed frame hr img input isindex keygen link meta p param source track wbr "
+
+, // 2 JavaScript
"Infinity NaN arguments async await break case catch class const continue debugger default delete do else export extends "
"false finally for function get globalThis if import in instanceof let new null of return set static super switch "
"this throw true try typeof undefined var void while with yield "
-, // 2 VBScript
+, // 3 VBScript
"Alias And As Attribute Begin Boolean ByRef Byte ByVal Call Case Char Class Compare Const Continue Currency "
"Decimal Declare Default Dim Do Double "
"Each Else ElseIf Empty End EndIf Enum Eqv Erase Error Event Execute ExecuteGlobal Exit Explicit "
@@ -28,11 +31,11 @@ static KEYWORDLIST Keywords_HTML = {{
"Select Set Shared Single Static Step Stop String Sub Then To True Type TypeOf Unload Until Variant "
"Wend While With WithEvents Xor "
-, // 3 SGML
+, // 4 SGML
"ANY ATTLIST CDATA DOCTYPE ELEMENT EMPTY ENTITIES ENTITY FIXED ID IDREF IDREFS IGNORE IMPLIED INCLUDE "
"NDATA NMTOKEN NMTOKENS NOTATION PCDATA PUBLIC REQUIRED SGML SYSTEM doctype "
-, // 4 attribute
+, // 5 attribute
"^aria- ^data- "
"abbr accept accept-charset accesskey action align alink allow allowfullscreen allowtransparency alpha alt archive "
"as async autocapitalize autocomplete autocorrect autofocus autoplay axis "
@@ -73,7 +76,7 @@ static KEYWORDLIST Keywords_HTML = {{
"valign value valuetype version vlink vocab vspace width wrap writingsuggestions "
"xml:base xml:lang xmlns xmlns:xsi xsi:schemaLocation "
-, // 5 value
+, // 6 value
"GET POST UTF-8 _blank _parent _self _top "
"about allow-downloads allow-forms allow-modals allow-orientation-lock "
"allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts "
@@ -96,7 +99,7 @@ static KEYWORDLIST Keywords_HTML = {{
"theme-color toggle true "
"unsafe-url until-found upper-alpha upper-roman url use-credentials utf-8 week words x-ua-compatible yes "
-, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
+, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
//--Autogenerated -- end of section automatically generated
}};
@@ -152,11 +155,12 @@ EDITLEXER lexHTML = {
0, 0,
0, 0
, KeywordAttr32(0, KeywordAttr_PreSorted) // tag
- | KeywordAttr32(1, KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // JavaScript
- | KeywordAttr32(2, KeywordAttr_MakeLower | KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // VBScript
- | KeywordAttr32(3, KeywordAttr_PreSorted) // SGML
- | KeywordAttr32(4, KeywordAttr_PreSorted) // attribute
- | KeywordAttr32(5, KeywordAttr_NoLexer) // value
+ | KeywordAttr32(1, KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // void tag
+ | KeywordAttr32(2, KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // JavaScript
+ | KeywordAttr32(3, KeywordAttr_MakeLower | KeywordAttr_PreSorted | KeywordAttr_NoAutoComp) // VBScript
+ | KeywordAttr32(4, KeywordAttr_PreSorted) // SGML
+ | KeywordAttr32(5, KeywordAttr_PreSorted) // attribute
+ | KeywordAttr32(6, KeywordAttr_NoLexer) // value
, 0,
0, 0,
//Settings--Autogenerated -- end of section automatically generated