diff options
author | Mario <mario@mariovavti.com> | 2024-03-25 21:42:50 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-03-25 21:52:14 +0000 |
commit | 6d5fa9205cc4007e07fad216fd1f1ef5980c9a01 (patch) | |
tree | 8829bd5120c171a0fc3a3cfced1c275573207199 | |
parent | 0fee7804fbfa80764e10a445a8e9ca9610b6b49c (diff) | |
download | volse-hubzilla-6d5fa9205cc4007e07fad216fd1f1ef5980c9a01.tar.gz volse-hubzilla-6d5fa9205cc4007e07fad216fd1f1ef5980c9a01.tar.bz2 volse-hubzilla-6d5fa9205cc4007e07fad216fd1f1ef5980c9a01.zip |
more remove additional linebreaks after block element plus test
(cherry picked from commit 53354a19304c932beea484e387d2c9536786e258)
-rw-r--r-- | include/bbcode.php | 5 | ||||
-rw-r--r-- | tests/unit/includes/BBCodeTest.php | 4 | ||||
-rw-r--r-- | vendor/composer/installed.php | 4 |
3 files changed, 11 insertions, 2 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index db3efe9f8..d7ed3a243 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1286,6 +1286,11 @@ function bbcode($text, $options = []) { if (strpos($text,'[pre]') !== false) { $text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$text); } + + if (strpos($text,'</pre>') !== false) { + $text = str_replace(["</pre>\r", "</pre>\n"], '</pre>', $text); + } + if (strpos($text,'[summary]') !== false) { $text = preg_replace_callback("/\[summary\](.*?)\[\/summary\]/ism", 'bb_spacefy',$text); } diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php index a6c798992..a8aa8ee2b 100644 --- a/tests/unit/includes/BBCodeTest.php +++ b/tests/unit/includes/BBCodeTest.php @@ -107,6 +107,10 @@ class BBCodeTest extends UnitTestCase { "[code]\ntestvar = \"this is a test\"\necho \"the message is \$testvar\"\n[/code]", '<pre><code>testvar = "this is a test"<br />echo "the message is $testvar"</code></pre>', ], + 'code block with surroundin linebreaks \n' => [ + "some text\n[code]\ntestvar = \"this is a test\"\necho \"the message is \$testvar\"\n[/code]\nsome more text", + 'some text<br /><pre><code>testvar = "this is a test"<br />echo "the message is $testvar"</code></pre>some more text', + ], 'list with linebreaks \n' => [ "some text\n[list]\n[*] item1\n[*] item2\n[/list]\nsome more text", 'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text' diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index dd4bccc71..1ab0e12b9 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'zotlabs/hubzilla', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3', + 'reference' => '3c0d6339bb12bd7fbf65ba7a79078e39737b4387', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -340,7 +340,7 @@ 'zotlabs/hubzilla' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3', + 'reference' => '3c0d6339bb12bd7fbf65ba7a79078e39737b4387', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), |