-require_once("include/oembed.php");
-require_once("include/event.php");
-require_once("library/markdown.php");
-require_once("include/html2bbcode.php");
-require_once("include/bbcode.php");
-require_once("library/html-to-markdown/HTML_To_Markdown.php");
-
-
-// we don't want to support a bbcode specific markdown interpreter
-// and the markdown library we have is pretty good, but provides HTML output.
-// So we'll use that to convert to HTML, then convert the HTML back to bbcode,
-// and then clean up a few Diaspora specific constructs.
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Network\Probe;
+
+use League\HTMLToMarkdown\HtmlConverter;
+
+require_once 'include/oembed.php';
+require_once 'include/event.php';
+require_once 'library/markdown.php';
+require_once 'include/html2bbcode.php';
+require_once 'include/bbcode.php';
+
+/**
+ * @brief Callback function to replace a Diaspora style mention in a mention for Friendica
+ *
+ * @param array $match Matching values for the callback
+ * @return string Replaced mention
+ */
+function diaspora_mention2bb($match) {
+ if ($match[2] == '') {
+ return;
+ }
+
+ $data = get_contact_details_by_addr($match[2]);
+
+ $name = $match[1];
+
+ if ($name == '') {
+ $name = $data['name'];
+ }
+
+ return '@[url=' . $data['url'] . ']' . $name . '[/url]';
+}