mirror of
https://github.com/friendica/friendica
synced 2024-12-23 11:20:15 +00:00
Prevents share block new lines from being converted to HTML <br> tags
- Address https://github.com/friendica/friendica/pull/9621#issuecomment-739333767
This commit is contained in:
parent
1cc509c5ef
commit
f141f5acf4
1 changed files with 8 additions and 7 deletions
|
@ -1378,6 +1378,9 @@ class BBCode
|
||||||
} while ($oldtext != $text);
|
} while ($oldtext != $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add HTML new lines
|
||||||
|
$text = str_replace("\n", '<br>', $text);
|
||||||
|
|
||||||
/// @todo Have a closer look at the different html modes
|
/// @todo Have a closer look at the different html modes
|
||||||
// Handle attached links or videos
|
// Handle attached links or videos
|
||||||
if ($simple_html == self::ACTIVITYPUB) {
|
if ($simple_html == self::ACTIVITYPUB) {
|
||||||
|
@ -1848,18 +1851,16 @@ class BBCode
|
||||||
return $text;
|
return $text;
|
||||||
}); // Escaped noparse, nobb, pre
|
}); // Escaped noparse, nobb, pre
|
||||||
|
|
||||||
// Remove escaping tags
|
// Remove escaping tags and replace new lines that remain
|
||||||
$text = preg_replace("/\[noparse\](.*?)\[\/noparse\]/ism", '\1', $text);
|
$text = preg_replace_callback("/\[(noparse|nobb)\](.*?)\[\/\1\]/ism", function ($match) {
|
||||||
$text = preg_replace("/\[nobb\](.*?)\[\/nobb\]/ism", '\1', $text);
|
return str_replace("\n", "<br>", $match[2]);
|
||||||
|
}, $text);
|
||||||
|
|
||||||
// Additionally, [pre] tags preserve spaces
|
// Additionally, [pre] tags preserve spaces
|
||||||
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", function ($match) {
|
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", function ($match) {
|
||||||
return str_replace(' ', ' ', htmlentities($match[1], ENT_NOQUOTES,'UTF-8'));
|
return str_replace([' ', "\n"], [' ', "<br>"], htmlentities($match[1], ENT_NOQUOTES,'UTF-8'));
|
||||||
}, $text);
|
}, $text);
|
||||||
|
|
||||||
// Add HTML new lines
|
|
||||||
$text = str_replace("\n", '<br>', $text);
|
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}); // Escaped code
|
}); // Escaped code
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue