2 #include <QXMLHighlighter>
3 #include <QSyntaxStyle>
8 m_xmlKeywordRegexes (),
9 m_xmlElementRegex (R
"(<[\s]*[/]?[\s]*([^\n][a-zA-Z-_:]*)(?=[\s/>]))"),
10 m_xmlAttributeRegex (R"(\w+(?=\=))"),
11 m_xmlValueRegex (R"("[^\n"]+"(?=\??[\s/>]))"),
12 m_xmlCommentBeginRegex(R"(<!--)"),
13 m_xmlCommentEndRegex (R"(-->)")
16 << QRegularExpression("<\\?")
17 << QRegularExpression(
"/>")
18 << QRegularExpression(
">")
19 << QRegularExpression(
"<")
20 << QRegularExpression(
"</")
21 << QRegularExpression(
"\\?>");
28 while (matchIterator.hasNext())
30 auto match = matchIterator.next();
33 match.capturedStart(),
34 match.capturedLength(),
56 setCurrentBlockState(0);
59 if (previousBlockState() != 1)
64 while (startIndex >= 0)
68 int endIndex = match.capturedStart();
69 int commentLength = 0;
73 setCurrentBlockState(1);
74 commentLength = text.length() - startIndex;
78 commentLength = endIndex - startIndex + match.capturedLength();
99 auto matchIterator = regex.globalMatch(text);
101 while (matchIterator.hasNext())
103 auto match = matchIterator.next();
106 match.capturedStart(),
107 match.capturedLength(),