Skip to content

Commit

Permalink
reverted last test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
polypunkt committed May 27, 2021
1 parent 2f996eb commit 1b50761
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions xsl/docx2tex-preprocess.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,25 @@
</para>
</xsl:template>

<!-- move leading and trailing whitespace out of phrase #13913 doesn't work well with nested phrases -->
<!-- move leading and trailing whitespace out of phrase #13913 -->

<xsl:template match="text()[parent::phrase]
[(matches(., '^(\s+).+') and ../node()[1][self::text()]) or (matches(., '.+(\s+)$') and ../node()[last()][self::text()])] (: leading or trailing whitespace :)
<xsl:template match="text()[parent::phrase][matches(., '^(\s+)?.+(\s+)?$')] (: leading or trailing whitespace :)
[string-length(normalize-space(.)) gt 0]
[not(following-sibling::node()[1][not(matches(., '^\s'))]) and
not(preceding-sibling::node()[1][not(matches(., '\s$'))])]
[not(following-sibling::text()[1][not(matches(., '^\s'))]) and
not(preceding-sibling::text()[1][not(matches(., '\s$'))])]
[not(parent::phrase/@xml:space eq 'preserve')]
[not(following-sibling::*[1][self::*:inlineequation])]" mode="docx2tex-preprocess">
<xsl:param name="spaced" as="xs:boolean?" tunnel="no"/>
<xsl:value-of select="if ($spaced) then normalize-space(.) else ."/>
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>

<xsl:template match="phrase[matches(., '^(\s+).+|.+(\s+)$')][string-length(normalize-space(.)) gt 0]" mode="docx2tex-preprocess" priority="5">
<xsl:if test="matches(., '^\s+') and node()[1][self::text()]">
<xsl:template match="phrase[matches(., '^(\s+)?.+(\s+)?$')][string-length(normalize-space(.)) gt 0]" mode="docx2tex-preprocess">
<xsl:if test="matches(., '^\s+')">
<xsl:value-of select="replace(., '^(\s+).+', '$1')"/>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="@*, node()" mode="#current">
<xsl:with-param name="spaced" select="true()" tunnel="no" as="xs:boolean"/>
</xsl:apply-templates>
<xsl:apply-templates select="@*, node()" mode="#current"/>
</xsl:copy>
<xsl:if test="matches(., '\s+$') and node()[last()][self::text()]">
<xsl:if test="matches(., '\s+$')">
<xsl:value-of select="replace(., '.+(\s+)$', '$1')"/>
</xsl:if>
</xsl:template>
Expand Down

0 comments on commit 1b50761

Please sign in to comment.