From d81b61ccfa19e2c685df7acfb7c4306b7b775846 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 18 Jun 2017 23:18:41 +0200 Subject: [PATCH] [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 --- bridges/TwitterBridge.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 081cd2a..b485f08 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -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), '')); $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( + 'find('div.AdaptiveMedia-container', 0);