From 200bdb55baf58ec149dfecb445e65f31d0a7ead2 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
Date: Sat, 18 Mar 2023 23:22:42 -0400
Subject: [PATCH] Normalize [ul] and [ol] BBCode output to and HTML
tags
---
src/Content/Text/BBCode.php | 4 ++--
src/Content/Text/HTML.php | 4 ++--
tests/src/Content/Text/BBCodeTest.php | 10 +++++-----
3 files changed, 9 insertions(+), 9 deletions(-)
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..ebd74121b1 100644
--- a/src/Content/Text/HTML.php
+++ b/src/Content/Text/HTML.php
@@ -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]", "");
diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php
index 1bf5dfb902..698b37e700 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' => '- http://example.com/
',
'text' => '[ol][*] http://example.com/[/ol]',
],
'bug-7271-condensed-nospace' => [
- 'expectedHtml' => '',
+ 'expectedHtml' => '- 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,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' => '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' => [
--
2.39.5