diff --git a/src/resources/common.css b/src/resources/common.css
index 5552b9dd..4c27c5e4 100644
--- a/src/resources/common.css
+++ b/src/resources/common.css
@@ -4,3 +4,86 @@ div.mark-rect {
border-radius: 2px;
position: absolute;
}
+
+/* Mathjax */
+x-eqs {
+ display: flex;
+ flex-direction: row;
+ align-content: space-between;
+ align-items: center;
+}
+
+x-eqs > x-eqn {
+ width: 100%;
+ margin-left: 3em;
+}
+
+x-eqs > span {
+ text-align:right;
+}
+/* Mathjax */
+
+/* View Image */
+.view-image,.view-svg {
+ transition: 0.3s;
+}
+
+.modal-box {
+ display: none;
+ position: fixed;
+ z-index: 1000;
+ padding-top: 50px;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ background-color: rgb(68, 68, 68);
+ background-color: rgba(68, 68, 68, 0.95);
+}
+
+.modal-content {
+ margin: auto;
+ display: block;
+ width: auto;
+ height: auto;
+ cursor: move;
+}
+
+/* Add Animation */
+.modal-content {
+ -webkit-animation-name: zoom;
+ -webkit-animation-duration: 0.6s;
+ animation-name: zoom;
+ animation-duration: 0.6s;
+}
+
+@-webkit-keyframes zoom {
+ from {-webkit-transform:scale(0)}
+ to {-webkit-transform:scale(1)}
+}
+
+@keyframes zoom {
+ from {transform:scale(0)}
+ to {transform:scale(1)}
+}
+
+/* The Close Button */
+span.modal-close {
+ position: absolute;
+ z-index: 1000;
+ top: 15px;
+ right: 35px;
+ color: #DADADA;
+ font-size: 40px;
+ font-weight: bold;
+ transition: 0.3s;
+}
+
+span.modal-close:hover,
+span.modal-close:focus {
+ color: #EEEEEE;
+ text-decoration: none;
+ cursor: pointer;
+}
+/* View Image */
diff --git a/src/resources/markdown_template.html b/src/resources/markdown_template.html
index 7b426694..d872636b 100644
--- a/src/resources/markdown_template.html
+++ b/src/resources/markdown_template.html
@@ -21,8 +21,7 @@
}
-
-
+
diff --git a/src/resources/view_image.css b/src/resources/view_image.css
deleted file mode 100644
index 4d9c8d08..00000000
--- a/src/resources/view_image.css
+++ /dev/null
@@ -1,62 +0,0 @@
-.view-image,.view-svg {
- transition: 0.3s;
-}
-
-.modal-box {
- display: none;
- position: fixed;
- z-index: 1000;
- padding-top: 50px;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- overflow: hidden;
- background-color: rgb(68, 68, 68);
- background-color: rgba(68, 68, 68, 0.95);
-}
-
-.modal-content {
- margin: auto;
- display: block;
- width: auto;
- height: auto;
- cursor: move;
-}
-
-/* Add Animation */
-.modal-content {
- -webkit-animation-name: zoom;
- -webkit-animation-duration: 0.6s;
- animation-name: zoom;
- animation-duration: 0.6s;
-}
-
-@-webkit-keyframes zoom {
- from {-webkit-transform:scale(0)}
- to {-webkit-transform:scale(1)}
-}
-
-@keyframes zoom {
- from {transform:scale(0)}
- to {transform:scale(1)}
-}
-
-/* The Close Button */
-span.modal-close {
- position: absolute;
- z-index: 1000;
- top: 15px;
- right: 35px;
- color: #DADADA;
- font-size: 40px;
- font-weight: bold;
- transition: 0.3s;
-}
-
-span.modal-close:hover,
-span.modal-close:focus {
- color: #EEEEEE;
- text-decoration: none;
- cursor: pointer;
-}
diff --git a/src/utils/markdown-it/markdown-it-texmath.js b/src/utils/markdown-it/markdown-it-texmath.js
index 85868951..9c1e6bf8 100644
--- a/src/utils/markdown-it/markdown-it-texmath.js
+++ b/src/utils/markdown-it/markdown-it-texmath.js
@@ -18,7 +18,8 @@ function texmath(md, options) {
for (let rule of texmath.rules[delimiters].block) {
md.block.ruler.before('fence', rule.name, texmath.block(rule));
- md.renderer.rules[rule.name] = (tokens, idx) => rule.tmpl.replace(/\$1/,texmath.render(tokens[idx].content,true));
+ md.renderer.rules[rule.name] = (tokens, idx) => rule.tmpl.replace(/\$2/,tokens[idx].info) // equation number
+ .replace(/\$1/,texmath.render(tokens[idx].content,true));
}
}
}
@@ -58,6 +59,7 @@ texmath.block = (rule) =>
let token = state.push(rule.name, 'math', 0);
token.block = true;
token.content = res[1];
+ token.info = res[2];
token.markup = rule.tag;
}
for (let line=begLine, endpos=res.lastIndex-1; line < endLine; line++)
@@ -101,6 +103,11 @@ texmath.rules = {
}
],
block: [
+ { name: 'math_block_eqno',
+ rex: /\\\[(.+?)\\\]\s*?\(([^)$\r\n]+?)\)\s*$/gmy,
+ tmpl: '$1($2)',
+ tag: '\\['
+ },
{ name: 'math_block',
rex: /\\\[(.+?)\\\]\s*$/gmy,
tmpl: '$1',
@@ -117,6 +124,11 @@ texmath.rules = {
}
],
block: [
+ { name: 'math_block_eqno',
+ rex: /`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)\s*$/gmy,
+ tmpl: '$1($2)',
+ tag: '```math'
+ },
{ name: 'math_block',
rex: /`{3}math\s+?([^`]+?)\s+?`{3}\s*$/gmy,
tmpl: '$1',
@@ -142,6 +154,11 @@ texmath.rules = {
}
],
block: [
+ { name: 'math_block_eqno',
+ rex: /\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)\s*$/gmy,
+ tmpl: '$1($2)',
+ tag: '$$'
+ },
{ name: 'math_block',
rex: /\${2}([^$]*?)\${2}\s*$/gmy,
tmpl: '$1',
diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp
index eeb2bb2a..040ce6b6 100644
--- a/src/vconfigmanager.cpp
+++ b/src/vconfigmanager.cpp
@@ -41,6 +41,8 @@ const QString VConfigManager::c_templateConfigFolder = QString("templates");
const QString VConfigManager::c_snippetConfigFolder = QString("snippets");
+const QString VConfigManager::c_resourceConfigFolder = QString("resources");
+
const QString VConfigManager::c_warningTextStyle = QString("color: #C9302C; font: bold");
const QString VConfigManager::c_dataTextStyle = QString("font: bold");
@@ -64,6 +66,8 @@ void VConfigManager::initialize()
{
initSettings();
+ checkVersion();
+
initThemes();
initEditorStyles();
@@ -858,6 +862,30 @@ const QString &VConfigManager::getSnippetConfigFilePath() const
return path;
}
+QString VConfigManager::getResourceConfigFolder() const
+{
+ return QDir(getConfigFolder()).filePath(c_resourceConfigFolder);
+}
+
+const QString &VConfigManager::getCommonCssUrl() const
+{
+ static QString cssPath;
+ if (cssPath.isEmpty()) {
+ cssPath = QDir(getResourceConfigFolder()).filePath("common.css");
+ if (m_versionChanged || !QFileInfo::exists(cssPath)) {
+ // Output the default one.
+ if (!VUtils::copyFile(":/resources/common.css", cssPath, false)) {
+ cssPath = "qrc:/resources/common.css";
+ return cssPath;
+ }
+ }
+
+ cssPath = QUrl::fromLocalFile(cssPath).toString();
+ }
+
+ return cssPath;
+}
+
const QString VConfigManager::getKeyboardLayoutConfigFilePath() const
{
return QDir(getConfigFolder()).filePath(c_keyboardLayoutConfigFile);
@@ -1637,3 +1665,12 @@ QString VConfigManager::getRenderBackgroundColor(const QString &p_bgName) const
return QString();
}
+void VConfigManager::checkVersion()
+{
+ const QString key("version");
+ QString ver = getConfigFromSettings("global", key).toString();
+ m_versionChanged = ver != c_version;
+ if (m_versionChanged) {
+ setConfigToSettings("global", key, c_version);
+ }
+}
diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h
index 93d6cf50..6b076745 100644
--- a/src/vconfigmanager.h
+++ b/src/vconfigmanager.h
@@ -457,6 +457,11 @@ public:
// Get the folder c_codeBlockStyleConfigFolder in the config folder.
const QString &getCodeBlockStyleConfigFolder() const;
+ // Get the folder c_resourceConfigFolder in the config folder.
+ QString getResourceConfigFolder() const;
+
+ const QString &getCommonCssUrl() const;
+
// All the editor styles.
QList getEditorStyles() const;
@@ -663,6 +668,8 @@ private:
QString getEditorStyleFile() const;
+ void checkVersion();
+
// Default font and palette.
QFont m_defaultEditFont;
QPalette m_defaultEditPalette;
@@ -1032,6 +1039,9 @@ private:
// Whether download image from parse and paste.
bool m_parsePasteLocalImage;
+ // Whether the VNote instance has different version of vnote.ini.
+ bool m_versionChanged;
+
// The name of the config file in each directory.
static const QString c_dirConfigFile;
@@ -1080,6 +1090,9 @@ private:
// The default export output folder name.
static const QString c_exportFolderName;
+
+ // The folder name of resource files.
+ static const QString c_resourceConfigFolder;
};
diff --git a/src/vconstants.h b/src/vconstants.h
index bc02c183..bec19322 100644
--- a/src/vconstants.h
+++ b/src/vconstants.h
@@ -44,6 +44,7 @@ namespace HtmlHolder
static const QString c_JSHolder = "JS_PLACE_HOLDER";
static const QString c_cssHolder = "CSS_PLACE_HOLDER";
static const QString c_codeBlockCssHolder = "HIGHLIGHTJS_CSS_PLACE_HOLDER";
+ static const QString c_commonCssHolder = "COMMON_CSS_PLACE_HOLDER";
static const QString c_globalStyleHolder = "/* STYLE_GLOBAL_PLACE_HOLDER */";
static const QString c_extraHolder = "";
static const QString c_bodyHolder = "";
diff --git a/src/vnote.cpp b/src/vnote.cpp
index 1f981f37..2f1f9ff1 100644
--- a/src/vnote.cpp
+++ b/src/vnote.cpp
@@ -120,6 +120,7 @@ QString VNote::generateHtmlTemplate(const QString &p_renderBg,
g_palette->fillStyle(templ);
// Must replace the code block holder first.
+ templ.replace(HtmlHolder::c_commonCssHolder, g_config->getCommonCssUrl());
templ.replace(HtmlHolder::c_codeBlockCssHolder, p_codeBlockStyleUrl);
templ.replace(HtmlHolder::c_cssHolder, p_renderStyleUrl);
diff --git a/src/vnote.qrc b/src/vnote.qrc
index d9c39e66..ffb09bf5 100644
--- a/src/vnote.qrc
+++ b/src/vnote.qrc
@@ -261,7 +261,6 @@
resources/icons/tag_explorer.svg
resources/icons/tag.svg
resources/view_image.js
- resources/view_image.css
resources/icons/decrease_outline_level.svg
resources/icons/increase_outline_level.svg
utils/markdown-it/markdown-it-texmath.js