Skip to content

Commit

Permalink
Add mathjax support to template & context.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Aug 27, 2015
1 parent f16c156 commit 56987af
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/config.l
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/context.cpp
Expand Up @@ -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;
};
//%% }

Expand Down
6 changes: 1 addition & 5 deletions src/htmlgen.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -364,7 +360,7 @@ static QCString substituteHtmlKeywords(const QCString &s,
mathJaxJs += "\n";
}
mathJaxJs += "</script>";
mathJaxJs += "<script src=\"" + path + "MathJax.js\"></script>\n";
mathJaxJs += "<script type=\"text/javascript\" src=\"" + path + "MathJax.js\"></script>\n";
}

// first substitute generic keywords
Expand Down
20 changes: 20 additions & 0 deletions src/template.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -1416,6 +1435,7 @@ static TemplateFilterFactory::AutoRegister<FilterFlatten> fFlatten("flatten"
static TemplateFilterFactory::AutoRegister<FilterDefault> fDefault("default");
static TemplateFilterFactory::AutoRegister<FilterPrepend> fPrepend("prepend");
static TemplateFilterFactory::AutoRegister<FilterGroupBy> fGroupBy("groupBy");
static TemplateFilterFactory::AutoRegister<FilterRelative> fRelative("relative");
static TemplateFilterFactory::AutoRegister<FilterListSort> fListSort("listsort");
static TemplateFilterFactory::AutoRegister<FilterPaginate> fPaginate("paginate");
static TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath");
Expand Down
15 changes: 7 additions & 8 deletions templates/html/htmlbase.tpl
Expand Up @@ -41,13 +41,13 @@
{% if config.USE_MATHJAX %}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"], {# TODO: support MATHJAX_EXTENSIONS #}
jax: ["input/TeX","output/{{ config.MATHJAX_FORMAT }}"],
extensions: ["tex2jax.js"{% for ext in config.MATHJAX_EXTENSIONS %}, "{{ ext }}"{% endfor %}],
jax: ["input/TeX","output/{{ config.MATHJAX_FORMAT|default:'HTML-CSS' }}"],
});
{# TODO: support MATHJAX_CODEFILE #}
{{ doxygen.mathJaxCodeFile }}
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
{% endif %}
<script type="text/javascript" src="{{ config.MATHJAX_RELPATH }}{% if config.MATHJAX_RELPATH|relative %}{{ page.relPath }}{% endif %}MathJax.js"></script>
{% endif %}{# MathJax #}
<link href="{{ page.relPath }}{{ config.HTML_STYLESHEET|default:'doxygen.css' }}" rel="stylesheet" type="text/css" />
{% if config.HTML_EXTRA_STYLESHEET %}
<link href="{{ page.relPath }}{{ config.HTML_EXTRA_STYLESHEET }}" rel="stylesheet" type="text/css" />
Expand Down Expand Up @@ -120,7 +120,7 @@
<!-- end header part -->
<!-- Generated by Doxygen {{ doxygen.version }} -->
{% block search %}
{% if config.SEARCHENGINE %}{# TODO: can't we move this to the header? #}
{% if config.SEARCHENGINE %}
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "{{ page.relPath }}search",false,'{{ tr.search }}');
</script>
Expand Down Expand Up @@ -163,14 +163,13 @@ $(document).ready(function(){initNavTree('{{ page.fileName }}{% if page_postfix
<div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
{# TODO: get search categories dynamically, since we don't know them here #}
</div>
{% endif %}
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
</iframe>
</div>
{% endif %}
{% endblock %}
<div class="header">
Expand Down

0 comments on commit 56987af

Please sign in to comment.