mastodonapi.php aktualisiert

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

View file

@ -199,26 +199,21 @@ 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');
$content = strip_tags($html); $content = strip_tags($html);
$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)) { $content = substr($content, 0, -strlen($matches[0]));
// Entferne den Tag-Block aus dem Content if (preg_match_all('/#(\w+)/u', $matches[0], $tags)) {
$content = substr($content, 0, -strlen($matches[0])); $hashtagString = "\n> " . implode(' ', $tags[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]);
} }
}
$content = trim(preg_replace('/\s+/', ' ', $content)); $content = trim(preg_replace('/\s+/', ' ', $content));