mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
export: add icon, title and footer to exported HTML
This commit is contained in:
parent
c0af5aeb71
commit
4cced65863
@ -5,6 +5,21 @@ div.mark-rect {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#vnote-footer {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
opacity: 0.2;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
#vnote-footer p {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
#vnote-footer a {
|
||||
color: inherit !important;
|
||||
}
|
||||
|
||||
/* Mathjax */
|
||||
x-eqs {
|
||||
display: flex;
|
||||
@ -15,7 +30,7 @@ x-eqs {
|
||||
|
||||
x-eqs > x-eqn {
|
||||
width: 100%;
|
||||
margin-left: 3em;
|
||||
margin-left: 3rem;
|
||||
}
|
||||
|
||||
x-eqs > span {
|
||||
@ -87,3 +102,29 @@ span.modal-close:focus {
|
||||
cursor: pointer;
|
||||
}
|
||||
/* View Image */
|
||||
|
||||
/* Print */
|
||||
@media print {
|
||||
pre, pre code, td.hljs-ln-code {
|
||||
white-space: pre-wrap !important;
|
||||
word-break: break-all !important;
|
||||
}
|
||||
|
||||
code, a {
|
||||
word-break: break-all !important;
|
||||
}
|
||||
|
||||
div.flowchart-diagram, div.mermaid-diagram, div.plantuml-diagram {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
#vnote-footer {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
/* Print*/
|
||||
|
@ -1,7 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="generator" content="VNote">
|
||||
|
||||
<!-- HEAD_TITLE_PLACE_HOLDER -->
|
||||
<link rel="icon" href="https://github.com/tamlok/vnote/raw/master/src/resources/icons/vnote.ico">
|
||||
|
||||
<style type="text/css">
|
||||
/* STYLE_GLOBAL_PLACE_HOLDER */
|
||||
</style>
|
||||
@ -32,5 +37,9 @@
|
||||
<p id="floating-more" class="more">></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer" id="vnote-footer">
|
||||
<p>Generated by <em><a href="https://tamlok.github.io/vnote/">VNote</a></em>.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -197,3 +197,9 @@
|
||||
.outline-bold {
|
||||
font-weight: bolder !important;
|
||||
}
|
||||
|
||||
@media print {
|
||||
#floating-button {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<style type="text/css">
|
||||
/* STYLE_GLOBAL_PLACE_HOLDER */
|
||||
</style>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<style type="text/css">
|
||||
/* STYLE_GLOBAL_PLACE_HOLDER */
|
||||
</style>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="CSS_PLACE_HOLDER">
|
||||
<link rel="stylesheet" type="text/css" href="qrc:/resources/typewriter.css">
|
||||
</head>
|
||||
|
@ -1846,3 +1846,9 @@ QString VUtils::purifyImageTitle(QString p_title)
|
||||
{
|
||||
return p_title.remove(QRegExp("[\\r\\n\\[\\]]"));
|
||||
}
|
||||
|
||||
QString VUtils::escapeHtml(QString p_text)
|
||||
{
|
||||
p_text.replace(">", ">").replace("<", "<").replace("&", "&");
|
||||
return p_text;
|
||||
}
|
||||
|
@ -392,6 +392,8 @@ public:
|
||||
|
||||
static QString purifyImageTitle(QString p_title);
|
||||
|
||||
static QString escapeHtml(QString p_text);
|
||||
|
||||
// Regular expression for image link.
|
||||
// 
|
||||
// Captured texts (need to be trimmed):
|
||||
|
@ -51,6 +51,7 @@ namespace HtmlHolder
|
||||
static const QString c_headHolder = "<!-- HEAD_PLACE_HOLDER -->";
|
||||
static const QString c_styleHolder = "/* STYLE_PLACE_HOLDER */";
|
||||
static const QString c_outlineStyleHolder = "/* STYLE_OUTLINE_PLACE_HOLDER */";
|
||||
static const QString c_headTitleHolder = "<!-- HEAD_TITLE_PLACE_HOLDER -->";
|
||||
}
|
||||
|
||||
// Directory Config file items.
|
||||
|
@ -132,6 +132,11 @@ void VDocument::setFile(const VFile *p_file)
|
||||
m_file = p_file;
|
||||
}
|
||||
|
||||
const VFile *VDocument::getFile() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
||||
void VDocument::finishLogics()
|
||||
{
|
||||
qDebug() << "Web side finished logics" << this;
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
|
||||
void setFile(const VFile *p_file);
|
||||
|
||||
const VFile *getFile() const;
|
||||
|
||||
bool isReadyToHighlight() const;
|
||||
|
||||
bool isReadyToTextToHtml() const;
|
||||
|
@ -336,7 +336,10 @@ bool VExporter::exportToPDFViaWK(VDocument *p_webDocument,
|
||||
}
|
||||
|
||||
QString htmlPath = tmpDir.filePath("vnote_tmp.html");
|
||||
QString title = p_webDocument->getFile()->getName();
|
||||
title = QFileInfo(title).completeBaseName();
|
||||
if (!outputToHTMLFile(htmlPath,
|
||||
title,
|
||||
p_headContent,
|
||||
p_styleContent,
|
||||
p_bodyContent,
|
||||
@ -396,7 +399,10 @@ bool VExporter::exportToCustom(VDocument *p_webDocument,
|
||||
}
|
||||
|
||||
QString htmlPath = tmpDir.filePath("vnote_tmp.html");
|
||||
QString title = p_webDocument->getFile()->getName();
|
||||
title = QFileInfo(title).completeBaseName();
|
||||
if (!outputToHTMLFile(htmlPath,
|
||||
title,
|
||||
p_headContent,
|
||||
p_styleContent,
|
||||
p_bodyContent,
|
||||
@ -563,7 +569,10 @@ bool VExporter::exportToHTML(VDocument *p_webDocument,
|
||||
|
||||
Q_ASSERT(!p_filePath.isEmpty());
|
||||
|
||||
QString title = p_webDocument->getFile()->getName();
|
||||
title = QFileInfo(title).completeBaseName();
|
||||
if (!outputToHTMLFile(p_filePath,
|
||||
title,
|
||||
p_headContent,
|
||||
p_styleContent,
|
||||
p_bodyContent,
|
||||
@ -971,6 +980,7 @@ int VExporter::startProcess(const QString &p_cmd)
|
||||
}
|
||||
|
||||
bool VExporter::outputToHTMLFile(const QString &p_file,
|
||||
const QString &p_title,
|
||||
const QString &p_headContent,
|
||||
const QString &p_styleContent,
|
||||
const QString &p_bodyContent,
|
||||
@ -989,6 +999,11 @@ bool VExporter::outputToHTMLFile(const QString &p_file,
|
||||
qDebug() << "HTML files folder" << resFolderPath;
|
||||
|
||||
QString html(m_exportHtmlTemplate);
|
||||
if (!p_title.isEmpty()) {
|
||||
html.replace(HtmlHolder::c_headTitleHolder,
|
||||
"<title>" + VUtils::escapeHtml(p_title) + "</title>");
|
||||
}
|
||||
|
||||
if (!p_styleContent.isEmpty() && p_embedCssStyle) {
|
||||
QString content(p_styleContent);
|
||||
embedStyleResources(content);
|
||||
|
@ -135,6 +135,7 @@ private:
|
||||
|
||||
// @p_embedImages: embed <img> as data URI.
|
||||
bool outputToHTMLFile(const QString &p_file,
|
||||
const QString &p_title,
|
||||
const QString &p_headContent,
|
||||
const QString &p_styleContent,
|
||||
const QString &p_bodyContent,
|
||||
|
Loading…
x
Reference in New Issue
Block a user