Skip to content

Commit

Permalink
Only remove list markers up to two characters
Browse files Browse the repository at this point in the history
List markers that are longer than two characters are most likely not
list markers, so leave them alone.
  • Loading branch information
egli committed Mar 29, 2022
1 parent 6eb103e commit d6b84c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1486,22 +1486,22 @@
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when
test="self::dtbook:* and not(preceding-sibling::node()[self::* or self::text()[normalize-space()]]) and not(text()[1]/preceding-sibling::*) and matches(text()[1],'^(\w+\.|•)')">
<xsl:if test="* or normalize-space(replace(text()[1],'^(\w+\.|•) ','')) != ''">
test="self::dtbook:* and not(preceding-sibling::node()[self::* or self::text()[normalize-space()]]) and not(text()[1]/preceding-sibling::*) and matches(text()[1],'^([0-9a-zA-Z]{1,2}\.|•)')">
<xsl:if test="* or normalize-space(replace(text()[1],'^([0-9a-zA-Z]{1,2}\.|•) ','')) != ''">
<xsl:variable name="element">
<xsl:apply-templates select="."/>
</xsl:variable>
<xsl:for-each select="$element/*">
<xsl:copy exclude-result-prefixes="#all">
<xsl:copy-of select="@*" exclude-result-prefixes="#all"/>
<xsl:value-of select="replace(text()[1],'^(\w+\.|•) ','')"/>
<xsl:value-of select="replace(text()[1],'^([0-9a-zA-Z]\.|•) ','')"/>
<xsl:copy-of select="node() except text()[1]" exclude-result-prefixes="#all"/>
</xsl:copy>
</xsl:for-each>
</xsl:if>
</xsl:when>
<xsl:when test="self::text() and not(preceding-sibling::node()[self::* or self::text()[normalize-space()]]) and matches(.,'^(\w+\.|•)')">
<xsl:value-of select="replace(.,'^(\w+\.|•) ','')"/>
<xsl:when test="self::text() and not(preceding-sibling::node()[self::* or self::text()[normalize-space()]]) and matches(.,'^([0-9a-zA-Z]{1,2}\.|•)')">
<xsl:value-of select="replace(.,'^([0-9a-zA-Z]{1,2}\.|•) ','')"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@
<x:expect label="the resulting list should be wrapped in a section element containing the hd">
<html:section id="...">
<html:h1 id="...">TEXT</html:h1>
<html:ol id="..." class="list-style-type-none">...</html:ol>
<html:ol id="..." class="list-style-type-none preformatted">...</html:ol>
</html:section>
</x:expect>
</x:scenario>
Expand Down Expand Up @@ -2607,7 +2607,7 @@
</dtbook:list>
</x:context>
<x:expect label="the type of list should be detected, the list markers removed and the value should be correct">
<html:ol id="...">
<html:ol id="..." class="preformatted">
<html:li id="..." value="2">Halten Sie
Sie es tunlichst, der Öffentlichkeit jene Hautfladen auch bekannt als Bingofladen, die unter den Oberarmen hängen, zuzumuten. Dasselbe gilt für die Röllchen unter der Achsel, zwischen Oberarm und Oberkörper.</html:li>
</html:ol>
Expand Down Expand Up @@ -3514,17 +3514,17 @@
</x:expect>
</x:scenario>

<x:scenario label="when processing a li element enumerated with letters of with a string length &gt; 1">
<x:scenario label="when processing a li element enumerated with letters with a string length &gt; 2">
<x:context>
<dtbook:list type="pl" depth="1">
<dtbook:li>aa. ONE</dtbook:li>
<dtbook:li>bbb. TWO</dtbook:li>
</dtbook:list>
</x:context>
<x:expect label="the letters should be correctly parsed">
<x:expect label="the list markers should not be removed">
<html:ol id="..." type="a" class="preformatted">
<html:li id="..." value="27">ONE</html:li>
<html:li id="..." value="1406">TWO</html:li>
<html:li id="..." value="1406">bbb. TWO</html:li>
</html:ol>
</x:expect>
</x:scenario>
Expand Down

0 comments on commit d6b84c7

Please sign in to comment.