From: Hypolite Petovan Date: Sun, 10 Mar 2019 04:28:50 +0000 (-0500) Subject: Add new Content\Text\MarkdownParser X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4d70e3282990a6c8f7216c92b9eb2f8b4f1828cd;p=friendica.git Add new Content\Text\MarkdownParser - Add autolinker to MarkdownParser->doAutoLinks() - Set hashtag_protection and url_filter_func properties of MarkdownParser --- diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php index e3e2cd3ac9..a715de7e97 100644 --- a/src/Content/Text/Markdown.php +++ b/src/Content/Text/Markdown.php @@ -9,7 +9,6 @@ namespace Friendica\Content\Text; use Friendica\BaseObject; use Friendica\Core\System; use Friendica\Model\Contact; -use Michelf\MarkdownExtra; /** * Friendica-specific usage of Markdown @@ -31,11 +30,18 @@ class Markdown extends BaseObject public static function convert($text, $hardwrap = true) { $stamp1 = microtime(true); - $MarkdownParser = new MarkdownExtra(); - $MarkdownParser->hard_wrap = $hardwrap; - $MarkdownParser->code_class_prefix = 'language-'; + $MarkdownParser = new MarkdownParser(); + $MarkdownParser->code_class_prefix = 'language-'; + $MarkdownParser->hard_wrap = $hardwrap; + $MarkdownParser->hashtag_protection = true; + $MarkdownParser->url_filter_func = function ($url) { + if (strpos($url, '#') === 0) { + $url = ltrim($_SERVER['REQUEST_URI'], '/') . $url; + } + return $url; + }; + $html = $MarkdownParser->transform($text); - $html = preg_replace('/