use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Proxy as ProxyUtils;
-use League\HTMLToMarkdown\HtmlConverter;
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);
use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\XML;
+use League\HTMLToMarkdown\HtmlConverter;
class HTML
{
return trim($message);
}
+
+ /**
+ * Converts provided HTML code to Markdown. The hardwrap parameter maximizes
+ * compatibility with Diaspora in spite of the Markdown standards.
+ *
+ * @param string $html
+ * @return string
+ */
+ public static function toMarkdown($html)
+ {
+ $converter = new HtmlConverter(['hard_break' => true]);
+ $markdown = $converter->convert($html);
+
+ return $markdown;
+ }
}