From f248b6faff0c9fa5eab7bafcc6e2595e2de07071 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Wed, 5 Dec 2007 20:59:11 +0000 Subject: [PATCH] Source highlighting of comments (by Bernhard Reiter) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@21973 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QViewSource.cpp | 18 +++++++++++++----- status.15x | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/frontends/qt4/QViewSource.cpp b/src/frontends/qt4/QViewSource.cpp index 6c866764cb..32b17103ec 100644 --- a/src/frontends/qt4/QViewSource.cpp +++ b/src/frontends/qt4/QViewSource.cpp @@ -139,13 +139,21 @@ void LaTeXHighlighter::highlightBlock(QString const & text) setFormat(index, length, keywordFormat); index = text.indexOf(exprKeyword, index + length); } - // comment - QRegExp exprComment("(^|[^\\\\])%.*$"); - index = text.indexOf(exprComment); + // %comment + // Treat a line as a comment starting at a percent sign + // * that is the first character in a line + // * that is preceded by + // ** an even number of backslashes + // ** any character other than a backslash + QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$"); + text.indexOf(exprComment); + index = exprComment.pos(1); while (index >= 0) { - int const length = exprComment.matchedLength(); + int const length = exprComment.matchedLength() + - (index - exprComment.pos(0)); setFormat(index, length, commentFormat); - index = text.indexOf(exprComment, index + length); + text.indexOf(exprComment, index + length); + index = exprComment.pos(1); } } diff --git a/status.15x b/status.15x index 1ea948e7c1..a4607e9c70 100644 --- a/status.15x +++ b/status.15x @@ -206,6 +206,8 @@ What's new - Distinguish translations for 'Note' between layouts and inset. +- Fix latex source highlighting of comments + * DOCUMENTATION - Fix corrupted character in the User's Guide (including the translations).