Skip to content

Commit

Permalink
Merge pull request #284 from robertatakenaka/opac_tk2063
Browse files Browse the repository at this point in the history
Corrige a apresentação de fórmulas na página do artigo
  • Loading branch information
gitnnolabs authored Mar 4, 2022
2 parents fe9e183 + 8ff2283 commit cdbb78a
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 12 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@
version="1.0">

<xsl:template match="alternatives">
<!-- primeiro -->
<xsl:apply-templates select="*[1]"/>
</xsl:template>

<xsl:template match="disp-formula/alternatives | inline-formula/alternatives">
<xsl:choose>
<xsl:when test="$MATH_ELEM_PREFERENCE='tex-math' and tex-math">
<xsl:apply-templates select="tex-math" />
</xsl:when>
<xsl:when test="$MATH_ELEM_PREFERENCE='math' and math">
<xsl:apply-templates select="math" />
</xsl:when>
<xsl:when test="$MATH_ELEM_PREFERENCE='mml:math' and mml:math">
<xsl:apply-templates select="mml:math" />
</xsl:when>
<xsl:when test="tex-math">
<xsl:apply-templates select="tex-math" />
</xsl:when>
<xsl:when test="mml:math">
<xsl:apply-templates select="mml:math" />
</xsl:when>
<xsl:when test="math">
<xsl:apply-templates select="math" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*[1]"></xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="fig/alternatives">
<!--
Apresentar a imagem padrão
-->
<xsl:choose>
<xsl:when test="inline-graphic[@specific-use='scielo-web']">
<xsl:apply-templates select="inline-graphic[@specific-use='scielo-web']" />
Expand Down
29 changes: 24 additions & 5 deletions packtools/catalogs/htmlgenerator/v2.0/article-text-formula.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,34 @@
<xsl:apply-templates select="alternatives" />
</xsl:template>

<xsl:template match="tex-math">
<xsl:template match="inline-formula/tex-math | inline-formula/alternatives/tex-math">
<xsl:choose>
<xsl:when test="starts-with(.,'\begin') and contains(.,'\end')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="starts-with(.,'\(') and ends-with(.,'\)')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="starts-with(.,'$') and ends-with(.,'$')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>\(<xsl:value-of select="."/>\)</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="disp-formula/tex-math | disp-formula/alternatives/tex-math">
<span class="formula-body">
<xsl:choose>
<xsl:when test="contains(.,'\begin{document}') and contains(.,'\end{document}')">
<xsl:value-of select="substring-after(substring-before(.,'\end{document}'),'\begin{document}')"/>
<xsl:when test="starts-with(.,'\begin') and contains(.,'\end')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:when test="starts-with(.,'\[') and ends-with(.,'\]')">
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:when>
<xsl:when test="starts-with(.,'$$') and ends-with(.,'$$')">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>\[<xsl:value-of select="."/>\]</xsl:otherwise>
</xsl:choose>
</span>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mml="http://www.w3.org/1998/Math/MathML"
exclude-result-prefixes="xlink mml"
version="1.0">
<xsl:template match="mml:math">
<xsl:template match="mml:math | math">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
16 changes: 13 additions & 3 deletions packtools/catalogs/htmlgenerator/v2.0/article.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,19 @@
<script src="{$JS_PATH}/js/min/main-min.js"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test=".//math or .//mml:math">
<script type="text/javascript"
src="{$MATHJAX}">
<xsl:if test=".//tex-math or .//math or .//mml:math">
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
</script>
<script type="text/javascript" id="MathJax-script" async="true"
src="{$MATHJAX}">
</script>
</xsl:if>
</xsl:template>
Expand Down
17 changes: 16 additions & 1 deletion packtools/catalogs/htmlgenerator/v2.0/config-vars.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@
<xsl:param name="legendary"></xsl:param>
<xsl:param name="abbr_contrib"></xsl:param>

<xsl:param name="math_elem_preference" select="''"/>
<xsl:param name="math_js" select="''"/>

<xsl:param name="output_style"/>

<xsl:variable name="MATHJAX">https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML</xsl:variable>
<xsl:variable name="MATH_ELEM_PREFERENCE">
<xsl:choose>
<xsl:when test="$math_elem_preference='mml:math'">mml:math</xsl:when>
<xsl:otherwise>tex-math</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="MATHJAX">
<xsl:choose>
<xsl:when test="$math_js!=''"><xsl:value-of select="$math_js"/></xsl:when>
<xsl:otherwise>https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/tex-chtml.js</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="ABBR_CONTRIB"><xsl:choose>
<xsl:when test="$abbr_contrib!=''"><xsl:value-of select="$abbr_contrib"/></xsl:when>
<xsl:otherwise>false</xsl:otherwise>
Expand Down
2 changes: 1 addition & 1 deletion packtools/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Single source to the version across setup.py and the whole project.
"""
from __future__ import unicode_literals
__version__ = '2.8.2'
__version__ = '2.8.3'

0 comments on commit cdbb78a

Please sign in to comment.