From 52c7078bad869b30bcf4bf6cbbb58f3d1ff6b360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?s=C3=B8renpeter?= Date: Fri, 6 Dec 2024 17:21:17 +0100 Subject: [PATCH] Attept for rendering markdown spoilers --- libs/twtxt.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/twtxt.php b/libs/twtxt.php index a94ed36..15082cb 100644 --- a/libs/twtxt.php +++ b/libs/twtxt.php @@ -70,7 +70,7 @@ function getSingleParameter($keyToFind, $string) { } $pattern = '/\s*(?!( ?.+?)((\r?\n\r?\n\w)|\Z)/'; + $replacement = '
$1$2
'; + $result = preg_replace($pattern, $replacement, $twtString); + + return $result; +} + + function embedYoutubeFromTwt(string $twtString) { // original regex source: https://gist.github.com/afeld/1254889#gistcomment-1253992 @@ -436,6 +445,8 @@ function getTwtsFromTwtxtString($url) { //$twtContent = str_replace("\u{2028}", "\n
\n", $twtContent); $twtContent = str_replace("\u{2028}", "\n", $twtContent); + $twtContent = replaceMarkdownSpoilersFromTwt($twtContent); // Testing for: https://darch.dk/timeline/conv/kwxr5aq + $twtContent = embedYoutubeFromTwt($twtContent); // Get and remove the hash