Created
January 7, 2012 22:37
-
-
Save mjaschen/1576311 to your computer and use it in GitHub Desktop.
XHTML to BBCode
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
<?xml version="1.0" encoding="utf-8" ?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="text" /> | |
<xsl:template match="a"> [url=<xsl:value-of select="@href" />]<xsl:apply-templates />[/url] </xsl:template> | |
<xsl:template match="img"> [img]<xsl:value-of select="@src" />[/img] </xsl:template> | |
<xsl:template match="b|strong"> [b]<xsl:apply-templates />[/b] </xsl:template> | |
<xsl:template match="i|em"> [i]<xsl:apply-templates />[/i] </xsl:template> | |
<xsl:template match="text()"><xsl:value-of select="normalize-space(.)"/></xsl:template> | |
<xsl:template match="ol"> [list=1]<xsl:apply-templates />[/list] </xsl:template> | |
<xsl:template match="ul"> [list]<xsl:apply-templates />[/list] </xsl:template> | |
<xsl:template match="li"> [*]<xsl:apply-templates /> </xsl:template> | |
<xsl:template match="br"> <xsl:text>
</xsl:text> </xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment