diff --git a/include/class.format.php b/include/class.format.php
index 407c9916b55cba4d31d2e73630318fe3ae77ee4b..be314d4675e76c5a422332fd8c85ec1fccdbc870 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -164,7 +164,7 @@ class Format {
             $html = $doc->saveHTML();
             $html = preg_replace('`^<!DOCTYPE.+?>|<\?xml .+?>|</?html>|</?body>|</?head>|<meta .+?/?>`', '', $html); # <?php
         }
-        return preg_replace('`^<div>|</div>$`', '', $html);
+        return preg_replace('`^<div>|</div>$`', '', trim($html));
     }
 
     function html($html, $config=array()) {