Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merry Christmas Tables
  • Loading branch information
kthoden committed Dec 21, 2018
1 parent df3508f commit 53e87c4
Showing 1 changed file with 87 additions and 22 deletions.
109 changes: 87 additions & 22 deletions tei2eoatex.xsl
Expand Up @@ -9,7 +9,7 @@

<xsl:param name="frontmatter" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="contributors" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="strictfigures" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="strictfloats" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="verbosity" as="xs:integer" required="no" select="0"/>
<xsl:param name="parts" as="xs:boolean" required="yes"/>

Expand All @@ -35,6 +35,7 @@ contexts, a double replacement is performed.
<xsl:output-character character="&#x26;" string="\&amp;"/>
<xsl:output-character character="&#x25;" string="\%"/>
<xsl:output-character character="&#x2E0E;" string="%"/>
<xsl:output-character character="&#x2E0F;" string="&amp;"/>
</xsl:character-map>

<xsl:strip-space elements="*"/>
Expand Down Expand Up @@ -137,39 +138,37 @@ contexts, a double replacement is performed.
</xsl:template>

<xsl:template match="tei:body//tei:quote">
<xsl:text>\begin{EOAquote}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAquote}</xsl:text>
<xsl:text>\begin{EOAquote}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAquote}</xsl:text>
</xsl:template>

<xsl:template match="tei:body//tei:abstract">
<xsl:text>\begin{EOAabstract}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAabstract}</xsl:text>
<xsl:text>\begin{EOAabstract}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAabstract}</xsl:text>
</xsl:template>


<xsl:template match="tei:body//tei:p[not(ancestor::tei:note)]">
<!--
<xsl:choose>
<xsl:when test="@type='quote'">
<xsl:text>\begin{EOAquote}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAquote}</xsl:text>
</xsl:when>
<xsl:when test="@type='abstract'">
<xsl:text>\begin{EOAabstract}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAabstract}</xsl:text>
<!-- thanks: https://stackoverflow.com/questions/28984806/xsl-check-immediate-preceding-sibling#28985405 -->
<xsl:when test="preceding-sibling::*[1][self::tei:abstract]">
<xsl:text>&#x000a;&#x000a;\noindent </xsl:text>
<xsl:apply-templates />
</xsl:when>
<!--
<xsl:when test="@type='abstract'">
<xsl:text>\begin{EOAabstract}</xsl:text>
<xsl:apply-templates/>
<xsl:text>\end{EOAabstract}</xsl:text>
</xsl:when>
-->
<xsl:otherwise>
-->
<xsl:text>&#x000a;&#x000a;</xsl:text>
<xsl:apply-templates />
<!--
</xsl:otherwise>
</xsl:choose>
-->
</xsl:template>

<xsl:template match="//tei:foreign">
Expand Down Expand Up @@ -197,6 +196,72 @@ contexts, a double replacement is performed.
</xsl:choose>
</xsl:template>

<xsl:template match="//tei:table">
<xsl:variable name="number_cells" as="xs:integer*">
<xsl:value-of select="count(./tei:row[1]/tei:cell)"/>
</xsl:variable>
<xsl:text>&#x000a;&#x000a;\begin{EOAtable}</xsl:text>
<xsl:choose>
<xsl:when test="@rend='blank'">
<xsl:text>[blank]</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:text>{</xsl:text>
<xsl:for-each select="1 to $number_cells">L{4cm} </xsl:for-each>
<xsl:text>} </xsl:text>
<xsl:choose>
<xsl:when test="@n='nonumber'">
<xsl:text>{nonumber}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="tablehead"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>{</xsl:text>
<xsl:value-of select="@xml:id"/>
<xsl:text>}</xsl:text>
<xsl:choose>
<xsl:when test="$strictfloats">
<xsl:text>{!ht}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>{ht}</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="./tei:row"/>
<xsl:text>&#x000a;\end{EOAtable}&#x000a;</xsl:text>
</xsl:template>

<xsl:template name="tablehead">
<xsl:text>&#x000a; {</xsl:text>
<xsl:apply-templates select="./tei:head"/>
<xsl:text>}</xsl:text>
</xsl:template>

<xsl:template match="//tei:row">
<xsl:choose>
<xsl:when test="@role='label'">
<xsl:text>&#x000a;\EOAtablehead{</xsl:text>
<xsl:apply-templates/>
<xsl:text>} </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&#x000a; </xsl:text>
<xsl:apply-templates/>
<xsl:text>\\ </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="//tei:cell/tei:lb">
<xsl:text>\newline </xsl:text>
</xsl:template>

<xsl:template match="//tei:cell[preceding-sibling::tei:cell]">
<xsl:text>⸏ </xsl:text>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="//tei:hi[@rend='italic']" >
<xsl:text>\EOAemph{</xsl:text>
<xsl:apply-templates />
Expand Down Expand Up @@ -393,7 +458,7 @@ contexts, a double replacement is performed.
<xsl:text>{66}</xsl:text>
<!-- place needs to be adjusted -->
<xsl:choose>
<xsl:when test="$strictfigures">
<xsl:when test="$strictfloats">
<xsl:text>{!ht}</xsl:text>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -644,7 +709,7 @@ contexts, a double replacement is performed.
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:text>}</xsl:text>
<xsl:text>}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'No chapter author: ', node())" />
Expand Down

0 comments on commit 53e87c4

Please sign in to comment.