Merge pull request #12917 from annando/remove-tab

Remove tabs if followed by new lines (or vice versa)
This commit is contained in:
Hypolite Petovan 2023-03-20 07:09:51 -04:00 committed by GitHub
commit 0b1f67f5b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -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", "[/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", "[/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 {

View file

@ -267,13 +267,17 @@ Karl Marx - Die ursprüngliche Akkumulation
'text' => '[h1]Header[/h1]Some Chapter',
],
'bug-12842-ul-newlines' => [
'expectedHTML' => '<p>This is:</p><ul><li>some<br></li><li>amazing<br></li><li>list</li></ul>',
'expectedHTML' => '<p>This is:</p><ul><li>some</li><li>amazing</li><li>list</li></ul>',
'text' => "This is:\r\n[ul]\r\n[*]some\r\n[*]amazing\r\n[*]list\r\n[/ul]",
],
'bug-12842-ol-newlines' => [
'expectedHTML' => '<p>This is:</p><ol><li>some<br></li><li>amazing<br></li><li>list</li></ol>',
'expectedHTML' => '<p>This is:</p><ol><li>some</li><li>amazing</li><li>list</li></ol>',
'text' => "This is:\r\n[ol]\r\n[*]some\r\n[*]amazing\r\n[*]list\r\n[/ol]",
],
'task-12917-tabs-between-linebreaks' => [
'expectedHTML' => '<p>Paragraph</p><p>New Paragraph</p>',
'text' => "Paragraph\n\t\nNew Paragraph",
],
];
}