fix(StatusSyntaxHighlighter): Updated regex and text formatting

Closes https://github.com/status-im/status-desktop/issues/6030
This commit is contained in:
Alexandra Betouni 2022-06-10 18:50:49 +03:00 committed by Michał
parent e666ccf1ad
commit 63b6e8c885
1 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,7 @@
#include "DOtherSide/DOtherSideStatusSyntaxHighlighter.h"
#include <QQuickTextDocument>
#include <Qt>
#include <QBrush>
StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent)
@ -8,20 +10,21 @@ StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument *parent)
//BOLD
singlelineBoldFormat.setFontWeight(QFont::Bold);
rule.pattern = QRegularExpression(QStringLiteral("\\*\\*(.*?)\\*\\*"));
rule.pattern = QRegularExpression(QStringLiteral("(\\*\\*(.*?)\\*\\*)|(\\_\\_(.*?)\\_\\_)"));
rule.format = singlelineBoldFormat;
highlightingRules.append(rule);
//BOLD
//ITALIC
singleLineItalicFormat.setFontItalic(true);
rule.pattern = QRegularExpression(QStringLiteral("\\*(.*?)\\*"));
rule.pattern = QRegularExpression(QStringLiteral("(\\*(.*?)\\*)|(\\_(.*?)\\_)"));
rule.format = singleLineItalicFormat;
highlightingRules.append(rule);
//ITALIC
//CODE
singlelineCodeBlockFormat.setFontFamily("Roboto Mono");
singlelineCodeBlockFormat.setBackground(QBrush(Qt::lightGray));
rule.pattern = QRegularExpression(QStringLiteral("\\`(.*?)\\`"));
rule.format = singlelineCodeBlockFormat;
highlightingRules.append(rule);
@ -29,13 +32,14 @@ StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument *parent)
//STRIKETHROUGH
singleLineStrikeThroughFormat.setFontStrikeOut(true);
rule.pattern = QRegularExpression(QStringLiteral("\\~+(.*?)\\~+"));
rule.pattern = QRegularExpression(QStringLiteral("\\~\\~(.*?)\\~\\~"));
rule.format = singleLineStrikeThroughFormat;
highlightingRules.append(rule);
//STRIKETHROUGH
//CODE BLOCK
multiLineCodeBlockFormat.setFontFamily("Roboto Mono");
multiLineCodeBlockFormat.setBackground(QBrush(Qt::lightGray));
rule.pattern = QRegularExpression(QStringLiteral("\\`\\`\\`(.*?)\\`\\`\\`"));
rule.format = multiLineCodeBlockFormat;
highlightingRules.append(rule);