aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexHTML.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'lexers/LexHTML.cxx')
-rw-r--r--lexers/LexHTML.cxx27
1 files changed, 24 insertions, 3 deletions
diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx
index 96462235f..9d9ec9bb1 100644
--- a/lexers/LexHTML.cxx
+++ b/lexers/LexHTML.cxx
@@ -562,6 +562,7 @@ struct OptionsHTML {
bool foldCompact = true;
bool foldComment = false;
bool foldHeredoc = false;
+ bool foldXmlAtTagOpen = false;
OptionsHTML() noexcept {
}
};
@@ -626,6 +627,10 @@ struct OptionSetHTML : public OptionSet<OptionsHTML> {
"Allow folding for heredocs in scripts embedded in HTML. "
"The default is off.");
+ DefineProperty("fold.xml.at.tag.open", &OptionsHTML::foldXmlAtTagOpen,
+ "Enable folding for XML at the start of open tag. "
+ "The default is off.");
+
DefineWordListSets(isPHPScript_ ? phpscriptWordListDesc : htmlWordListDesc);
}
};
@@ -991,6 +996,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
const bool foldCompact = options.foldCompact;
const bool foldComment = fold && options.foldComment;
const bool foldHeredoc = fold && options.foldHeredoc;
+ const bool foldXmlAtTagOpen = isXml && fold && options.foldXmlAtTagOpen;
const bool caseSensitive = options.caseSensitive;
const bool allowScripts = options.allowScripts;
const bool isMako = options.isMako;
@@ -1206,6 +1212,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
i += 2;
visibleChars += 2;
tagClosing = true;
+ if (foldXmlAtTagOpen) {
+ levelCurrent--;
+ }
continue;
}
}
@@ -1531,6 +1540,12 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
// in HTML, fold on tag open and unfold on tag close
tagOpened = true;
tagClosing = (chNext == '/');
+ if (foldXmlAtTagOpen && !(chNext == '/' || chNext == '?' || chNext == '!' || chNext == '-' || chNext == '%')) {
+ levelCurrent++;
+ }
+ if (foldXmlAtTagOpen && chNext == '/') {
+ levelCurrent--;
+ }
styler.ColourTo(i - 1, StateToPrint);
if (chNext != '!')
state = SCE_H_TAGUNKNOWN;
@@ -1727,7 +1742,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
state = SCE_H_DEFAULT;
}
tagOpened = false;
- if (!tagDontFold) {
+ if (!(foldXmlAtTagOpen || tagDontFold)) {
if (tagClosing) {
levelCurrent--;
} else {
@@ -1746,6 +1761,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
ch = chNext;
state = SCE_H_DEFAULT;
tagOpened = false;
+ if (foldXmlAtTagOpen) {
+ levelCurrent--;
+ }
} else {
if (eClass != SCE_H_TAGUNKNOWN) {
if (eClass == SCE_H_SGML_DEFAULT) {
@@ -1775,7 +1793,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
state = SCE_H_DEFAULT;
}
tagOpened = false;
- if (!tagDontFold) {
+ if (!(foldXmlAtTagOpen || tagDontFold)) {
if (tagClosing) {
levelCurrent--;
} else {
@@ -1801,7 +1819,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
state = SCE_H_DEFAULT;
}
tagOpened = false;
- if (!tagDontFold) {
+ if (!(foldXmlAtTagOpen || tagDontFold)) {
if (tagClosing) {
levelCurrent--;
} else {
@@ -1825,6 +1843,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int
ch = chNext;
state = SCE_H_DEFAULT;
tagOpened = false;
+ if (foldXmlAtTagOpen) {
+ levelCurrent--;
+ }
} else if (ch == '?' && chNext == '>') {
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i + 1, SCE_H_XMLEND);