rss_converter_twitter.com.xsl: cleanup titles
authorAntonio Ospite <ao2@ao2.it>
Wed, 18 May 2016 20:41:54 +0000 (22:41 +0200)
committerAntonio Ospite <ao2@ao2.it>
Fri, 20 May 2016 13:03:40 +0000 (15:03 +0200)
Prepend a white space in front of some URLs (those not preceded by an
open parenthesis) because otherwise they get rendered attached to the
preceding text.

Also strip non-breaking spaces and horizontal ellipses, they are not
needed because the RSS feed show the full URLs.

rss_converter_twitter.com.xsl

index 6ef86dd..b7c7124 100644 (file)
         <xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
         <item>
             <title>
         <xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
         <item>
             <title>
-                <xsl:value-of select="concat($user-name, ': ', $item-content)"/>
+                <xsl:value-of select="concat($user-name, ': ')"/>
+                <!--
+                     Prepend a space in front of the URLs which are not
+                     preceded by an open parenthesis, for aestethic reasons.
+                     Also, regex, I know: http://xkcd.com/1171/
+                -->
+                <xsl:variable
+                    name="processed-title"
+                    select="php:function('preg_replace', '@((?&lt;!\()(?:http[s]?://|pic.twitter.com))@', ' \1', string($item-content))"/>
+                <!-- Also strip &nbsp; and &hellip; -->
+                <xsl:value-of select="normalize-space(translate($processed-title, '&#xA0;&#x2026;', ''))"/>
             </title>
             <link>
                 <xsl:value-of select="$item-permalink"/>
             </title>
             <link>
                 <xsl:value-of select="$item-permalink"/>