namespace frontend {
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent)
- : QSyntaxHighlighter(parent)
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter)
+ : QSyntaxHighlighter(parent), at_letter_(at_letter)
{
auto blend = [](QColor color1, QColor color2) {
int r = 0.5 * (color1.red() + color2.red());
startIndex = exprStartDispMath.indexIn(text, startIndex + length);
}
// \whatever
- static const QRegExp exprKeyword("\\\\[A-Za-z]+");
+ static const QRegExp exprKeywordAtOther("\\\\[A-Za-z]+");
+ // \wh@tever
+ static const QRegExp exprKeywordAtLetter("\\\\[A-Za-z@]+");
+ QRegExp const & exprKeyword = at_letter_ ? exprKeywordAtLetter
+ : exprKeywordAtOther;
index = exprKeyword.indexIn(text);
while (index >= 0) {
int length = exprKeyword.matchedLength();
// %comment
// Treat a line as a comment starting at a percent sign
// * that is the first character in a line
- // * that is preceded by
+ // * that is preceded by
// ** an even number of backslashes
// ** any character other than a backslash
- QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
+ QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
exprComment.indexIn(text);
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);
exprComment.indexIn(text, index + length);