Skip to content

Commit

Permalink
FEAT(client,markdown): Support multiple code-blocks per message
Browse files Browse the repository at this point in the history
The way code-blocks are handled was here changed to support multiple code-blocks per message.

This allows content that is not formatted as code between code-blocks, whereas previously everything between the first start of a code-block and the last end of a code-block would become part of one code-block. The only other change is to only end a code-block on the end-signature when it is right after a new line, so triple backticks may also be included as long as they are not at the start of a line.

For explanation on how the regex functions, see [perl - Regex to match any character including new lines](https://stackoverflow.com/a/8303507)
  • Loading branch information
GeneralUser01 authored Nov 26, 2024
1 parent 9c48561 commit 28f4ec3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mumble/Markdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ bool processMarkdownInlineCode(QString &str, qsizetype &offset) {
bool processMarkdownCodeBlock(QString &str, qsizetype &offset) {
// Code blocks are marked as ```code```
// Also consume a potential following newline as the <pre> tag will cause a linebreak anyways
static const QRegularExpression s_regex(QLatin1String("```.*\\n((?:[^`]|``?[^`]?)*)```(\\r\\n|\\n|\\r)?"));
static const QRegularExpression s_regex(QLatin1String("```.*\\n((.|\\n)+?)\\n```(\\r\\n|\\n|\\r)?"));

const QRegularExpressionMatch match = regexMatch(s_regex, str, offset);
if (match.hasMatch()) {
Expand Down

0 comments on commit 28f4ec3

Please sign in to comment.