Due to the use of multiple DLabels to display text in this module, the ordered list is always parsed starting from 1. To avoid this issue, we have implemented some circumvention measures. */
| 41 | To avoid this issue, we have implemented some circumvention measures. |
| 42 | */ |
| 43 | QString convertOlToParagraph(const QString &input) |
| 44 | { |
| 45 | QString result = input; |
| 46 | |
| 47 | static QRegularExpression olRegex( |
| 48 | R"(<ol(?:\s+start="(\d+)\")?\s*>\s*<li>(.*?)</li>\s*</ol>)", |
| 49 | QRegularExpression::DotMatchesEverythingOption |
| 50 | ); |
| 51 | |
| 52 | QRegularExpressionMatch match = olRegex.match(input); |
| 53 | if (match.hasMatch()) { |
| 54 | QString startNum = match.captured(1); |
| 55 | QString content = match.captured(2); |
| 56 | |
| 57 | QString replacement; |
| 58 | if (startNum.isEmpty()) { |
| 59 | replacement = QString("<p>1. %1</p>").arg(content); |
| 60 | } else { |
| 61 | replacement = QString("<p>%1. %2</p>").arg(startNum).arg(content); |
| 62 | } |
| 63 | |
| 64 | result = result.replace(match.captured(0), replacement); |
| 65 | } |
| 66 | |
| 67 | return result; |
| 68 | } |
| 69 | |
| 70 | void MessageComponent::updateMessage(const MessageData &msgData) |
| 71 | { |
no test coverage detected