From 12d2de2c9345820c39d64d88c2448d5965f4909d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 19 Mar 2023 20:16:41 +0000 Subject: [PATCH 1/4] Remove tabs if followed by new lines (or vice versa) --- src/Content/Text/BBCode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index d329c1e326..c14f55a709 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1338,11 +1338,11 @@ class BBCode // removing multiplicated newlines if (DI::config()->get('system', 'remove_multiplicated_lines')) { $search = [ - "\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[*]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n", + "\n\n\n", "\n ", " \n", "\n\t", "\t\n", "\n\r", "\r\n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[*]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n", "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n" ]; $replace = [ - "\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[*]", "[ul]", "[/ul]", "\n[share ", "[/attachment]", + "\n\n", "\n", "\n", "\n", "\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[*]", "[ul]", "[/ul]", "\n[share ", "[/attachment]", "[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]" ]; do { From f65c71a25bcade6c3aacbff6a1ec36132c780e40 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Mar 2023 04:10:35 +0000 Subject: [PATCH 2/4] Restructured replacements --- src/Content/Text/BBCode.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index c14f55a709..81e1476b58 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1312,7 +1312,8 @@ class BBCode "\n[tr]", "[tr]\n", " [tr]", "[tr] ", "\n[/tr]", "[/tr]\n", " [/tr]", "[/tr] ", "\n[hr]", "[hr]\n", " [hr]", "[hr] ", "\n[attachment ", " [attachment ", "\n[/attachment]", "[/attachment]\n", " [/attachment]", "[/attachment] ", - "[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] " + "[table]\n", "[table] ", " [table]", "\n[/table]", " [/table]", "[/table] ", + " \n", "\t\n", "[/li]\n", "\n[li]", "\n[*]", ]; $replace = [ "[th]", "[th]", "[th]", "[/th]", "[/th]", "[/th]", @@ -1320,7 +1321,8 @@ class BBCode "[tr]", "[tr]", "[tr]", "[tr]", "[/tr]", "[/tr]", "[/tr]", "[/tr]", "[hr]", "[hr]", "[hr]", "[hr]", "[attachment ", "[attachment ", "[/attachment]", "[/attachment]", "[/attachment]", "[/attachment]", - "[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]" + "[table]", "[table]", "[table]", "[/table]", "[/table]", "[/table]", + "\n", "\n", "[/li]", "[li]", "[*]", ]; do { $oldtext = $text; @@ -1338,11 +1340,11 @@ class BBCode // removing multiplicated newlines if (DI::config()->get('system', 'remove_multiplicated_lines')) { $search = [ - "\n\n\n", "\n ", " \n", "\n\t", "\t\n", "\n\r", "\r\n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[*]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n", + "\n\n\n", "[/quote]\n\n", "\n[/quote]", "\n[ul]", "[/ul]\n", "\n[ol]", "[/ol]\n", "\n\n[share ", "[/attachment]\n", "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n" ]; $replace = [ - "\n\n", "\n", "\n", "\n", "\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[*]", "[ul]", "[/ul]", "\n[share ", "[/attachment]", + "\n\n", "[/quote]\n", "[/quote]", "[ul]", "[/ul]", "[ol]", "[/ol]", "\n[share ", "[/attachment]", "[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]" ]; do { From 3a73df7007b0433ee346661ff8e3853c8975d6fe Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Mar 2023 04:25:05 +0000 Subject: [PATCH 3/4] Fix tests --- tests/src/Content/Text/BBCodeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index b7328d67d7..3dfae479b2 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -267,11 +267,11 @@ Karl Marx - Die ursprüngliche Akkumulation 'text' => '[h1]Header[/h1]Some Chapter', ], 'bug-12842-ul-newlines' => [ - 'expectedHTML' => '

This is:

  • some
  • amazing
  • list
', + 'expectedHTML' => '

This is:

  • some
  • amazing
  • list
', '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
', + '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]", ], ]; From 55912d1c75302b8cd9d07ff52b26eb2c977b0544 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Mar 2023 07:03:17 +0000 Subject: [PATCH 4/4] Test added --- tests/src/Content/Text/BBCodeTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 3dfae479b2..6f8fdea2e6 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -274,6 +274,10 @@ Karl Marx - Die ursprüngliche Akkumulation '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]", ], + 'task-12917-tabs-between-linebreaks' => [ + 'expectedHTML' => '

Paragraph

New Paragraph

', + 'text' => "Paragraph\n\t\nNew Paragraph", + ], ]; }