mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
LaTeXHighlighter: handle grouped values with commas in keyval options
This commit is contained in:
parent
9e308ddb03
commit
eadc8ab147
@ -50,6 +50,7 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
|
|||||||
if (keyval_) {
|
if (keyval_) {
|
||||||
// Highlight key-val options. Used in some option widgets.
|
// Highlight key-val options. Used in some option widgets.
|
||||||
static QRegularExpression exprKeyvalkey("[^=,]+");
|
static QRegularExpression exprKeyvalkey("[^=,]+");
|
||||||
|
static QRegularExpression exprKeyvalgval("[^,]+{[^}]+}");
|
||||||
static QRegularExpression exprKeyvalval("[^,]+");
|
static QRegularExpression exprKeyvalval("[^,]+");
|
||||||
if (optsnippet_) {
|
if (optsnippet_) {
|
||||||
static QRegularExpression exprKeyvalkey("^=,+");
|
static QRegularExpression exprKeyvalkey("^=,+");
|
||||||
@ -61,15 +62,24 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
|
|||||||
int length = matchkey.capturedLength(0);
|
int length = matchkey.capturedLength(0);
|
||||||
setFormat(kvindex, length, keyFormat);
|
setFormat(kvindex, length, keyFormat);
|
||||||
if (text.size() > kvindex + length && text.at(kvindex + length) == '=') {
|
if (text.size() > kvindex + length && text.at(kvindex + length) == '=') {
|
||||||
|
QRegularExpressionMatch matchgval =
|
||||||
|
exprKeyvalgval.match(text, kvindex + length);
|
||||||
|
int kvvindex = matchgval.capturedStart(0);
|
||||||
|
if (kvvindex > 0) {
|
||||||
|
int vlength = matchgval.capturedLength(0);
|
||||||
|
length += vlength;
|
||||||
|
setFormat(kvvindex, vlength, valFormat);
|
||||||
|
} else {
|
||||||
QRegularExpressionMatch matchval =
|
QRegularExpressionMatch matchval =
|
||||||
exprKeyvalval.match(text, kvindex + length);
|
exprKeyvalval.match(text, kvindex + length);
|
||||||
int kvvindex = matchval.capturedStart(0);
|
kvvindex = matchval.capturedStart(0);
|
||||||
if (kvvindex > 0) {
|
if (kvvindex > 0) {
|
||||||
int vlength = matchval.capturedLength(0);
|
int vlength = matchval.capturedLength(0);
|
||||||
length += vlength;
|
length += vlength;
|
||||||
setFormat(kvvindex, vlength, valFormat);
|
setFormat(kvvindex, vlength, valFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
matchkey = exprKeyvalkey.match(text, kvindex + length);
|
matchkey = exprKeyvalkey.match(text, kvindex + length);
|
||||||
kvindex = matchkey.capturedStart(0);
|
kvindex = matchkey.capturedStart(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user