Skip to content

Commit

Permalink
Give text an id if inside a group
Browse files Browse the repository at this point in the history
Don't set href labels if the url is empty.
  • Loading branch information
jhellingman committed Mar 14, 2024
1 parent d83520a commit 9f3c48d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
12 changes: 11 additions & 1 deletion modules/divisions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@
<!-- Main subdivisions of work -->

<xsl:template match="text">
<xsl:apply-templates/>
<xsl:choose>
<xsl:when test="parent::group">
<div>
<xsl:copy-of select="f:set-lang-id-attributes(.)"/>
<xsl:apply-templates/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>

<xsl:if test="not(ancestor::group) and f:is-set('facsimile.enable') and f:is-set('facsimile.wrapper.enable')">
<xsl:apply-templates select="//pb[@facs]" mode="facsimile"/>
Expand Down
2 changes: 1 addition & 1 deletion modules/references-func.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<xsl:variable name="protocol" select="if (contains($url, ':')) then substring-before($url, ':') else ''"/>
<xsl:choose>
<xsl:when test="$linkClasses($protocol)"><xsl:value-of select="$linkClasses($protocol)"/></xsl:when>
<xsl:when test="starts-with($url, 'audio/')">audiolink</xsl:when>
<xsl:when test="starts-with($url, 'audio/') or starts-with($url, 'music/')">audiolink</xsl:when>
<xsl:otherwise>exlink</xsl:otherwise>
</xsl:choose>
</xsl:function>
Expand Down
25 changes: 15 additions & 10 deletions modules/references.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,25 @@
<xsl:text> </xsl:text>
<xsl:value-of select="f:generate-class-name(.)"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="f:translate-xref-title($url)"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="f:translate-xref-url($url, substring(f:get-document-lang(), 1, 2))"/>
</xsl:attribute>
<xsl:if test="@rel">
<xsl:attribute name="rel"><xsl:value-of select="@rel"/></xsl:attribute>
</xsl:if>

<xsl:copy-of select="f:create-attribute-if-present('title', f:translate-xref-title($url))"/>
<xsl:copy-of select="f:create-attribute-if-present('href', f:translate-xref-url($url, substring(f:get-document-lang(), 1, 2)))"/>
<xsl:copy-of select="f:create-attribute-if-present('rel', @rel)"/>
<xsl:apply-templates/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:function name="f:create-attribute-if-present">
<xsl:param name="name" as="xs:string"/>
<xsl:param name="value" as="xs:string?"/>

<xsl:if test="$value != ''">
<xsl:attribute name="{$name}">
<xsl:value-of select="$value"/>
</xsl:attribute>
</xsl:if>
</xsl:function>

</xsl:stylesheet>

0 comments on commit 9f3c48d

Please sign in to comment.