From 56987af3987f40ac77e70cd39ebbdac3702c1ce2 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 1 Jan 2015 10:13:04 +0100 Subject: Add mathjax support to template & context. --- src/config.l | 6 ++++++ src/context.cpp | 13 +++++++++++++ src/htmlgen.cpp | 6 +----- src/template.cpp | 20 ++++++++++++++++++++ templates/html/htmlbase.tpl | 15 +++++++-------- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/config.l b/src/config.l index 1bbe320..b158e5c 100644 --- a/src/config.l +++ b/src/config.l @@ -1198,6 +1198,12 @@ void Config::check() exit(1); } } + QCString &path = Config_getString("MATHJAX_RELPATH"); + if (!path.isEmpty() && path.at(path.length()-1)!='/') + { + path+="/"; + } + } // Test to see if LaTeX header is valid diff --git a/src/context.cpp b/src/context.cpp index 17229f7..f7e6ae2 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -370,13 +370,26 @@ class DoxygenContext::Private : public PropertyMapper { return TemplateVariant(dateToString(TRUE)); } + TemplateVariant maxJaxCodeFile() const + { + return m_cache.maxJaxCodeFile; + } Private() { //%% string version addProperty("version",this,&Private::version); //makeProperty(this,&Private::version)); //%% string date addProperty("date", this,&Private::date); + //%% string + addProperty("mathJaxCodeFile", this,&Private::maxJaxCodeFile); } + private: + struct Cachable + { + Cachable() { maxJaxCodeFile=fileToString(Config_getString("MATHJAX_CODEFILE")); } + QCString maxJaxCodeFile; + }; + mutable Cachable m_cache; }; //%% } diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index e6431e8..7908393 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -333,10 +333,6 @@ static QCString substituteHtmlKeywords(const QCString &s, if (mathJax) { QCString path = Config_getString("MATHJAX_RELPATH"); - if (!path.isEmpty() && path.at(path.length()-1)!='/') - { - path+="/"; - } if (path.isEmpty() || path.left(2)=="..") // relative path { path.prepend(relPath); @@ -364,7 +360,7 @@ static QCString substituteHtmlKeywords(const QCString &s, mathJaxJs += "\n"; } mathJaxJs += ""; - mathJaxJs += "\n"; + mathJaxJs += "\n"; } // first substitute generic keywords diff --git a/src/template.cpp b/src/template.cpp index ce9493b..e81ed17 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -1116,6 +1116,25 @@ class FilterGroupBy //-------------------------------------------------------------------- +/** @brief The implementation of the "relative" filter */ +class FilterRelative +{ + public: + static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &) + { + if (v.isValid() && v.type()==TemplateVariant::String && v.toString().left(2)=="..") + { + return TRUE; + } + else + { + return FALSE; + } + } +}; + +//-------------------------------------------------------------------- + /** @brief The implementation of the "paginate" filter */ class FilterPaginate { @@ -1416,6 +1435,7 @@ static TemplateFilterFactory::AutoRegister fFlatten("flatten" static TemplateFilterFactory::AutoRegister fDefault("default"); static TemplateFilterFactory::AutoRegister fPrepend("prepend"); static TemplateFilterFactory::AutoRegister fGroupBy("groupBy"); +static TemplateFilterFactory::AutoRegister fRelative("relative"); static TemplateFilterFactory::AutoRegister fListSort("listsort"); static TemplateFilterFactory::AutoRegister fPaginate("paginate"); static TemplateFilterFactory::AutoRegister fStripPath("stripPath"); diff --git a/templates/html/htmlbase.tpl b/templates/html/htmlbase.tpl index 2191186..5ee7f3e 100644 --- a/templates/html/htmlbase.tpl +++ b/templates/html/htmlbase.tpl @@ -41,13 +41,13 @@ {% if config.USE_MATHJAX %} - -{% endif %} + +{% endif %}{# MathJax #} {% if config.HTML_EXTRA_STYLESHEET %} @@ -120,7 +120,7 @@ {% block search %} -{% if config.SEARCHENGINE %}{# TODO: can't we move this to the header? #} +{% if config.SEARCHENGINE %} @@ -163,14 +163,13 @@ $(document).ready(function(){initNavTree('{{ page.fileName }}{% if page_postfix
-{# TODO: get search categories dynamically, since we don't know them here #}
-{% endif %}
+{% endif %} {% endblock %}
-- cgit v0.12