From 2c7bba0d84ec5616c6ac0c93f53b394fe8f70899 Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 12 Apr 2021 16:41:38 +0200 Subject: issue #7346 Incompatibility with MathJax 3.0 Implementing the possibility to use MathJax versie 3 - Added setting MATHJAX_VERSION - made setting for MATHJAX_RELPATH so that is suited for version Mathjax version3, i.e. selecting right default - made setting for MATHJAX_FORMAT so that is suited for version Mathjax version3, automatic conversion between MathJax 2 and MathJax3 format setting --- src/config.xml | 34 ++++++++++++--- src/configimpl.l | 40 +++++++++++++----- src/htmlgen.cpp | 123 ++++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 152 insertions(+), 45 deletions(-) diff --git a/src/config.xml b/src/config.xml index 080230c..56a0b56 100644 --- a/src/config.xml +++ b/src/config.xml @@ -2475,20 +2475,33 @@ The \c DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. ]]> + - @@ -2506,10 +2523,15 @@ The \c DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. diff --git a/src/configimpl.l b/src/configimpl.l index cae157b..d557d43 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -1548,6 +1548,23 @@ void Config::checkAndCorrect() // Test to see if MathJax code file is valid if (Config_getBool(USE_MATHJAX)) { + QCString mathJaxFormat = Config_getEnum(MATHJAX_FORMAT); + QCString mathjaxVersion = Config_getEnum(MATHJAX_VERSION); + if (!mathJaxFormat.isEmpty()) + { + if (mathjaxVersion == "MathJax_2") + { + if (mathJaxFormat=="chtml") Config_updateEnum(MATHJAX_FORMAT,"HTML-CSS"); + } + else + { + if (mathJaxFormat=="HTML-CSS" || mathJaxFormat=="NativeMML") + { + Config_updateEnum(MATHJAX_FORMAT,"chtml"); + } + } + } + QCString mathJaxCodefile = Config_getString(MATHJAX_CODEFILE); if (!mathJaxCodefile.isEmpty()) { @@ -1559,7 +1576,19 @@ void Config::checkAndCorrect() } } QCString path = Config_getString(MATHJAX_RELPATH); - if (!path.isEmpty() && path.at(path.length()-1)!='/') + if (path.isEmpty()) + { + if (mathjaxVersion == "MathJax_2") + { + path = "https://cdn.jsdelivr.net/npm/mathjax@2"; + } + else + { + path = "https://cdn.jsdelivr.net/npm/mathjax@3"; + } + } + + if (path.at(path.length()-1)!='/') { path+="/"; } @@ -1975,15 +2004,6 @@ void Config::checkAndCorrect() Config_updateInt(HTML_COLORSTYLE_GAMMA,gamma); //------------------------ - QCString mathJaxFormat = Config_getEnum(MATHJAX_FORMAT); - if (!mathJaxFormat.isEmpty() && mathJaxFormat!="HTML-CSS" && - mathJaxFormat!="NativeMML" && mathJaxFormat!="SVG") - { - err("Unsupported value for MATHJAX_FORMAT: Should be one of HTML-CSS, NativeMML, or SVG\n"); - Config_updateEnum(MATHJAX_FORMAT,"HTML-CSS"); - } - - //------------------------ // add default words if needed const StringVector &annotationFromBrief = Config_getList(ABBREVIATE_BRIEF); if (annotationFromBrief.empty()) diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index fc00b17..3340ad9 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -437,44 +437,109 @@ static QCString substituteHtmlKeywords(const QCString &str, if (mathJax) { + QCString mathJaxVersion = Config_getEnum(MATHJAX_VERSION); QCString path = Config_getString(MATHJAX_RELPATH); if (path.isEmpty() || path.left(2)=="..") // relative path { path.prepend(relPath); } - mathJaxJs = "\n"; + + if (!g_latex_macro.isEmpty()) + { + mathJaxJs += "\n"; + } + + // MATHJAX_CODEFILE + if (!g_mathjax_code.isEmpty()) + { + mathJaxJs += "\n"; + } + + + mathJaxJs += "\n" ; + } + else if (mathJaxFormat == "SVG") + { + mathJaxJs += "es5/tex-svg.js\">\n" ; + } } - mathJaxJs += "\n"; - if (!g_latex_macro.isEmpty()) + else { - mathJaxJs += "\n"; + mathJaxJs = "\n"; + if (!g_latex_macro.isEmpty()) + { + mathJaxJs += "\n"; + } + mathJaxJs += "\n"; } - mathJaxJs += "\n"; } // first substitute generic keywords -- cgit v0.12