diff --git a/mastodonapi.php b/mastodonapi.php index 5218619..02471a5 100644 --- a/mastodonapi.php +++ b/mastodonapi.php @@ -199,26 +199,21 @@ class YellowMastodonAPI { return trim(preg_replace('/[^a-z0-9-]+/', '', $slug), '-'); } -private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor, $origUrl, $yellowAuthor, $yellowTag, $images = [], $alts = []) { - $date = new DateTime($dateTime); - $formattedDate = $date->format('Y-m-d'); - $formattedTime = $date->format('H:i:s'); + private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor, $origUrl, $yellowAuthor, $yellowTag, $images = [], $alts = []) { + $date = new DateTime($dateTime); + $formattedDate = $date->format('Y-m-d'); + $formattedTime = $date->format('H:i:s'); - $content = strip_tags($html); - $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $content = strip_tags($html); + $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); - $hashtagString = ''; - // Finde den gesamten Block der Tags am Ende des Strings - if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) { - // Entferne den Tag-Block aus dem Content - $content = substr($content, 0, -strlen($matches[0])); - - // Finde alle einzelnen Tags im extrahierten Block - if (preg_match_all('/#(\w+)/u', $matches[0], $tags)) { - // Füge die Tags mit einem Leerzeichen zusammen und stelle sicher, dass sie ein # haben - $hashtagString = "\n" . implode(' ', $tags[0]); + $hashtagString = ''; + if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) { + $content = substr($content, 0, -strlen($matches[0])); + if (preg_match_all('/#(\w+)/u', $matches[0], $tags)) { + $hashtagString = "\n> " . implode(' ', $tags[0]); + } } - } $content = trim(preg_replace('/\s+/', ' ', $content));