Skip to content

Commit

Permalink
Better handling of @Tei:rend for @html:class
Browse files Browse the repository at this point in the history
  • Loading branch information
glorieux-f committed Sep 8, 2024
1 parent 07a45b4 commit 1cfb009
Showing 1 changed file with 65 additions and 48 deletions.
113 changes: 65 additions & 48 deletions tei_html/tei_flow_html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ Sections
<xsl:call-template name="id"/>
</xsl:attribute>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
level<xsl:value-of select="$level + 1"/>
<xsl:if test="@type = 'act' and $verse"> verse</xsl:if>
</xsl:with-param>
Expand Down Expand Up @@ -303,9 +304,10 @@ Sections
<xsl:apply-templates select="tei:pb"/>
<xsl:element name="{$name}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="$verse"> verse </xsl:if>
<xsl:value-of select="../@type"/>
<xsl:if test="$verse"> verse</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:for-each select="preceding-sibling::tei:head[1][@type = 'kicker']">
Expand Down Expand Up @@ -431,19 +433,19 @@ Sections
<xsl:element name="{$el}">
<xsl:variable name="prev" select="preceding-sibling::*[not(self::tei:pb)][not(self::tei:cb)][1]"/>
<xsl:variable name="char1" select="substring( normalize-space(.), 1, 1)"/>
<xsl:variable name="class">
<xsl:variable name="noindent">
<xsl:call-template name="noindent"/>
</xsl:variable>
<xsl:if test="$noindent != ''"> noindent </xsl:if>
<xsl:if test="@n"> no</xsl:if>
<xsl:if test="tei:hi[contains(@rend, 'initial')]">
<xsl:text> </xsl:text>
<xsl:value-of select="tei:hi[starts-with(@rend, 'initial')]/@rend"/>
</xsl:if>
</xsl:variable>
<xsl:call-template name="atts">
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:variable name="noindent">
<xsl:call-template name="noindent"/>
</xsl:variable>
<xsl:if test="$noindent != ''"> noindent </xsl:if>
<xsl:if test="@n"> no</xsl:if>
<xsl:if test="tei:hi[contains(@rend, 'initial')]">
<xsl:text> </xsl:text>
<xsl:value-of select="tei:hi[starts-with(@rend, 'initial')]/@rend"/>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:if test="@n">
<small class="no">
Expand Down Expand Up @@ -519,8 +521,9 @@ Sections
<xsl:otherwise>
<div>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:if test="substring(normalize-space(.), 1, 1) = '*'">star</xsl:if>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="substring(normalize-space(.), 1, 1) = '*'"> star</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates>
Expand Down Expand Up @@ -566,8 +569,9 @@ Sections
</xsl:apply-templates>
<xsl:element name="{$el}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:if test="$none">none</xsl:if>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="$none"> none</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates select="*[local-name() != 'head']">
Expand All @@ -579,8 +583,9 @@ Sections
<xsl:otherwise>
<xsl:element name="{$el}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:if test="$none">none</xsl:if>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="$none"> none</xsl:if>
<xsl:text> </xsl:text>
<!-- bad TEI practice, from odt/tei with -->
<xsl:value-of select="tei:item[1]/@rend"/>
Expand Down Expand Up @@ -768,9 +773,7 @@ Sections
</xsl:when>
<xsl:otherwise>
<dl>
<xsl:call-template name="atts">
<xsl:with-param name="class">dl</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="atts"/>
<xsl:apply-templates>
<xsl:with-param name="from" select="$from"/>
</xsl:apply-templates>
Expand Down Expand Up @@ -868,8 +871,13 @@ Tables
<xsl:param name="from"/>
<table>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:if test="not(@rend)">table</xsl:if>
<xsl:with-param name="rend">
<xsl:choose>
<xsl:when test="@rend">
<xsl:value-of select="@rend"/>
</xsl:when>
<xsl:otherwise>table</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates>
Expand Down Expand Up @@ -942,9 +950,10 @@ Tables
<xsl:param name="from"/>
<div>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="@part">
<xsl:text>part-</xsl:text>
<xsl:text> part-</xsl:text>
<xsl:value-of select="translate(@part, 'fimy', 'FIMY')"/>
</xsl:if>
</xsl:with-param>
Expand Down Expand Up @@ -982,9 +991,10 @@ Tables
<xsl:number/>
</xsl:variable>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="@part">
<xsl:text>part-</xsl:text>
<xsl:text> part-</xsl:text>
<xsl:value-of select="translate(@part, 'fimy', 'FIMY')"/>
</xsl:if>
<xsl:if test="@met">
Expand Down Expand Up @@ -1075,7 +1085,9 @@ Tables
<!-- si @rend est un nom d'élément HTML -->
<xsl:when test="contains( ' b big em i s small strike strong sub sup tt u var ', concat(' ', $rend, ' '))">
<xsl:element name="{$rend}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="atts"/>
<xsl:call-template name="atts">
<xsl:with-param name="rend"/>
</xsl:call-template>
<xsl:apply-templates>
<xsl:with-param name="from" select="$from"/>
</xsl:apply-templates>
Expand Down Expand Up @@ -1131,7 +1143,9 @@ Tables
</xsl:when>
<xsl:when test="starts-with($rend, 'var')">
<var>
<xsl:call-template name="atts"/>
<xsl:call-template name="atts">
<xsl:with-param name="rend" select="substring-after($rend, 'var')"/>
</xsl:call-template>
<xsl:apply-templates>
<xsl:with-param name="from" select="$from"/>
</xsl:apply-templates>
Expand Down Expand Up @@ -1546,12 +1560,12 @@ Tables
<!-- bad link pb, seen in notes -->
<xsl:when test="normalize-space($html) = ''"/>
<xsl:otherwise>
<xsl:variable name="class">
<xsl:if test="starts-with(@target, 'http')">external</xsl:if>
</xsl:variable>
<a>
<xsl:call-template name="atts">
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="starts-with(@target, 'http')"> external</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:copy-of select="$html"/>
</a>
Expand Down Expand Up @@ -2131,7 +2145,10 @@ Elements block or inline level
<xsl:when test="@corresp and contains(@type, 'embed')">
<figure>
<xsl:call-template name="atts">
<xsl:with-param name="class">corresp</xsl:with-param>
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:text> corresp</xsl:text>
</xsl:with-param>
</xsl:call-template>
<figcaption>
<xsl:call-template name="atts"/>
Expand All @@ -2156,7 +2173,8 @@ Elements block or inline level
</xsl:variable>
<xsl:element name="{$el}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:if test="@corresp"> corresp</xsl:if>
</xsl:with-param>
</xsl:call-template>
Expand Down Expand Up @@ -2270,7 +2288,9 @@ Elements block or inline level
</xsl:variable>
<span>
<xsl:call-template name="atts">
<xsl:with-param name="class">
<xsl:with-param name="rend">
<xsl:value-of select="@rend"/>
<xsl:text> </xsl:text>
<xsl:value-of select="translate($key, $idfrom, $idto)"/>
</xsl:with-param>
</xsl:call-template>
Expand All @@ -2292,10 +2312,10 @@ Centralize some html attribute policy, especially for id, and class
-->
<xsl:template name="atts">
<!-- Add some html classes to the automatic ones -->
<xsl:param name="class"/>
<xsl:param name="rend"/>
<!-- Ddelegate class attribution to another template -->
<xsl:call-template name="class">
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="rend" select="$rend"/>
</xsl:call-template>
<!-- Shall we identify element ? -->
<xsl:choose>
Expand Down Expand Up @@ -2327,11 +2347,13 @@ Centralize some html attribute policy, especially for id, and class
</xsl:template>
<!-- Provide automatic classes from TEI names -->
<xsl:template name="class">
<xsl:param name="class"/>
<xsl:param name="rend" select="@rend"/>
<!-- @rend may be used as a free text attribute, be careful -->
<xsl:variable name="value">
<xsl:value-of select="$rend"/>
<!-- Name of the element (except from a list where TEI info will be redundant with HTML name) -->
<xsl:if test="not(contains( ' abbr add code del emph hi q ref row seg ' , concat(' ', local-name(), ' ')))">
<xsl:if test="not(contains( ' abbr add code del emph hi q ref row seg ' , concat(' ', local-name(), ' ')))">
<xsl:text> </xsl:text>
<xsl:value-of select="local-name()"/>
</xsl:if>
<xsl:text> </xsl:text>
Expand All @@ -2351,11 +2373,6 @@ Centralize some html attribute policy, especially for id, and class
<!-- lang is a useful class for some rendering (ex: greek fonts) -->
<xsl:value-of select="@xml:lang"/>
<xsl:text> </xsl:text>
<!-- parameter value -->
<xsl:value-of select="$class"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@rend"/>
<xsl:text> </xsl:text>
<xsl:value-of select="translate(@rendition, '#', '')"/>
</xsl:variable>
<xsl:variable name="norm" select="normalize-space($value)"/>
Expand Down

0 comments on commit 1cfb009

Please sign in to comment.