// HTMLParse.cpp : Defines the entry point for the application.
//
#include
#include
using namespace std::string_literals;
#include
#include
auto withoutIDs = "\n\
\n\
Header
\n\
\n\
- For a limited time Item 1 is on sale for $10
\n\
- For a limited time Item 2 is on sale for $20
\n\
\n\
\n\
"s;
auto withIDs = "\n\
\n\
\n\
\n\
- For a limited time Item 1 is on sale for $10
\n\
- For a limited time Item 2 is on sale for $20
\n\
\n\
\n\
"s;
void dumpDocument(const std::string& text) {
std::cout << text << std::endl;
QTextDocument document;
document.setHtml(QString(text.c_str()));
for (auto itBlock = document.begin(); itBlock != document.end(); itBlock = itBlock.next()) {
std::cout << "Block: " << itBlock.text().toStdString() << std::endl;
for (auto itFragment = itBlock.begin(); !itFragment.atEnd(); ++itFragment) {
auto charFormat = itFragment.fragment().charFormat();
std::cout << "Fragment: \"" << itFragment.fragment().text().toStdString() << "\", fontWeight=" << charFormat.fontWeight() << ", isAnchor=" << std::boolalpha << charFormat.isAnchor() << std::endl;
}
}
}
int main()
{
std::cout << "Qt version: " << QT_VERSION_STR << std::endl;
std::cout << "Without IDs" << std::endl;
dumpDocument(withoutIDs);
std::cout << std::endl;
std::cout << "With IDS" << std::endl;
dumpDocument(withIDs);
return 0;
}