From 8f24d38bf8bc3715de6e80374a1a5169a2b40a4e Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 14 May 2018 20:41:44 +0800 Subject: [PATCH] export: remove in embedded SVGs Pandoc will take it as the title of the document by mistake. --- src/utils/vwebutils.cpp | 8 +++++++- src/utils/vwebutils.h | 2 +- src/vexporter.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/vwebutils.cpp b/src/utils/vwebutils.cpp index fdb9af63..17a4c00f 100644 --- a/src/utils/vwebutils.cpp +++ b/src/utils/vwebutils.cpp @@ -926,7 +926,7 @@ QString VWebUtils::copyResource(const QUrl &p_url, const QString &p_folder) cons return succ ? targetFile : QString(); } -QString VWebUtils::dataURI(const QUrl &p_url) const +QString VWebUtils::dataURI(const QUrl &p_url, bool p_keepTitle) const { QString uri; Q_ASSERT(!p_url.isRelative()); @@ -956,6 +956,12 @@ QString VWebUtils::dataURI(const QUrl &p_url) const if (suffix == "svg") { uri = QString("data:image/svg+xml;utf8,%1").arg(QString::fromUtf8(data)); uri.replace('\r', "").replace('\n', ""); + + if (!p_keepTitle) { + // Remove <title>.... + QRegExp reg(".*", Qt::CaseInsensitive); + uri.remove(reg); + } } else { uri = QString("data:image/%1;base64,%2").arg(suffix).arg(QString::fromUtf8(data.toBase64())); } diff --git a/src/utils/vwebutils.h b/src/utils/vwebutils.h index f488b43b..4d446951 100644 --- a/src/utils/vwebutils.h +++ b/src/utils/vwebutils.h @@ -26,7 +26,7 @@ public: QString copyResource(const QUrl &p_url, const QString &p_folder) const; // Return a dataURI of @p_url if it is an image. - QString dataURI(const QUrl &p_url) const; + QString dataURI(const QUrl &p_url, bool p_keepTitle = true) const; private: struct CopyTargetAction diff --git a/src/vexporter.cpp b/src/vexporter.cpp index 57864bb2..b059eae1 100644 --- a/src/vexporter.cpp +++ b/src/vexporter.cpp @@ -625,7 +625,7 @@ bool VExporter::embedStyleResources(QString &p_html) break; } - QString dataURI = g_webUtils->dataURI(QUrl(reg.cap(1))); + QString dataURI = g_webUtils->dataURI(QUrl(reg.cap(1)), false); if (dataURI.isEmpty()) { pos = idx + reg.matchedLength(); } else {