mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
export: remove <title> in embedded SVGs
Pandoc will take it as the title of the document by mistake.
This commit is contained in:
parent
f3302d25e8
commit
8f24d38bf8
@ -926,7 +926,7 @@ QString VWebUtils::copyResource(const QUrl &p_url, const QString &p_folder) cons
|
|||||||
return succ ? targetFile : QString();
|
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;
|
QString uri;
|
||||||
Q_ASSERT(!p_url.isRelative());
|
Q_ASSERT(!p_url.isRelative());
|
||||||
@ -956,6 +956,12 @@ QString VWebUtils::dataURI(const QUrl &p_url) const
|
|||||||
if (suffix == "svg") {
|
if (suffix == "svg") {
|
||||||
uri = QString("data:image/svg+xml;utf8,%1").arg(QString::fromUtf8(data));
|
uri = QString("data:image/svg+xml;utf8,%1").arg(QString::fromUtf8(data));
|
||||||
uri.replace('\r', "").replace('\n', "");
|
uri.replace('\r', "").replace('\n', "");
|
||||||
|
|
||||||
|
if (!p_keepTitle) {
|
||||||
|
// Remove <title>...</title>.
|
||||||
|
QRegExp reg("<title>.*</title>", Qt::CaseInsensitive);
|
||||||
|
uri.remove(reg);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uri = QString("data:image/%1;base64,%2").arg(suffix).arg(QString::fromUtf8(data.toBase64()));
|
uri = QString("data:image/%1;base64,%2").arg(suffix).arg(QString::fromUtf8(data.toBase64()));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
QString copyResource(const QUrl &p_url, const QString &p_folder) const;
|
QString copyResource(const QUrl &p_url, const QString &p_folder) const;
|
||||||
|
|
||||||
// Return a dataURI of @p_url if it is an image.
|
// 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:
|
private:
|
||||||
struct CopyTargetAction
|
struct CopyTargetAction
|
||||||
|
@ -625,7 +625,7 @@ bool VExporter::embedStyleResources(QString &p_html)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString dataURI = g_webUtils->dataURI(QUrl(reg.cap(1)));
|
QString dataURI = g_webUtils->dataURI(QUrl(reg.cap(1)), false);
|
||||||
if (dataURI.isEmpty()) {
|
if (dataURI.isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + reg.matchedLength();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user