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