mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 10:57: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
|
|
@ -70,7 +70,7 @@ function getSingleParameter($keyToFind, $string) {
|
|||
}
|
||||
|
||||
$pattern = '/\s*(?<!\S)' . $keyToFind . '\s*=\s*([^#\n]+)/';
|
||||
// Fix: not machting with nick as in: `# follow = dbucklin@www.davebucklin.com https://www.davebucklin.com/twtxt.txt?nick=dbucklin`
|
||||
// Fix: not machting with nick as in: `# follow = dbucklin@www.davebucklin.com https://www.davebucklin.com/twtxt.txt?nick=dbucklin`
|
||||
//$pattern = '/\s*' . $keyToFind . '\s*=\s*([^#\n]+)/';
|
||||
//$pattern = '/\s*' . $keyToFind . '\s*=\s*([^\s#]+)/'; // Only matches the first word
|
||||
preg_match($pattern, $string, $matches);
|
||||
|
|
@ -224,6 +224,15 @@ function replaceTagsFromTwt(string $twtString) {
|
|||
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) {
|
||||
|
||||
// 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", $twtContent);
|
||||
|
||||
$twtContent = replaceMarkdownSpoilersFromTwt($twtContent); // Testing for: https://darch.dk/timeline/conv/kwxr5aq
|
||||
|
||||
$twtContent = embedYoutubeFromTwt($twtContent);
|
||||
|
||||
// Get and remove the hash
|
||||
|
|
|
|||
Loading…
Reference in a new issue