mastodonapi.php aktualisiert

This commit is contained in:
simonpipe 2025-08-13 15:15:23 +02:00
parent 5b5faa2889
commit 1db48837f6

View file

@ -199,7 +199,7 @@ class YellowMastodonAPI {
return trim(preg_replace('/[^a-z0-9-]+/', '', $slug), '-'); return trim(preg_replace('/[^a-z0-9-]+/', '', $slug), '-');
} }
private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor, $origUrl, $yellowAuthor, $yellowTag, $images = [], $alts = []) { private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor, $origUrl, $yellowAuthor, $yellowTag, $images = [], $alts = []) {
$date = new DateTime($dateTime); $date = new DateTime($dateTime);
$formattedDate = $date->format('Y-m-d'); $formattedDate = $date->format('Y-m-d');
$formattedTime = $date->format('H:i:s'); $formattedTime = $date->format('H:i:s');
@ -208,15 +208,10 @@ private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor,
$content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8'); $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$hashtagString = ''; $hashtagString = '';
// Finde den gesamten Block der Tags am Ende des Strings
if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) { if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) {
// Entferne den Tag-Block aus dem Content
$content = substr($content, 0, -strlen($matches[0])); $content = substr($content, 0, -strlen($matches[0]));
// Finde alle einzelnen Tags im extrahierten Block
if (preg_match_all('/#(\w+)/u', $matches[0], $tags)) { 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 = "\n" . implode(' ', $tags[0]);
} }
} }