mastodonapi.php aktualisiert
This commit is contained in:
parent
3d41b8f56c
commit
84de143e21
1 changed files with 15 additions and 2 deletions
|
|
@ -2,7 +2,7 @@
|
|||
// MastodonAPI extension, https://codeberg.org/simonpipe/yellow-mastodonapi
|
||||
|
||||
class YellowMastodonAPI {
|
||||
const VERSION = "0.3";
|
||||
const VERSION = "0.4";
|
||||
public $yellow;
|
||||
|
||||
// Initialisierung
|
||||
|
|
@ -206,6 +206,19 @@ private function generateMarkdown($title, $slug, $dateTime, $html, $origAuthor,
|
|||
|
||||
$content = strip_tags($html);
|
||||
$content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// --- NEUER, ROBUSTER CODE: Findet und entfernt nur die Tags am Ende ---
|
||||
$hashtagMarkdown = '';
|
||||
|
||||
// Sucht Hashtags am Ende des Content-Strings
|
||||
if (preg_match('/(\s*(#\w+))+$/u', $content, $matches)) {
|
||||
// Entfernt die gefundenen Tags aus dem Content
|
||||
$content = substr($content, 0, -strlen($matches[0]));
|
||||
// Formatiert die Tags für die separate Zeile
|
||||
$hashtagMarkdown = "\n" . trim($matches[0]) . "\n";
|
||||
}
|
||||
// --- ENDE NEUER CODE ---
|
||||
|
||||
$content = trim(preg_replace('/\s+/', ' ', $content));
|
||||
|
||||
$imageMarkdown = '';
|
||||
|
|
@ -239,7 +252,7 @@ $imageMarkdown
|
|||
> "$content"
|
||||
>
|
||||
> — <a target="_blank" href="$origUrl">$htmlSafeAuthorName</a>
|
||||
|
||||
$hashtagMarkdown
|
||||
MD;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue