]> git.mxchange.org Git - friendica.git/commitdiff
Normalize [ul] and [ol] BBCode output to <ul> and <ol> HTML tags
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 19 Mar 2023 03:22:42 +0000 (23:22 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 19 Mar 2023 03:35:51 +0000 (23:35 -0400)
src/Content/Text/BBCode.php
src/Content/Text/HTML.php
tests/src/Content/Text/BBCodeTest.php

index d329c1e326b6bb0374a11475a65f2dab7e1887c1..5f06ba58841cf610c006db6e3a961fe15d71f6e4 100644 (file)
@@ -1473,8 +1473,8 @@ class BBCode
                                        $text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '</p><ul class="listupperroman" style="list-style-type: upper-roman;">$2</ul><p>', $text);
                                        $text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '</p><ul class="listloweralpha" style="list-style-type: lower-alpha;">$2</ul><p>', $text);
                                        $text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '</p><ul class="listupperalpha" style="list-style-type: upper-alpha;">$2</ul><p>', $text);
-                                       $text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '</p><ul class="listbullet" style="list-style-type: circle;">$1</ul><p>', $text);
-                                       $text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '</p><ul class="listdecimal" style="list-style-type: decimal;">$1</ul><p>', $text);
+                                       $text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '</p><ul>$1</ul><p>', $text);
+                                       $text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '</p><ol>$1</ol><p>', $text);
                                        $text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>', $text);
                                }
 
index f9f340135cf51cf22cab2bf62c941166305b2f4c..ebd74121b11552414cca0473c9fd305867326614 100644 (file)
@@ -281,8 +281,8 @@ 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, 'ul', [], "[ul]", "[/ul]");
+                       self::tagToBBCode($doc, 'ol', [], "[ol]", "[/ol]");
                        self::tagToBBCode($doc, 'li', [], "[*]", "");
 
                        self::tagToBBCode($doc, 'hr', [], "[hr]", "");
index 1bf5dfb902b807a4deabff85963f6b629dca2a12..698b37e70001ee4b5fa50b3c8007c06f4e2d9a49 100644 (file)
@@ -158,21 +158,21 @@ class BBCodeTest extends FixtureTest
        {
                return [
                        'bug-7271-condensed-space' => [
-                               'expectedHtml' => '<ul class="listdecimal" style="list-style-type:decimal;"><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
+                               'expectedHtml' => '<ol><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ol>',
                                'text' => '[ol][*] http://example.com/[/ol]',
                        ],
                        'bug-7271-condensed-nospace' => [
-                               'expectedHtml' => '<ul class="listdecimal" style="list-style-type:decimal;"><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
+                               'expectedHtml' => '<ol><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ol>',
                                'text' => '[ol][*]http://example.com/[/ol]',
                        ],
                        'bug-7271-indented-space' => [
-                               'expectedHtml' => '<ul class="listbullet" style="list-style-type:circle;"><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
+                               'expectedHtml' => '<ul><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
                                'text' => '[ul]
 [*] http://example.com/
 [/ul]',
                        ],
                        'bug-7271-indented-nospace' => [
-                               'expectedHtml' => '<ul class="listbullet" style="list-style-type:circle;"><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
+                               'expectedHtml' => '<ul><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
                                'text' => '[ul]
 [*]http://example.com/
 [/ul]',
@@ -259,7 +259,7 @@ 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' => '<h1>Header</h1><ul class="listbullet" style="list-style-type:circle;"><li>One</li><li>Two</li></ul><p>This is a paragraph<br>with a line feed.</p><p>Second Chapter</p>',
+                               'expectedHTML' => '<h1>Header</h1><ul><li>One</li><li>Two</li></ul><p>This is a paragraph<br>with a line feed.</p><p>Second Chapter</p>',
                                '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' => [