Skip to content

Commit

Permalink
Merge pull request DSpace#680 from LongsightGroup/DS-635-mathjax
Browse files Browse the repository at this point in the history
DS-635 Render scientific formulas in XMLUI using MathJax
  • Loading branch information
peterdietz committed Oct 20, 2014
2 parents 4e1c740 + 699eca5 commit 938eec3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dspace-xmlui-mirage2/src/main/webapp/xsl/core/page-structure.xsl
Expand Up @@ -295,6 +295,33 @@
<meta name="{@element}" content="{.}"></meta>
</xsl:for-each>

<!-- Add MathJAX CDN to render scientific formulas -->
<xsl:if test="confman:getProperty('webui.browse.render-scientific-formulas') = 'true'">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
ignoreClass: "detail-field-data|detailtable"
},
TeX: {
Macros: {
AA: '{\\mathring A}'
}
}
});
</script>

<xsl:choose>

<xsl:when test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='request'][@qualifier='scheme']='https'">
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">&#160;</script>
</xsl:when>
<xsl:otherwise>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">&#160;</script>
</xsl:otherwise>
</xsl:choose>
</xsl:if>

</head>
</xsl:template>

Expand Down
Expand Up @@ -311,6 +311,33 @@
<meta name="{@element}" content="{.}"></meta>
</xsl:for-each>

<!-- Add MathJAX CDN, can do a local install, or possibly get SSL enabled-->
<xsl:if test="confman:getProperty('webui.browse.render-scientific-formulas') = 'true'">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
ignoreClass: "detail-field-data|detailtable"
},
TeX: {
Macros: {
AA: '{\\mathring A}'
}
}
});
</script>

<xsl:choose>

<xsl:when test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='request'][@qualifier='scheme']='https'">
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">&#160;</script>
</xsl:when>
<xsl:otherwise>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">&#160;</script>
</xsl:otherwise>
</xsl:choose>
</xsl:if>

</head>
</xsl:template>

Expand Down
4 changes: 4 additions & 0 deletions dspace/config/dspace.cfg
Expand Up @@ -1235,6 +1235,10 @@ plugin.named.org.dspace.sort.OrderFormatDelegate= \
#
webui.browse.link.1 = author:dc.contributor.*

### Render scientific formulas symbols in view/browse
# Use MathJax to render properly encoded text formulas to be visual for people
#webui.browse.render-scientific-formulas = true

#### Display browse frequencies
#
# webui.browse.metadata.show-freq.<n> = true | false
Expand Down

0 comments on commit 938eec3

Please sign in to comment.