diff options
| author | Zufu Liu <unknown> | 2019-11-02 10:19:22 +1100 |
|---|---|---|
| committer | Zufu Liu <unknown> | 2019-11-02 10:19:22 +1100 |
| commit | 03782fcb79245045d198632700aa54b4ded2b640 (patch) | |
| tree | 0d23dd6a5b21d30b190b336408a50d8fcaa31148 /lexers/LexHTML.cxx | |
| parent | 66d8e35d535f4d443e1b14d7ebfd812fef797818 (diff) | |
| download | scintilla-mirror-03782fcb79245045d198632700aa54b4ded2b640.tar.gz | |
Backport: Feature [feature-requests:#1299] Treat custom tags from HTML5 as known tags.
These contain "-" like "custom-tag".
Backport fo changeset 7757:66cf17769808.
Diffstat (limited to 'lexers/LexHTML.cxx')
| -rw-r--r-- | lexers/LexHTML.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
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); |
