mirror of
https://github.com/friendica/friendica
synced 2024-11-10 02:22:55 +00:00
Merge pull request #8801 from MrPetovan/task/8800-pre-whitespaces
[pre] blocks now preserve spaces
This commit is contained in:
commit
2fc0b23b7c
3 changed files with 25 additions and 5 deletions
|
@ -633,6 +633,14 @@ On Mastodon this field is used for the content warning.
|
|||
</td>
|
||||
<td>@user@domain.tld #hashtag</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Additionally, [pre] blocks preserve spaces:
|
||||
<ul>
|
||||
<li>[pre] Spaces[/pre]</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td> Spaces</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[nosmile] is used to disable smilies on a post by post basis<br>
|
||||
<br>
|
||||
|
|
|
@ -1299,9 +1299,9 @@ class BBCode
|
|||
// Remove the abstract element. It is a non visible element.
|
||||
$text = self::stripAbstract($text);
|
||||
|
||||
// Move all spaces out of the tags
|
||||
$text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $text);
|
||||
$text = preg_replace("/(\s*)\[\/(\w*)\]/ism", '[/$2]$1', $text);
|
||||
// Move new lines outside of tags
|
||||
$text = preg_replace("#\[(\w*)](\n*)#ism", '$2[$1]', $text);
|
||||
$text = preg_replace("#(\n*)\[/(\w*)]#ism", '[/$2]$1', $text);
|
||||
|
||||
// Extract the private images which use data urls since preg has issues with
|
||||
// large data sizes. Stash them away while we do bbcode conversion, and then put them back
|
||||
|
@ -1878,7 +1878,11 @@ class BBCode
|
|||
// Remove escaping tags
|
||||
$text = preg_replace("/\[noparse\](.*?)\[\/noparse\]/ism", '\1', $text);
|
||||
$text = preg_replace("/\[nobb\](.*?)\[\/nobb\]/ism", '\1', $text);
|
||||
$text = preg_replace("/\[pre\](.*?)\[\/pre\]/ism", '\1', $text);
|
||||
|
||||
// Additionally, [pre] tags preserve spaces
|
||||
$text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", function ($match) {
|
||||
return str_replace(' ', ' ', $match[1]);
|
||||
}, $text);
|
||||
|
||||
return $text;
|
||||
}); // Escaped code
|
||||
|
|
|
@ -236,7 +236,15 @@ class BBCodeTest extends MockedTest
|
|||
'bug-7808-code-amp' => [
|
||||
'expectedHtml' => '<code>&</code>',
|
||||
'text' => '[code]&[/code]',
|
||||
]
|
||||
],
|
||||
'task-8800-pre-spaces-notag' => [
|
||||
'expectedHtml' => '[test] Space',
|
||||
'text' => '[test] Space',
|
||||
],
|
||||
'task-8800-pre-spaces' => [
|
||||
'expectedHtml' => ' Spaces',
|
||||
'text' => '[pre] Spaces[/pre]',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue