| 142 | } |
| 143 | |
| 144 | void processLine(QString& line) |
| 145 | { |
| 146 | static const QRegularExpression ttRE(QStringLiteral("`([^`]+)`")); |
| 147 | static const QRegularExpression bdRE(QStringLiteral("\\*\\*([^\\*]+)\\*\\*")); |
| 148 | static const QRegularExpression itRE(QStringLiteral("[^\\*]\\*([^\\*]+)\\*[^\\*]")); |
| 149 | |
| 150 | static auto applyRE = [](const QRegularExpression& re, QString& line, const QString& tag) { |
| 151 | auto i = re.globalMatch(line); |
| 152 | while (i.hasNext()) { |
| 153 | auto match = i.next(); |
| 154 | line.replace(match.captured(0), QStringLiteral("<%1>%2</%1>").arg(tag, match.captured(1))); |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | if (state != PREFORMATTED) { |
| 159 | line.replace(QLatin1Char('&'), QLatin1String("&")); |
| 160 | line.replace(QLatin1Char('<'), QLatin1String("<")); |
| 161 | line.replace(QLatin1Char('>'), QLatin1String(">")); |
| 162 | |
| 163 | line.replace(QLatin1Char('\"'), QLatin1String(""")); |
| 164 | line.replace(QLatin1Char('\''), QLatin1String("'")); |
| 165 | |
| 166 | applyRE(ttRE, line, QStringLiteral("tt")); |
| 167 | applyRE(bdRE, line, QStringLiteral("b")); |
| 168 | applyRE(itRE, line, QStringLiteral("i")); |
| 169 | } |
| 170 | |
| 171 | html += line; |
| 172 | } |
| 173 | |
| 174 | private: |
| 175 | int state; |