Browse Source

add config mathjax_javascript for Mathjax location and configuration

Le Tan 8 years ago
parent
commit
d955dedcb7
6 changed files with 18 additions and 6 deletions
  1. 4 0
      src/resources/vnote.ini
  2. 1 1
      src/utils/vutils.cpp
  3. 3 0
      src/vconfigmanager.cpp
  4. 10 0
      src/vconfigmanager.h
  5. 0 2
      src/vnote.cpp
  6. 0 3
      src/vnote.h

+ 4 - 0
src/resources/vnote.ini

@@ -119,6 +119,10 @@ confirm_images_clean_up=true
 ; Confirm before reloading folder from disk
 confirm_reload_folder=true
 
+[web]
+; Location and configuration for Mathjax
+mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML
+
 [session]
 tools_dock_checked=true
 

+ 1 - 1
src/utils/vutils.cpp

@@ -561,7 +561,7 @@ QString VUtils::generateHtmlTemplate(MarkdownConverterType p_conType, bool p_exp
                      "                    showProcessingMessages: false,\n"
                      "                    messageStyle: \"none\"});\n"
                      "</script>\n"
-                     "<script type=\"text/javascript\" async src=\"" + VNote::c_mathjaxJsFile + "\"></script>\n" +
+                     "<script type=\"text/javascript\" async src=\"" + g_config->getMathjaxJavascript() + "\"></script>\n" +
                      "<script>var VEnableMathjax = true;</script>\n";
     }
 

+ 3 - 0
src/vconfigmanager.cpp

@@ -213,6 +213,9 @@ void VConfigManager::initialize()
 
     m_confirmReloadFolder = getConfigFromSettings("global",
                                                   "confirm_reload_folder").toBool();
+
+    m_mathjaxJavascript = getConfigFromSettings("web",
+                                                "mathjax_javascript").toString();
 }
 
 void VConfigManager::readPredefinedColorsFromSettings()

+ 10 - 0
src/vconfigmanager.h

@@ -277,6 +277,8 @@ public:
     bool getConfirmReloadFolder() const;
     void setConfirmReloadFolder(bool p_enabled);
 
+    const QString &getMathjaxJavascript() const;
+
     // Return the configured key sequence of @p_operation.
     // Return empty if there is no corresponding config.
     QString getShortcutKeySequence(const QString &p_operation) const;
@@ -557,6 +559,9 @@ private:
     // Confirm before reloading folder from disk.
     bool m_confirmReloadFolder;
 
+    // Location and configuration for Mathjax.
+    QString m_mathjaxJavascript;
+
     // The name of the config file in each directory, obsolete.
     // Use c_dirConfigFile instead.
     static const QString c_obsoleteDirConfigFile;
@@ -1468,4 +1473,9 @@ inline void VConfigManager::setConfirmReloadFolder(bool p_enabled)
                         m_confirmReloadFolder);
 }
 
+inline const QString &VConfigManager::getMathjaxJavascript() const
+{
+    return m_mathjaxJavascript;
+}
+
 #endif // VCONFIGMANAGER_H

+ 0 - 2
src/vnote.cpp

@@ -44,8 +44,6 @@ const QString VNote::c_mermaidForestCssFile = ":/utils/mermaid/mermaid.forest.cs
 const QString VNote::c_flowchartJsFile = ":/utils/flowchart.js/flowchart.min.js";
 const QString VNote::c_raphaelJsFile = ":/utils/flowchart.js/raphael.min.js";
 
-const QString VNote::c_mathjaxJsFile = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML";
-
 const QString VNote::c_highlightjsLineNumberExtraFile = ":/utils/highlightjs/highlightjs-line-numbers.min.js";
 
 const QString VNote::c_shortcutsDocFile_en = ":/resources/docs/shortcuts_en.md";

+ 0 - 3
src/vnote.h

@@ -62,9 +62,6 @@ public:
     static const QString c_flowchartJsFile;
     static const QString c_raphaelJsFile;
 
-    // Mathjax
-    static const QString c_mathjaxJsFile;
-
     // Highlight.js line number plugin
     static const QString c_highlightjsLineNumberExtraFile;