diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index d329c1e326..5f06ba5884 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1473,8 +1473,8 @@ class BBCode $text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '

', $text); $text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '

', $text); $text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '

', $text); - $text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '

', $text); - $text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '

', $text); + $text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '

', $text); + $text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '

    $1

', $text); $text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '

  • $1
  • ', $text); } diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index f9f340135c..c1bcb0b5b0 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -281,9 +281,9 @@ class HTML self::tagToBBCode($doc, 'div', [], "\r", "\r"); self::tagToBBCode($doc, 'p', [], "\n", "\n"); - self::tagToBBCode($doc, 'ul', [], "[list]", "[/list]"); - self::tagToBBCode($doc, 'ol', [], "[list=1]", "[/list]"); - self::tagToBBCode($doc, 'li', [], "[*]", ""); + self::tagToBBCode($doc, 'ul', [], "[ul]", "\n[/ul]"); + self::tagToBBCode($doc, 'ol', [], "[ol]", "\n[/ol]"); + self::tagToBBCode($doc, 'li', [], "\n[*]", ""); self::tagToBBCode($doc, 'hr', [], "[hr]", ""); @@ -349,33 +349,6 @@ class HTML $message = str_replace("\n\n\n", "\n\n", $message); } while ($oldmessage != $message); - do { - $oldmessage = $message; - $message = str_replace( - [ - "[/size]\n\n", - "\n[hr]", - "[hr]\n", - "\n[list", - "[/list]\n", - "\n[/", - "[list]\n", - "[list=1]\n", - "\n[*]"], - [ - "[/size]\n", - "[hr]", - "[hr]", - "[list", - "[/list]", - "[/", - "[list]", - "[list=1]", - "[*]"], - $message - ); - } while ($message != $oldmessage); - $message = str_replace( ['[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'], ['[b]', '[/b]', '[i]', '[/i]'], diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index a7de2388e2..b7328d67d7 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -158,21 +158,21 @@ class BBCodeTest extends FixtureTest { return [ 'bug-7271-condensed-space' => [ - 'expectedHtml' => '', + 'expectedHtml' => '
    1. http://example.com/
    ', 'text' => '[ol][*] http://example.com/[/ol]', ], 'bug-7271-condensed-nospace' => [ - 'expectedHtml' => '', + 'expectedHtml' => '
    1. http://example.com/
    ', 'text' => '[ol][*]http://example.com/[/ol]', ], 'bug-7271-indented-space' => [ - 'expectedHtml' => '', + 'expectedHtml' => '', 'text' => '[ul] [*] http://example.com/ [/ul]', ], 'bug-7271-indented-nospace' => [ - 'expectedHtml' => '', + 'expectedHtml' => '', 'text' => '[ul] [*]http://example.com/ [/ul]', @@ -259,13 +259,21 @@ Karl Marx - Die ursprüngliche Akkumulation 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', ], 'task-12900-multiple-paragraphs' => [ - 'expectedHTML' => '

    Header

    This is a paragraph
    with a line feed.

    Second Chapter

    ', + 'expectedHTML' => '

    Header

    This is a paragraph
    with a line feed.

    Second Chapter

    ', 'text' => "[h1]Header[/h1][ul][*]One[*]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter", ], 'task-12900-header-with-paragraphs' => [ 'expectedHTML' => '

    Header

    Some Chapter

    ', 'text' => '[h1]Header[/h1]Some Chapter', - ] + ], + 'bug-12842-ul-newlines' => [ + 'expectedHTML' => '

    This is:

    ', + 'text' => "This is:\r\n[ul]\r\n[*]some\r\n[*]amazing\r\n[*]list\r\n[/ul]", + ], + 'bug-12842-ol-newlines' => [ + 'expectedHTML' => '

    This is:

    1. some
    2. amazing
    3. list
    ', + 'text' => "This is:\r\n[ol]\r\n[*]some\r\n[*]amazing\r\n[*]list\r\n[/ol]", + ], ]; } @@ -282,8 +290,9 @@ Karl Marx - Die ursprüngliche Akkumulation * * @throws InternalServerErrorException */ - public function testConvert(string $expectedHtml, string $text, $try_oembed = false, int $simpleHtml = 0, bool $forPlaintext = false) + public function testConvert(string $expectedHtml, string $text, bool $try_oembed = true, int $simpleHtml = BBCode::INTERNAL, bool $forPlaintext = false) { + // This assumes system.remove_multiplicated_lines = false $actual = BBCode::convert($text, $try_oembed, $simpleHtml, $forPlaintext); self::assertEquals($expectedHtml, $actual); diff --git a/tests/src/Content/Text/HTMLTest.php b/tests/src/Content/Text/HTMLTest.php index 3225d7f60a..dc55ad0f0b 100644 --- a/tests/src/Content/Text/HTMLTest.php +++ b/tests/src/Content/Text/HTMLTest.php @@ -88,6 +88,24 @@ its surprisingly good", 'expectedBBCode' => '[url=https://dev-friendica.mrpetovan.com/profile/hypolite]@hypolite[/url] 0', 'html' => '

    @hypolite 0

    ', ], + 'bug-12842-ul-new-lines' => [ + 'expectedBBCode' => 'This is: +[ul] +[*]some +[*]amazing +[*]list +[/ul]', + 'html'=> '

    This is:

    ', + ], + 'bug-12842-ol-new-lines' => [ + 'expectedBBCode' => 'This is: +[ol] +[*]some +[*]amazing +[*]list +[/ol]', + 'html'=> '

    This is:

    1. some
    2. amazing
    3. list
    ', + ], ]; } @@ -627,13 +645,13 @@ its surprisingly good", e.preventDefault(); // console.log('[id=\"' + this.getAttribute('href') + '\"]'); // console.log(document.getElementById('[id=\"' + this.getAttribute('href') + '\"]')); - + document.querySelector('[ez-toc-data-id=\"' + decodeURI(this.getAttribute('href')) + '\"]').scrollIntoView({ behavior: 'smooth' }); }); }); -}; +}; document.addEventListener('DOMContentLoaded', ezTocScrollScriptJS, false);