diff --git a/src/resources/common.css b/src/resources/common.css index 4c27c5e4..da593966 100644 --- a/src/resources/common.css +++ b/src/resources/common.css @@ -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*/ diff --git a/src/resources/export/export_template.html b/src/resources/export/export_template.html index 36b889fd..92cc216f 100644 --- a/src/resources/export/export_template.html +++ b/src/resources/export/export_template.html @@ -1,7 +1,12 @@ -
+ + + + + + @@ -32,5 +37,9 @@>
+ + diff --git a/src/resources/export/outline.css b/src/resources/export/outline.css index 19f11f7f..b73b2ba1 100644 --- a/src/resources/export/outline.css +++ b/src/resources/export/outline.css @@ -197,3 +197,9 @@ .outline-bold { font-weight: bolder !important; } + +@media print { + #floating-button { + display: none !important; + } +} diff --git a/src/resources/markdown_template.html b/src/resources/markdown_template.html index d872636b..4e2f36b2 100644 --- a/src/resources/markdown_template.html +++ b/src/resources/markdown_template.html @@ -1,7 +1,8 @@ - + + diff --git a/src/resources/mathjax_preview_template.html b/src/resources/mathjax_preview_template.html index af8ec698..54024b78 100644 --- a/src/resources/mathjax_preview_template.html +++ b/src/resources/mathjax_preview_template.html @@ -1,7 +1,8 @@ - + + diff --git a/src/resources/simple_template.html b/src/resources/simple_template.html index 5badbb32..16a31d7d 100644 --- a/src/resources/simple_template.html +++ b/src/resources/simple_template.html @@ -1,7 +1,8 @@ - + + diff --git a/src/utils/vutils.cpp b/src/utils/vutils.cpp index 42defa32..7a190be4 100644 --- a/src/utils/vutils.cpp +++ b/src/utils/vutils.cpp @@ -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; +} diff --git a/src/utils/vutils.h b/src/utils/vutils.h index e2cac5f5..4c097b37 100644 --- a/src/utils/vutils.h +++ b/src/utils/vutils.h @@ -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): diff --git a/src/vconstants.h b/src/vconstants.h index bec19322..803ba9ac 100644 --- a/src/vconstants.h +++ b/src/vconstants.h @@ -51,6 +51,7 @@ namespace HtmlHolder static const QString c_headHolder = ""; static const QString c_styleHolder = "/* STYLE_PLACE_HOLDER */"; static const QString c_outlineStyleHolder = "/* STYLE_OUTLINE_PLACE_HOLDER */"; + static const QString c_headTitleHolder = ""; } // Directory Config file items. diff --git a/src/vdocument.cpp b/src/vdocument.cpp index db1b0ed8..c967a1d5 100644 --- a/src/vdocument.cpp +++ b/src/vdocument.cpp @@ -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; diff --git a/src/vdocument.h b/src/vdocument.h index 3b300aab..f60c598a 100644 --- a/src/vdocument.h +++ b/src/vdocument.h @@ -48,6 +48,8 @@ public: void setFile(const VFile *p_file); + const VFile *getFile() const; + bool isReadyToHighlight() const; bool isReadyToTextToHtml() const; diff --git a/src/vexporter.cpp b/src/vexporter.cpp index a3c2d892..e368cf88 100644 --- a/src/vexporter.cpp +++ b/src/vexporter.cpp @@ -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, + "