X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FText%2FBBCode.php;h=66f4190b287eca731fe8b465dea18da5504b0feb;hb=5a02e39a65f8f685440228cc1d36738cbe15f32b;hp=b403b1f349e1a8a0ef8a04346790a29f75840cd1;hpb=ba4f368b451144230af4e7a604113cf1e1d17717;p=friendica.git diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index b403b1f349..66f4190b28 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -25,7 +25,6 @@ use Friendica\Util\Map; use Friendica\Util\Network; use Friendica\Util\ParseUrl; use Friendica\Util\Proxy as ProxyUtils; -use League\HTMLToMarkdown\HtmlConverter; class BBCode extends BaseObject { @@ -348,7 +347,7 @@ class BBCode extends BaseObject */ public static function toPlaintext($text, $keep_urls = true) { - $naked_text = preg_replace('/\[(.+?)\]/','', $text); + $naked_text = preg_replace('/\[(.+?)\]\s*/','', $text); if (!$keep_urls) { $naked_text = preg_replace('#https?\://[^\s<]+[^\s\.\)]#i', '', $naked_text); } @@ -1061,11 +1060,11 @@ class BBCode extends BaseObject $ch = @curl_init($match[1]); @curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - @curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent()); + @curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent()); @curl_exec($ch); $curl_info = @curl_getinfo($ch); - $a->save_timestamp($stamp1, "network"); + $a->saveTimestamp($stamp1, "network"); if (substr($curl_info["content_type"], 0, 6) == "image/") { $text = "[url=" . $match[1] . "]" . $match[1] . "[/url]"; @@ -1120,11 +1119,11 @@ class BBCode extends BaseObject $ch = @curl_init($match[1]); @curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - @curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent()); + @curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent()); @curl_exec($ch); $curl_info = @curl_getinfo($ch); - $a->save_timestamp($stamp1, "network"); + $a->saveTimestamp($stamp1, "network"); // if its a link to a picture then embed this picture if (substr($curl_info["content_type"], 0, 6) == "image/") { @@ -1942,13 +1941,12 @@ class BBCode extends BaseObject $stamp1 = microtime(true); // Now convert HTML to Markdown - $converter = new HtmlConverter(); - $text = $converter->convert($text); + $text = HTML::toMarkdown($text); // unmask the special chars back to HTML $text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $text); - $a->save_timestamp($stamp1, "parser"); + $a->saveTimestamp($stamp1, "parser"); // Libertree has a problem with escaped hashtags. $text = str_replace(['\#'], ['#'], $text);