]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Text/HTML.php
Add missing copyright text
[friendica.git] / src / Content / Text / HTML.php
index e65c89523a7f70ca094712bdd573baf8b932432c..4eed07718d861d89f8de1807055ab2dd58d01e69 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -143,6 +143,7 @@ class HTML
         */
        public static function toBBCode($message, $basepath = '')
        {
+               DI::profiler()->startRecording('rendering');
                $message = str_replace("\r", "", $message);
 
                $message = Strings::performWithEscapedBlocks($message, '#<pre><code.*</code></pre>#iUs', function ($message) {
@@ -385,7 +386,7 @@ class HTML
                                        $prefix = '[code=' . $matches[1] . ']';
                                }
 
-                               return $prefix . PHP_EOL . trim($matches[2]) . PHP_EOL . '[/code]';
+                               return $prefix . "\n" . html_entity_decode($matches[2]) . "\n" . '[/code]';
                        },
                        $message
                );
@@ -396,6 +397,7 @@ class HTML
                        $message = self::qualifyURLs($message, $basepath);
                }
 
+               DI::profiler()->stopRecording();
                return $message;
        }
 
@@ -585,6 +587,7 @@ class HTML
         */
        public static function toPlaintext(string $html, $wraplength = 75, $compact = false)
        {
+               DI::profiler()->startRecording('rendering');
                $message = str_replace("\r", "", $html);
 
                $doc = new DOMDocument();
@@ -593,6 +596,7 @@ class HTML
                $message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
 
                if (empty($message)) {
+                       DI::profiler()->stopRecording();
                        return '';
                }
 
@@ -606,6 +610,7 @@ class HTML
                $urls = self::collectURLs($message);
 
                if (empty($message)) {
+                       DI::profiler()->stopRecording();
                        return '';
                }
 
@@ -689,6 +694,7 @@ class HTML
 
                $message = self::quoteLevel(trim($message), $wraplength);
 
+               DI::profiler()->stopRecording();
                return trim($message);
        }
 
@@ -701,9 +707,11 @@ class HTML
         */
        public static function toMarkdown($html)
        {
+               DI::profiler()->startRecording('rendering');
                $converter = new HtmlConverter(['hard_break' => true]);
                $markdown = $converter->convert($html);
 
+               DI::profiler()->stopRecording();
                return $markdown;
        }
 
@@ -776,16 +784,6 @@ class HTML
                return $text;
        }
 
-       /**
-        * return div element with class 'clear'
-        * @return string
-        * @deprecated
-        */
-       public static function clearDiv()
-       {
-               return '<div class="clear"></div>';
-       }
-
        /**
         * Loader for infinite scrolling
         *