mastodonapi.php aktualisiert
This commit is contained in:
parent
e1959eb15f
commit
5b5faa2889
1 changed files with 10 additions and 10 deletions
|
|
@ -207,17 +207,18 @@ private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor,
|
||||||
$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');
|
||||||
|
|
||||||
// --- NEUER, ROBUSTER CODE: Findet und entfernt nur die Tags am Ende ---
|
$hashtagString = '';
|
||||||
$hashtagMarkdown = '';
|
// Finde den gesamten Block der Tags am Ende des Strings
|
||||||
|
|
||||||
// Sucht Hashtags am Ende des Content-Strings
|
|
||||||
if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) {
|
if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) {
|
||||||
// Entfernt die gefundenen Tags aus dem Content
|
// Entferne den Tag-Block aus dem Content
|
||||||
$content = substr($content, 0, -strlen($matches[0]));
|
$content = substr($content, 0, -strlen($matches[0]));
|
||||||
// Formatiert die Tags für die separate Zeile
|
|
||||||
$hashtagMarkdown = "\n" . trim($matches[0]) . "\n";
|
// 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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// --- ENDE NEUER CODE ---
|
|
||||||
|
|
||||||
$content = trim(preg_replace('/\s+/', ' ', $content));
|
$content = trim(preg_replace('/\s+/', ' ', $content));
|
||||||
|
|
||||||
|
|
@ -249,10 +250,9 @@ Layout: blog
|
||||||
Tag: $yellowTag
|
Tag: $yellowTag
|
||||||
$featuredImage$featuredImageAlt---
|
$featuredImage$featuredImageAlt---
|
||||||
$imageMarkdown
|
$imageMarkdown
|
||||||
> "$content"
|
> "$content"$hashtagString
|
||||||
>
|
>
|
||||||
> — <a target="_blank" href="$origUrl">$htmlSafeAuthorName</a>
|
> — <a target="_blank" href="$origUrl">$htmlSafeAuthorName</a>
|
||||||
$hashtagMarkdown
|
|
||||||
MD;
|
MD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue