Skip to content

“white-space: pre” prevents words from wrapping in tweet bodies #456

Closed
@bdesham

Description

@bdesham

I use Granary to generate a JSON Feed for the Twitter account of the Buffalo office of the National Weather Service. This tweet is rendered poorly in Reeder for Mac and iOS: all of the text is put onto one line. This happens because the line has the rule white-space: pre applied, as you can see in the content_html in the JSON Feed entry:

<div style="white-space: pre">Here are some experimental Lake Effect Snow Warning polygons, which narrows down the place and time. The warning for WNY runs from 7PM Friday to 1PM Monday, but we've broken it down into for segments.  For more info, see:
<a href="https://www.weather.gov/buf/lespolygon">weather.gov/buf/lespolygon</a></div>
<p>
<a class="link" href="https://twitter.com/NWSBUFFALO/status/1603518606997716992">
<img class="u-photo" src="https://pbs.twimg.com/media/FkDXqYSUEAEWrFr.png" alt="" />
</a>
</p>
<p>
<a class="link" href="https://twitter.com/NWSBUFFALO/status/1603518606997716992">
<img class="u-photo" src="https://pbs.twimg.com/media/FkDXqYrUUAA0Rjg.png" alt="" />
</a>
</p>
<p>
<a class="link" href="https://twitter.com/NWSBUFFALO/status/1603518606997716992">
<img class="u-photo" src="https://pbs.twimg.com/media/FkDXqZIUUAApaGj.png" alt="" />
</a>
</p>
<p>
<a class="link" href="https://twitter.com/NWSBUFFALO/status/1603518606997716992">
<img class="u-photo" src="https://pbs.twimg.com/media/FkDXqZhUYAAnKPA.png" alt="" />
</a>
</p>

I’m guessing that this style is applied as a result of there being multiple images; other tweets in the feed that have just one image don’t show this rendering problem. In this particular case the desirable thing would be to replace the newline after “see:” with a <br> tag, and to get rid of the white-space: pre, but I know that Twitter and HTML have different ideas of which whitespace should be preserved and I assume this is a way of getting the former’s rules in the latter’s context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions