diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/context.cpp | 20 | ||||
-rw-r--r-- | src/htmlgen.cpp | 91 | ||||
-rw-r--r-- | src/htmlgen.h | 1 |
3 files changed, 57 insertions, 55 deletions
diff --git a/src/context.cpp b/src/context.cpp index 7d1c6a7..6835d98 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -395,9 +395,13 @@ class DoxygenContext::Private { return dateToString(TRUE); } - TemplateVariant maxJaxCodeFile() const + TemplateVariant mathJaxCodeFile() const { - return m_cache.maxJaxCodeFile; + return m_cache.mathJaxCodeFile; + } + TemplateVariant mathJaxMacros() const + { + return m_cache.mathJaxMacros; } Private() { @@ -409,7 +413,9 @@ class DoxygenContext::Private //%% string date s_inst.addProperty("date", &Private::date); //%% string maxJaxCodeFile - s_inst.addProperty("mathJaxCodeFile", &Private::maxJaxCodeFile); + s_inst.addProperty("mathJaxCodeFile", &Private::mathJaxCodeFile); + //%% string maxJaxMacros + s_inst.addProperty("mathJaxMacros", &Private::mathJaxMacros); init=TRUE; } } @@ -424,8 +430,12 @@ class DoxygenContext::Private private: struct Cachable { - Cachable() { maxJaxCodeFile=fileToString(Config_getString(MATHJAX_CODEFILE)); } - QCString maxJaxCodeFile; + Cachable() { + mathJaxCodeFile=fileToString(Config_getString(MATHJAX_CODEFILE)); + mathJaxMacros=HtmlGenerator::getMathJaxMacros(); + } + QCString mathJaxCodeFile; + QCString mathJaxMacros; }; mutable Cachable m_cache; static PropertyMapper<DoxygenContext::Private> s_inst; diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index c8c8021..86825e4 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -449,19 +449,25 @@ static QCString substituteHtmlKeywords(const QCString &str, if (mathJaxVersion == "MathJax_3") { - mathJaxJs += "<script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n"; - mathJaxJs += "<script>\n" - " window.MathJax = {\n" - " options: {\n" - " ignoreHtmlClass: 'tex2jax_ignore',\n" - " processHtmlClass: 'tex2jax_process'\n" - " },\n"; + mathJaxJs += "<script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n" + "<script type=\"text/javascript\">\n" + "window.MathJax = {\n" + " options: {\n" + " ignoreHtmlClass: 'tex2jax_ignore',\n" + " processHtmlClass: 'tex2jax_process'\n" + " }"; const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS); if (!mathJaxExtensions.empty() || !g_latex_macro.isEmpty()) { - mathJaxJs+= " tex: {\n" - " macros: {},\n" - " packages: ['base','configmacros'"; + mathJaxJs+= ",\n" + " tex: {\n" + " macros: {"; + if (!g_latex_macro.isEmpty()) + { + mathJaxJs += g_latex_macro+" "; + } + mathJaxJs+="},\n" + " packages: ['base','configmacros'"; if (!g_latex_macro.isEmpty()) { mathJaxJs+= ",'newcommand'"; @@ -471,46 +477,30 @@ static QCString substituteHtmlKeywords(const QCString &str, mathJaxJs+= ",'"+QCString(s.c_str())+"'"; } mathJaxJs += "]\n" - " }\n"; + " }\n"; } - mathJaxJs += " };\n"; - mathJaxJs += "</script>\n"; - - if (!g_latex_macro.isEmpty()) + else { - mathJaxJs += "<script>\n" - " Object.assign(MathJax.tex.macros, {\n"; - mathJaxJs += g_latex_macro; - mathJaxJs += "\n" - " });\n" - "</script>\n"; + mathJaxJs += "\n"; } - + mathJaxJs += "};\n"; // MATHJAX_CODEFILE if (!g_mathjax_code.isEmpty()) { - mathJaxJs += "<script>\n"; mathJaxJs += g_mathjax_code; mathJaxJs += "\n"; - mathJaxJs += "</script>\n"; } + mathJaxJs += "</script>\n"; - - mathJaxJs += "<script type=\"text/javascript\" id=\"MathJax-script\" async=\"async\" src=\"" + path; - if (mathJaxFormat == "chtml") - { - mathJaxJs += "es5/tex-chtml.js\"></script>\n" ; - } - else if (mathJaxFormat == "SVG") - { - mathJaxJs += "es5/tex-svg.js\"></script>\n" ; - } + mathJaxJs += "<script type=\"text/javascript\" id=\"MathJax-script\" async=\"async\" src=\"" + + path + "es5/tex-" + mathJaxFormat.lower() + ".js\">"; + mathJaxJs+="</script>\n"; } - else + else // MathJax v2 { mathJaxJs = "<script type=\"text/x-mathjax-config\">\n" - " MathJax.Hub.Config({\n" - " extensions: [\"tex2jax.js\""; + "MathJax.Hub.Config({\n" + " extensions: [\"tex2jax.js\""; const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS); for (const auto &s : mathJaxExtensions) { @@ -521,25 +511,21 @@ static QCString substituteHtmlKeywords(const QCString &str, mathJaxFormat = "HTML-CSS"; } mathJaxJs += "],\n" - " jax: [\"input/TeX\",\"output/"+mathJaxFormat+"\"],\n" - "});\n"; + " jax: [\"input/TeX\",\"output/"+mathJaxFormat+"\"],\n"; + if (!g_latex_macro.isEmpty()) + { + mathJaxJs += " TeX: { Macros: {\n"; + mathJaxJs += g_latex_macro; + mathJaxJs += "\n" + " } }\n"; + } + mathJaxJs += "});\n"; if (!g_mathjax_code.isEmpty()) { mathJaxJs += g_mathjax_code; mathJaxJs += "\n"; } mathJaxJs += "</script>\n"; - if (!g_latex_macro.isEmpty()) - { - mathJaxJs += "<script type=\"text/x-mathjax-config\">\n" - " MathJax.Hub.Config({\n" - " TeX: { Macros: {\n"; - mathJaxJs += g_latex_macro; - mathJaxJs += "\n" - " } }\n" - "});\n" - "</script>\n"; - } mathJaxJs += "<script type=\"text/javascript\" async=\"async\" src=\"" + path + "MathJax.js\"></script>\n"; } } @@ -3066,3 +3052,8 @@ void HtmlGenerator::addWord(const QCString &word,bool hiPriority) Doxygen::searchIndex->addWord(word,hiPriority); } } + +QCString HtmlGenerator::getMathJaxMacros() +{ + return getConvertLatexMacro(); +} diff --git a/src/htmlgen.h b/src/htmlgen.h index 845f259..c66e622 100644 --- a/src/htmlgen.h +++ b/src/htmlgen.h @@ -83,6 +83,7 @@ class HtmlGenerator : public OutputGenerator static void writeExternalSearchPage(); static QCString writeLogoAsString(const QCString &path); static QCString writeSplitBarAsString(const QCString &name,const QCString &relpath); + static QCString getMathJaxMacros(); // ---- CodeOutputInterface void codify(const QCString &text) |