diff options
author | Mario <mario@mariovavti.com> | 2024-05-03 09:39:58 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-05-03 09:39:58 +0200 |
commit | b25662e183fa800d13908e707e0a3f33131b9ea8 (patch) | |
tree | 172c0b039e50c7f531a75c132c90bb97b0c81a79 | |
parent | 47a86f877172fe6cdc44991c0722550e4190cb95 (diff) | |
download | volse-hubzilla-b25662e183fa800d13908e707e0a3f33131b9ea8.tar.gz volse-hubzilla-b25662e183fa800d13908e707e0a3f33131b9ea8.tar.bz2 volse-hubzilla-b25662e183fa800d13908e707e0a3f33131b9ea8.zip |
fix nested lists by parsing li before ul or ol and add a test
-rw-r--r-- | include/html2bbcode.php | 3 | ||||
-rw-r--r-- | tests/unit/includes/BBCodeTest.php | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 03e09cd62..b7f3ea4e3 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -205,10 +205,9 @@ function html2bbcode($message) node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]'); // node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]'); - + node2bbcode($doc, 'li', array(), "[*]", ""); node2bbcode($doc, 'ul', array(), "[list]", "[/list]"); node2bbcode($doc, 'ol', array(), "[list=1]", "[/list]"); - node2bbcode($doc, 'li', array(), "[*]", ""); node2bbcode($doc, 'hr', array(), "[hr]", ""); diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php index a8aa8ee2b..e1fba9fbc 100644 --- a/tests/unit/includes/BBCodeTest.php +++ b/tests/unit/includes/BBCodeTest.php @@ -230,6 +230,14 @@ class BBCodeTest extends UnitTestCase { 'html reshares from streams' => [ '<div><div><a href="https://example.com"><img src="https://example.com/image.jpg" alt="image/photo"></a> shared something</div>something</div>', '[url=https://example.com][img=https://example.com/image.jpg]image/photo[/img][/url] shared something' . "\n" . 'something' + ], + 'list' => [ + '<ul><li>list 1</li><li>list 2</li><li>list 3</li></ul>', + '[list][*]list 1[*]list 2[*]list 3[/list]' + ], + 'nested list' => [ + '<ul><li>list 1</li><li>list 2</li><li>list 3</li><ul><li>list 1</li><li>list 2</li><li>list 3</li></ul></ul>', + '[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[/list][/list]' ] ]; } |