mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-16 11:27:01 +00:00
Attept for rendering markdown spoilers
This commit is contained in:
parent
ee7e6558b2
commit
52c7078bad
1 changed files with 12 additions and 1 deletions
|
|
@ -224,6 +224,15 @@ function replaceTagsFromTwt(string $twtString) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceMarkdownSpoilersFromTwt(string $twtString) {
|
||||||
|
$pattern = '/>!( ?.+?)((\r?\n\r?\n\w)|\Z)/';
|
||||||
|
$replacement = '<details><summary>$1<summary>$2</details>';
|
||||||
|
$result = preg_replace($pattern, $replacement, $twtString);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function embedYoutubeFromTwt(string $twtString) {
|
function embedYoutubeFromTwt(string $twtString) {
|
||||||
|
|
||||||
// original regex source: https://gist.github.com/afeld/1254889#gistcomment-1253992
|
// original regex source: https://gist.github.com/afeld/1254889#gistcomment-1253992
|
||||||
|
|
@ -436,6 +445,8 @@ function getTwtsFromTwtxtString($url) {
|
||||||
//$twtContent = str_replace("\u{2028}", "\n<br>\n", $twtContent);
|
//$twtContent = str_replace("\u{2028}", "\n<br>\n", $twtContent);
|
||||||
$twtContent = str_replace("\u{2028}", "\n", $twtContent);
|
$twtContent = str_replace("\u{2028}", "\n", $twtContent);
|
||||||
|
|
||||||
|
$twtContent = replaceMarkdownSpoilersFromTwt($twtContent); // Testing for: https://darch.dk/timeline/conv/kwxr5aq
|
||||||
|
|
||||||
$twtContent = embedYoutubeFromTwt($twtContent);
|
$twtContent = embedYoutubeFromTwt($twtContent);
|
||||||
|
|
||||||
// Get and remove the hash
|
// Get and remove the hash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue