X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FText%2FHTML.php;h=c256717a159c972fff3bdac91af123fe6486dcce;hb=acd1caa1144f558002214d5991f551f232482200;hp=9a9f24f97f48e1a5542836817d05f1059fcad279;hpb=96ed7525b733111dbeca2cd672f85188ce369fef;p=friendica.git diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 9a9f24f97f..c256717a15 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -11,6 +11,7 @@ use DOMXPath; use Friendica\Core\Addon; use Friendica\Util\Network; use Friendica\Util\XML; +use League\HTMLToMarkdown\HtmlConverter; class HTML { @@ -672,4 +673,19 @@ 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; + } }