From 9822babd32bcbec76125362c108ec7b63ff528d4 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 24 May 2021 19:50:32 +0200 Subject: Optimized MathJax HTML output and made the template output the same. --- src/context.cpp | 20 ++++++--- src/htmlgen.cpp | 91 ++++++++++++++++++--------------------- src/htmlgen.h | 1 + templates/html/htmlbase.tpl | 31 +++++++++++-- templates/html/htmljsmenudata.tpl | 2 +- templates/html/htmllayout.tpl | 4 +- templates/html/htmlpage.tpl | 2 +- templates/html/htmltabs.tpl | 2 +- 8 files changed, 90 insertions(+), 63 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 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 += "\n"; - mathJaxJs += "\n" + "\n"; - - if (!g_latex_macro.isEmpty()) + else { - mathJaxJs += "\n"; + mathJaxJs += "\n"; } - + mathJaxJs += "};\n"; // MATHJAX_CODEFILE if (!g_mathjax_code.isEmpty()) { - mathJaxJs += "\n"; } + mathJaxJs += "\n"; - - mathJaxJs += "\n" ; - } - else if (mathJaxFormat == "SVG") - { - mathJaxJs += "es5/tex-svg.js\">\n" ; - } + mathJaxJs += "\n"; } - else + else // MathJax v2 { mathJaxJs = "\n"; - if (!g_latex_macro.isEmpty()) - { - mathJaxJs += "\n"; - } mathJaxJs += "\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) diff --git a/templates/html/htmlbase.tpl b/templates/html/htmlbase.tpl index 8343af9..39bfa8a 100644 --- a/templates/html/htmlbase.tpl +++ b/templates/html/htmlbase.tpl @@ -43,14 +43,37 @@ {% endif %} {% endif %} {% if config.USE_MATHJAX %} +{% if config.MATHJAX_VERSION=="MathJax_3" %} + + + +{% else %}{# MathJax_2 #} - + +{% endif %}{# MathJax_3 #} {% endif %}{# MathJax #} {% if config.HTML_EXTRA_STYLESHEET %} diff --git a/templates/html/htmljsmenudata.tpl b/templates/html/htmljsmenudata.tpl index e795918..2d0a53e 100644 --- a/templates/html/htmljsmenudata.tpl +++ b/templates/html/htmljsmenudata.tpl @@ -46,7 +46,7 @@ var menudata={children:[ ,{text:"{{ tr.classes }}",url:"annotated{{ config.HTML_FILE_EXTENSION }}",children:[ {text:"{{ tr.classList }}",url:"annotated{{ config.HTML_FILE_EXTENSION }}"} ,{text:"{{ tr.classIndex }}",url:"classes{{ config.HTML_FILE_EXTENSION }}"} -{% if classHierarchy.tree %} +{% if classHierarchy.tree and classHierarchy.maxDepth>1 %} ,{text:"{{ tr.classHierarchy }}",url:"hierarchy{{ config.HTML_FILE_EXTENSION }}"} {% endif %} {% if classMembersIndex.all %} diff --git a/templates/html/htmllayout.tpl b/templates/html/htmllayout.tpl index 0fbe458..f96de7e 100644 --- a/templates/html/htmllayout.tpl +++ b/templates/html/htmllayout.tpl @@ -30,9 +30,11 @@ {% resource 'nav_f.lum' %} {% resource 'nav_g.png' %} {% resource 'nav_h.lum' %} +{% if config.GENERATE_TREEVIEW %} {% resource 'navtree.css' %} {% resource 'navtree.js' %} {% resource 'resize.js' %} +{% endif %} {% resource 'menu.js' %} {% resource 'doc.luma' %} {% resource 'folderopen.luma' %} @@ -221,7 +223,7 @@ {% endif %} {# write the class inheritance hierarchy #} - {% if classHierarchy.tree %} + {% if classHierarchy.tree and classHierarchy.maxDepth>1 %} {% with page=classHierarchy %} {% create classHierarchy.fileName|append:config.HTML_FILE_EXTENSION from 'htmlhierarchy.tpl' %} {% if config.HAVE_DOT and config.GRAPHICAL_HIERARCHY %} diff --git a/templates/html/htmlpage.tpl b/templates/html/htmlpage.tpl index 449f601..74396e7 100644 --- a/templates/html/htmlpage.tpl +++ b/templates/html/htmlpage.tpl @@ -33,7 +33,7 @@