Created
August 31, 2020 19:48
-
-
Save quirijnslings/1819aa66471e57816c8e14a186424b0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output> | |
<xsl:template match="/ | node() | @*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node() | @*"></xsl:apply-templates> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="*[ (self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) and not(following::node()[not( (self::text() or self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) )]) ]"> | |
<!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks --> | |
</xsl:template> | |
<xsl:template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]"> | |
<!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space --> | |
<xsl:text></xsl:text> | |
</xsl:template> | |
<xsl:template match="@class[starts-with(string(.),'Mso')]"/> | |
<xsl:template match="@class[starts-with(string(.),'xl')]"/> | |
<xsl:template match="style|@style|comment()|@xml:lang|@lang"/> | |
<xsl:template match="@cellspacing|@cellpadding|colgroup"/> | |
<xsl:template match="@width[parent::table]|@border[parent::table]"/> | |
<xsl:template match="@width[parent::td]|@height[parent::td]"/> | |
<xsl:template match="span"> | |
<xsl:apply-templates select="node() | @*"/> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment