aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--lexers/LexHTML.cxx14
2 files changed, 18 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index e232e2580..b3a58e810 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -555,6 +555,10 @@
Released 24 October 2019.
</li>
<li>
+ HTML lexer treats custom tags from HTML5 as known tags. These contain "-" like "custom-tag".
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1299/">Feature #1299</a>.
+ </li>
+ <li>
HTML lexer fixes bug with some non-alphabetic characters in unknown tags.
<a href="https://sourceforge.net/p/scintilla/feature-requests/1320/">Feature #1320</a>.
</li>
diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx
index a58b01bc5..61ee917ab 100644
--- a/lexers/LexHTML.cxx
+++ b/lexers/LexHTML.cxx
@@ -267,6 +267,18 @@ void classifyAttribHTML(Sci_PositionU start, Sci_PositionU end, const WordList &
styler.ColourTo(end, chAttr);
}
+// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts
+bool isHTMLCustomElement(const std::string &tag) {
+ // check valid HTML custom element name: starts with an ASCII lower alpha and contains hyphen.
+ if (tag.length() < 2 || !IsLowerCase(tag[0])) {
+ return false;
+ }
+ if (tag.find('-') == std::string::npos) {
+ return false;
+ }
+ return true;
+}
+
int classifyTagHTML(Sci_PositionU start, Sci_PositionU end,
const WordList &keywords, Accessor &styler, bool &tagDontFold,
bool caseSensitive, bool isXml, bool allowScripts,
@@ -289,6 +301,8 @@ int classifyTagHTML(Sci_PositionU start, Sci_PositionU end,
chAttr = SCE_H_SGML_DEFAULT;
} else if (!keywords || keywords.InList(tag.c_str())) {
chAttr = SCE_H_TAG;
+ } else if (!isXml && isHTMLCustomElement(tag)) {
+ chAttr = SCE_H_TAG;
}
if (chAttr != SCE_H_TAGUNKNOWN) {
styler.ColourTo(end, chAttr);