mirror of
https://github.com/jawira/emoji-catalog.git
synced 2023-08-10 21:12:49 +03:00
5f5971badb
Builfile wasn't improved as requested by ticket, however Emoji class has docblock with more details about Emoji.
117 lines
4.3 KiB
XML
117 lines
4.3 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
|
|
<xsl:output method="text" version="2.0" encoding="UTF-8" indent="no"/>
|
|
|
|
<xsl:template match="/">
|
|
<xsl:for-each select="//table//tr[./td//img]">
|
|
<xsl:text> /** </xsl:text>
|
|
<xsl:text> * </xsl:text>
|
|
<xsl:call-template name="get-name"/>
|
|
<xsl:text> </xsl:text>
|
|
<xsl:text> * </xsl:text>
|
|
<xsl:text> * Code point(s): </xsl:text>
|
|
<xsl:call-template name="get-code"/>
|
|
<xsl:text> </xsl:text>
|
|
<xsl:text> */ </xsl:text>
|
|
<xsl:text> const </xsl:text>
|
|
<xsl:call-template name="get-constant-name"/>
|
|
<xsl:text> = "</xsl:text>
|
|
<xsl:call-template name="get-alt"/>
|
|
<xsl:text>"; </xsl:text>
|
|
</xsl:for-each>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="get-code">
|
|
<xsl:value-of select="./td[2]//a/text()"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="get-name">
|
|
<xsl:variable name="short-name" select="./td[last()]/text()"/>
|
|
<xsl:variable name="removable" select="'⊛⊖'"/>
|
|
<xsl:variable name="cleaned" select="translate($short-name, $removable, '')"/>
|
|
<xsl:value-of select="normalize-space($cleaned)"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="get-alt">
|
|
<xsl:value-of select="./td[3]/text()"/>
|
|
</xsl:template>
|
|
|
|
<xsl:template name="get-constant-name">
|
|
<xsl:variable name="short-name" select="./td[last()]/text()"/>
|
|
<xsl:variable name="removable" select="':;.,⊛’!“”()⊖'"/>
|
|
<xsl:variable name="cleaned" select="translate($short-name, $removable, '')"/>
|
|
<xsl:variable name="lowercase" select="'Åãabcçdeéfghíijklmnoôpqrstuvwxyz-&'"/>
|
|
<xsl:variable name="uppercase" select="'AAABCCDEEFGHIIJKLMNOOPQRSTUVWXYZ N'"/>
|
|
<xsl:variable name="no-accents" select="translate($cleaned, $lowercase, $uppercase)"/>
|
|
<xsl:variable name="normalized" select="normalize-space($no-accents)"/>
|
|
<xsl:variable name="no-spaces" select="translate($normalized, ' ', '_')"/>
|
|
|
|
<xsl:variable name="no-1st">
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="$no-spaces"/>
|
|
<xsl:with-param name="replace" select="'1ST'"/>
|
|
<xsl:with-param name="by" select="'FIRST'"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:variable name="no-2nd">
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="$no-1st"/>
|
|
<xsl:with-param name="replace" select="'2ND'"/>
|
|
<xsl:with-param name="by" select="'SECOND'"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:variable name="no-3rd">
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="$no-2nd"/>
|
|
<xsl:with-param name="replace" select="'3RD'"/>
|
|
<xsl:with-param name="by" select="'THIRD'"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:variable name="no-number">
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="$no-3rd"/>
|
|
<xsl:with-param name="replace" select="'#'"/>
|
|
<xsl:with-param name="by" select="'NUMBER'"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:variable name="no-asterisk">
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="$no-number"/>
|
|
<xsl:with-param name="replace" select="'*'"/>
|
|
<xsl:with-param name="by" select="'ASTERISK'"/>
|
|
</xsl:call-template>
|
|
</xsl:variable>
|
|
|
|
<xsl:value-of select="$no-asterisk"/>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
<!-- http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx -->
|
|
<xsl:template name="string-replace-all">
|
|
<xsl:param name="text"/>
|
|
<xsl:param name="replace"/>
|
|
<xsl:param name="by"/>
|
|
<xsl:choose>
|
|
<xsl:when test="contains($text, $replace)">
|
|
<xsl:value-of select="substring-before($text,$replace)"/>
|
|
<xsl:value-of select="$by"/>
|
|
<xsl:call-template name="string-replace-all">
|
|
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
|
|
<xsl:with-param name="replace" select="$replace"/>
|
|
<xsl:with-param name="by" select="$by"/>
|
|
</xsl:call-template>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="$text"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:template>
|
|
|
|
</xsl:stylesheet>
|