mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Correctly highlight comments in latexHighlighter
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17574 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ae6c7d2c51
commit
7c0bb562cb
@ -32,17 +32,9 @@ latexHighlighter::latexHighlighter(QTextDocument * parent) :
|
||||
|
||||
void latexHighlighter::highlightBlock(QString const & text)
|
||||
{
|
||||
// comment
|
||||
QRegExp exprComment("^%.*$");
|
||||
int index = text.indexOf(exprComment);
|
||||
while (index >= 0) {
|
||||
int length = exprComment.matchedLength();
|
||||
setFormat(index, length, commentFormat);
|
||||
index = text.indexOf(exprComment, index + length);
|
||||
}
|
||||
// $ $
|
||||
QRegExp exprMath("\\$[^\\$]*\\$");
|
||||
index = text.indexOf(exprMath);
|
||||
int index = text.indexOf(exprMath);
|
||||
while (index >= 0) {
|
||||
int length = exprMath.matchedLength();
|
||||
setFormat(index, length, mathFormat);
|
||||
@ -95,6 +87,14 @@ void latexHighlighter::highlightBlock(QString const & text)
|
||||
setFormat(index, length, keywordFormat);
|
||||
index = text.indexOf(exprKeyword, index + length);
|
||||
}
|
||||
// comment
|
||||
QRegExp exprComment("(^|[^\\\\])%.*$");
|
||||
index = text.indexOf(exprComment);
|
||||
while (index >= 0) {
|
||||
int length = exprComment.matchedLength();
|
||||
setFormat(index, length, commentFormat);
|
||||
index = text.indexOf(exprComment, index + length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user