preserve multiple newlines - see discussion at https://github.com/friendica/friendica/pull/570
This commit is contained in:
parent
8209ae6455
commit
a5755b59a8
1 changed files with 10 additions and 6 deletions
|
@ -312,6 +312,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
|
||||||
$Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text);
|
$Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text);
|
||||||
$Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text);
|
$Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text);
|
||||||
|
|
||||||
|
$Text = preg_replace("/\n\[code\]/ism", "[code]", $Text);
|
||||||
|
$Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
|
||||||
|
|
||||||
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
|
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
|
||||||
if (!$tryoembed)
|
if (!$tryoembed)
|
||||||
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
|
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
|
||||||
|
@ -327,12 +330,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
|
||||||
$Text = str_replace("\r\n","\n", $Text);
|
$Text = str_replace("\r\n","\n", $Text);
|
||||||
|
|
||||||
// removing multiplicated newlines
|
// removing multiplicated newlines
|
||||||
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
|
// $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
|
||||||
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
|
// $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
|
||||||
do {
|
// do {
|
||||||
$oldtext = $Text;
|
// $oldtext = $Text;
|
||||||
$Text = str_replace($search, $replace, $Text);
|
// $Text = str_replace($search, $replace, $Text);
|
||||||
} while ($oldtext != $Text);
|
// } while ($oldtext != $Text);
|
||||||
|
|
||||||
|
|
||||||
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
|
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue