Commit e46e95c9 authored by Volker Krause's avatar Volker Krause
Browse files

Port structured data extractor to the new API

The old StructuredDataExtractor class is going away, but we get to the
same functionality via the new engine/node API.
parent 0d2e0bf1
......@@ -4,8 +4,10 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "generic/structureddataextractor_p.h"
#include <KItinerary/HtmlDocument>
#include <KItinerary/ExtractorDocumentNode>
#include <KItinerary/ExtractorDocumentProcessor>
#include <KItinerary/ExtractorEngine>
#include <KItinerary/ExtractorResult>
#include <QDebug>
#include <QDir>
......@@ -45,15 +47,18 @@ private Q_SLOTS:
QFile f(inputFile);
QVERIFY(f.open(QFile::ReadOnly));
std::unique_ptr<HtmlDocument> htmlDoc(HtmlDocument::fromData(f.readAll()));
QVERIFY(htmlDoc);
ExtractorEngine engine;
engine.setData(f.readAll());
auto node = engine.rootDocumentNode();
node.processor()->preExtract(node, &engine);
QFile ref(jsonFile);
QVERIFY(ref.open(QFile::ReadOnly));
const auto doc = QJsonDocument::fromJson(ref.readAll());
QVERIFY(doc.isArray());
auto data = StructuredDataExtractor::extract(htmlDoc.get());
auto data = node.result().jsonLdResult();
if (data != doc.array()) {
qDebug().noquote() << QJsonDocument(data).toJson();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment