try to extract description via HTML parsing using new Qt6 documentation format
| 193 | |
| 194 | /// try to extract description via HTML parsing using new Qt6 documentation format |
| 195 | QString descriptionFromNewHtmlData(const QString& fragment, const QString& data) |
| 196 | { |
| 197 | if (fragment.isEmpty()) { |
| 198 | return {}; |
| 199 | } |
| 200 | |
| 201 | // find the header that references the fragment |
| 202 | const auto sectionStartPattern = QRegularExpression(QLatin1String("<h(\\d)[^>]+id=\"%1\"").arg(fragment)); |
| 203 | const auto matchStart = sectionStartPattern.match(data); |
| 204 | if (!matchStart.hasMatch()) { |
| 205 | return {}; |
| 206 | } |
| 207 | |
| 208 | // find the start of the next section by the header |
| 209 | const auto headerType = matchStart.capturedView(1); |
| 210 | const auto sectionStart = matchStart.capturedStart(0); |
| 211 | const auto sectionEndPattern = QRegularExpression(QLatin1String("<h%1[^>]+id=\"").arg(headerType)); |
| 212 | const auto matchEnd = sectionEndPattern.match(data, matchStart.capturedEnd(0)); |
| 213 | const auto sectionEnd = matchEnd.hasMatch() ? matchEnd.capturedStart(0) : data.size(); |
| 214 | |
| 215 | // then cleanup the data inbetween these two places |
| 216 | return cleanupDescription(data.sliced(sectionStart, sectionEnd - sectionStart)); |
| 217 | } |
| 218 | |
| 219 | /// extract description via HTML parsing using the old Qt5-like documentation format |
| 220 | QString descriptionFromOldHtmlData(const QString& fragment, const QString& dataString) |
no test coverage detected