1
0
Fork 0
forked from blallo/rss-bridge

[TwitterBridge] Fix missing spaces

This commit improves readability of tweets by adding spaces before
anchors in the text.

- Hide "invisible" tags which were not rendered hidden because of
missing CSS.
- Fix spacing between anchors

Reported via #539
This commit is contained in:
logmanoriginal 2017-06-18 23:18:41 +02:00
parent 9c78362fd7
commit d81b61ccfa

View file

@ -100,6 +100,11 @@ class TwitterBridge extends BridgeAbstract {
continue;
}
// remove 'invisible' content
foreach($tweet->find('.invisible') as $invisible){
$invisible->outertext = '';
}
$item = array();
// extract username and sanitize
$item['username'] = $tweet->getAttribute('data-screen-name');
@ -116,13 +121,7 @@ class TwitterBridge extends BridgeAbstract {
// extract tweet timestamp
$item['timestamp'] = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time');
// generate the title
$item['title'] = strip_tags(
html_entity_decode(
$tweet->find('p.js-tweet-text', 0)->innertext,
ENT_QUOTES,
'UTF-8'
)
);
$item['title'] = $this->fixAnchorSpacing(strip_tags($tweet->find('p.js-tweet-text', 0), '<a>'));
$this->processContentLinks($tweet);
$this->processEmojis($tweet);
@ -134,6 +133,9 @@ class TwitterBridge extends BridgeAbstract {
$tweet->find('p.js-tweet-text', 0)->innertext
);
// fix anchors missing spaces in-between
$cleanedTweet = $this->fixAnchorSpacing($cleanedTweet);
// Add picture to content
$picture_html = '';
if(!$hidePictures){
@ -245,6 +247,15 @@ EOD;
}
}
private function fixAnchorSpacing($content){
// fix anchors missing spaces in-between
return str_replace(
'<a',
' <a',
$content
);
}
private function getImageURI($tweet){
// Find media in tweet
$container = $tweet->find('div.AdaptiveMedia-container', 0);