export: add icon, title and footer to exported HTML

This commit is contained in:
Le Tan 2018-10-17 20:02:10 +08:00
parent c0af5aeb71
commit 4cced65863
13 changed files with 96 additions and 5 deletions

View File

@ -5,6 +5,21 @@ div.mark-rect {
position: absolute; 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 */ /* Mathjax */
x-eqs { x-eqs {
display: flex; display: flex;
@ -15,7 +30,7 @@ x-eqs {
x-eqs > x-eqn { x-eqs > x-eqn {
width: 100%; width: 100%;
margin-left: 3em; margin-left: 3rem;
} }
x-eqs > span { x-eqs > span {
@ -87,3 +102,29 @@ span.modal-close:focus {
cursor: pointer; cursor: pointer;
} }
/* View Image */ /* 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*/

View File

@ -1,7 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<meta charset="utf-8">
<head> <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 type="text/css">
/* STYLE_GLOBAL_PLACE_HOLDER */ /* STYLE_GLOBAL_PLACE_HOLDER */
</style> </style>
@ -32,5 +37,9 @@
<p id="floating-more" class="more">&gt;</p> <p id="floating-more" class="more">&gt;</p>
</div> </div>
</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> </body>
</html> </html>

View File

@ -197,3 +197,9 @@
.outline-bold { .outline-bold {
font-weight: bolder !important; font-weight: bolder !important;
} }
@media print {
#floating-button {
display: none !important;
}
}

View File

@ -1,7 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<meta charset="utf-8">
<head> <head>
<meta charset="utf-8">
<style type="text/css"> <style type="text/css">
/* STYLE_GLOBAL_PLACE_HOLDER */ /* STYLE_GLOBAL_PLACE_HOLDER */
</style> </style>

View File

@ -1,7 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<meta charset="utf-8">
<head> <head>
<meta charset="utf-8">
<style type="text/css"> <style type="text/css">
/* STYLE_GLOBAL_PLACE_HOLDER */ /* STYLE_GLOBAL_PLACE_HOLDER */
</style> </style>

View File

@ -1,7 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<meta charset="utf-8">
<head> <head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="CSS_PLACE_HOLDER"> <link rel="stylesheet" type="text/css" href="CSS_PLACE_HOLDER">
<link rel="stylesheet" type="text/css" href="qrc:/resources/typewriter.css"> <link rel="stylesheet" type="text/css" href="qrc:/resources/typewriter.css">
</head> </head>

View File

@ -1846,3 +1846,9 @@ QString VUtils::purifyImageTitle(QString p_title)
{ {
return p_title.remove(QRegExp("[\\r\\n\\[\\]]")); return p_title.remove(QRegExp("[\\r\\n\\[\\]]"));
} }
QString VUtils::escapeHtml(QString p_text)
{
p_text.replace(">", "&gt;").replace("<", "&lt;").replace("&", "&amp;");
return p_text;
}

View File

@ -392,6 +392,8 @@ public:
static QString purifyImageTitle(QString p_title); static QString purifyImageTitle(QString p_title);
static QString escapeHtml(QString p_text);
// Regular expression for image link. // Regular expression for image link.
// ![image title]( http://github.com/tamlok/vnote.jpg "alt text" =200x100) // ![image title]( http://github.com/tamlok/vnote.jpg "alt text" =200x100)
// Captured texts (need to be trimmed): // Captured texts (need to be trimmed):

View File

@ -51,6 +51,7 @@ namespace HtmlHolder
static const QString c_headHolder = "<!-- HEAD_PLACE_HOLDER -->"; static const QString c_headHolder = "<!-- HEAD_PLACE_HOLDER -->";
static const QString c_styleHolder = "/* STYLE_PLACE_HOLDER */"; static const QString c_styleHolder = "/* STYLE_PLACE_HOLDER */";
static const QString c_outlineStyleHolder = "/* STYLE_OUTLINE_PLACE_HOLDER */"; static const QString c_outlineStyleHolder = "/* STYLE_OUTLINE_PLACE_HOLDER */";
static const QString c_headTitleHolder = "<!-- HEAD_TITLE_PLACE_HOLDER -->";
} }
// Directory Config file items. // Directory Config file items.

View File

@ -132,6 +132,11 @@ void VDocument::setFile(const VFile *p_file)
m_file = p_file; m_file = p_file;
} }
const VFile *VDocument::getFile() const
{
return m_file;
}
void VDocument::finishLogics() void VDocument::finishLogics()
{ {
qDebug() << "Web side finished logics" << this; qDebug() << "Web side finished logics" << this;

View File

@ -48,6 +48,8 @@ public:
void setFile(const VFile *p_file); void setFile(const VFile *p_file);
const VFile *getFile() const;
bool isReadyToHighlight() const; bool isReadyToHighlight() const;
bool isReadyToTextToHtml() const; bool isReadyToTextToHtml() const;

View File

@ -336,7 +336,10 @@ bool VExporter::exportToPDFViaWK(VDocument *p_webDocument,
} }
QString htmlPath = tmpDir.filePath("vnote_tmp.html"); QString htmlPath = tmpDir.filePath("vnote_tmp.html");
QString title = p_webDocument->getFile()->getName();
title = QFileInfo(title).completeBaseName();
if (!outputToHTMLFile(htmlPath, if (!outputToHTMLFile(htmlPath,
title,
p_headContent, p_headContent,
p_styleContent, p_styleContent,
p_bodyContent, p_bodyContent,
@ -396,7 +399,10 @@ bool VExporter::exportToCustom(VDocument *p_webDocument,
} }
QString htmlPath = tmpDir.filePath("vnote_tmp.html"); QString htmlPath = tmpDir.filePath("vnote_tmp.html");
QString title = p_webDocument->getFile()->getName();
title = QFileInfo(title).completeBaseName();
if (!outputToHTMLFile(htmlPath, if (!outputToHTMLFile(htmlPath,
title,
p_headContent, p_headContent,
p_styleContent, p_styleContent,
p_bodyContent, p_bodyContent,
@ -563,7 +569,10 @@ bool VExporter::exportToHTML(VDocument *p_webDocument,
Q_ASSERT(!p_filePath.isEmpty()); Q_ASSERT(!p_filePath.isEmpty());
QString title = p_webDocument->getFile()->getName();
title = QFileInfo(title).completeBaseName();
if (!outputToHTMLFile(p_filePath, if (!outputToHTMLFile(p_filePath,
title,
p_headContent, p_headContent,
p_styleContent, p_styleContent,
p_bodyContent, p_bodyContent,
@ -971,6 +980,7 @@ int VExporter::startProcess(const QString &p_cmd)
} }
bool VExporter::outputToHTMLFile(const QString &p_file, bool VExporter::outputToHTMLFile(const QString &p_file,
const QString &p_title,
const QString &p_headContent, const QString &p_headContent,
const QString &p_styleContent, const QString &p_styleContent,
const QString &p_bodyContent, const QString &p_bodyContent,
@ -989,6 +999,11 @@ bool VExporter::outputToHTMLFile(const QString &p_file,
qDebug() << "HTML files folder" << resFolderPath; qDebug() << "HTML files folder" << resFolderPath;
QString html(m_exportHtmlTemplate); 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) { if (!p_styleContent.isEmpty() && p_embedCssStyle) {
QString content(p_styleContent); QString content(p_styleContent);
embedStyleResources(content); embedStyleResources(content);

View File

@ -135,6 +135,7 @@ private:
// @p_embedImages: embed <img> as data URI. // @p_embedImages: embed <img> as data URI.
bool outputToHTMLFile(const QString &p_file, bool outputToHTMLFile(const QString &p_file,
const QString &p_title,
const QString &p_headContent, const QString &p_headContent,
const QString &p_styleContent, const QString &p_styleContent,
const QString &p_bodyContent, const QString &p_bodyContent,