Skip to content

Commit

Permalink
#2791 navigation-panel: optimize regular expression usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jun 17, 2023
1 parent ed1abfd commit 8a9fded
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/widgets/navigationwidget.cpp
Expand Up @@ -124,12 +124,12 @@ int NavigationWidget::findItemIndexForCursorPosition(int position) const {
QString NavigationWidget::stripMarkdown(const QString& input)
{
// Regular expressions for different Markdown syntax patterns
static QRegularExpression boldRegex(R"(\*{2}([^*]+)\*{2})"); // **bold**
static QRegularExpression italicRegex(R"(\*{1}([^*]+)\*{1})"); // *italic*
static QRegularExpression strikethroughRegex(R"(\~{2}([^~]+)\~{2})"); // ~~strikethrough~~
static QRegularExpression linkRegex(R"(\[([^]]+)\]\(([^)]+)\))"); // [link](url)
static QRegularExpression angleBracketLinkRegex(R"(<([^>]+)>)"); // <http://link>
static QRegularExpression codeRegex(R"(`([^`]+)`+)"); // `code`
static const QRegularExpression boldRegex(R"(\*{2}([^*]+)\*{2})"); // **bold**
static const QRegularExpression italicRegex(R"(\*{1}([^*]+)\*{1})"); // *italic*
static const QRegularExpression strikethroughRegex(R"(\~{2}([^~]+)\~{2})"); // ~~strikethrough~~
static const QRegularExpression linkRegex(R"(\[([^]]+)\]\(([^)]+)\))"); // [link](url)
static const QRegularExpression angleBracketLinkRegex(R"(<([^>]+)>)"); // <http://link>
static const QRegularExpression codeRegex(R"(`([^`]+)`+)"); // `code`

// Replace each Markdown pattern with an empty string
QString strippedText = input;
Expand Down

0 comments on commit 8a9fded

Please sign in to comment.