Skip to content

Commit

Permalink
Fixed: Better date display
Browse files Browse the repository at this point in the history
Append a calendar abbreivation instead of trying to build a sentence, which in some cases made it more confusing. This should be an improvement ~95% of the time.
  • Loading branch information
andrew-morrison committed Mar 20, 2018
1 parent 21e1bc3 commit 5b5e71b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions processing/convert2HTML.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,24 @@



<!-- When two dates in different calendars are given, add some text to explain the difference. -->
<xsl:template match="origin//origDate[@calendar and preceding-sibling::origDate[not(@calendar = current()/@calendar)]]">
<!-- Append the calendar if it does not appear to have been mentioned in the origDate text -->
<xsl:template match="origDate[@calendar]">
<span class="{name()}">
<xsl:text>(</xsl:text>
<xsl:apply-templates/>
<xsl:text> in the </xsl:text>
<xsl:value-of select="replace(@calendar, '#', '')"/>
<xsl:text> calendar)</xsl:text>
<xsl:choose>
<xsl:when test="@calendar = '#Hijri-qamari' and not(matches(string-join(.//text(), ''), '[\d\s](H|AH|A\.H|Hijri)'))">
<xsl:text> AH</xsl:text>
</xsl:when>
<xsl:when test="@calendar = '#Gregorian' and not(matches(string-join(.//text(), ''), '[\d\s](CE|AD|C\.E|A\.D|Gregorian)'))">
<xsl:text> CE</xsl:text>
</xsl:when>
</xsl:choose>
</span>
<xsl:variable name="nextelem" select="following-sibling::*[1]"/>
<xsl:if test="following-sibling::*[self::origDate] and not(following-sibling::node()[1][self::text()][string-length(normalize-space(.)) gt 0])">
<!-- Insert a semi-colon between adjacent dates without text between them -->
<xsl:text>; </xsl:text>
</xsl:if>
</xsl:template>


Expand Down

0 comments on commit 5b5e71b

Please sign in to comment.