From: Antonio Ospite <ao2@ao2.it>
Date: Fri, 23 Feb 2018 14:34:02 +0000 (+0100)
Subject: rss_converter_twitter.com.xsl: preserve spaces in tweet content
X-Git-Tag: v1.2.0~3
X-Git-Url: https://git.ao2.it/tweeper.git/commitdiff_plain/db2757cc107da3869ce3cc930038ae0963a2b8d7

rss_converter_twitter.com.xsl: preserve spaces in tweet content

Wrap the tweet content into a span element with a CSS style attribute
set to "white-space: pre-wrap", this allows to have the spaces rendered
like on the twitter web page: with spaces and newlines preserved.

This is especially desirable if the tweet content contains any ASCII
art, like in https://twitter.com/sarahjeong/status/955651919279722496
---

diff --git a/src/rss_converter_twitter.com.xsl b/src/rss_converter_twitter.com.xsl
index b6b4257..44a0416 100644
--- a/src/rss_converter_twitter.com.xsl
+++ b/src/rss_converter_twitter.com.xsl
@@ -153,7 +153,10 @@
                     <xsl:text>(Video)</xsl:text>
                     <xsl:element name="br"/>
                 </xsl:if>
-                <xsl:apply-templates select="$item-content/node()"/>
+                <xsl:element name="span">
+                    <xsl:attribute name="style">white-space: pre-wrap;</xsl:attribute>
+                    <xsl:apply-templates select="$item-content/node()"/>
+                </xsl:element>
                 <xsl:apply-templates select="$item-media/node()"/>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>