mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
make sure we preserve linefeeds in the actual content of lists and tables also add tests
This commit is contained in:
@@ -1060,8 +1060,8 @@ function bb_fix_lf($match) {
|
|||||||
// be converted to '<br />' and turn your neatly crafted tables into a whole lot of
|
// be converted to '<br />' and turn your neatly crafted tables into a whole lot of
|
||||||
// empty space.
|
// empty space.
|
||||||
|
|
||||||
$new_content = str_replace(["\n\r", "\n", "\r"], '', $match[1]);
|
$new_content = preg_replace("/\]\s+\[/",'][', $match[1]);
|
||||||
return str_replace($match[1], $new_content, $match[0]);
|
return str_replace($match[1], trim($new_content, "\r\n"), $match[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbtopoll($s) {
|
function bbtopoll($s) {
|
||||||
@@ -1554,6 +1554,20 @@ function bbcode($text, $options = []) {
|
|||||||
$text = preg_replace_callback("/\[checklist\](.*?)\[\/checklist\]/ism", 'bb_checklist', $text);
|
$text = preg_replace_callback("/\[checklist\](.*?)\[\/checklist\]/ism", 'bb_checklist', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (strpos($text,'[/table]') !== false) {
|
||||||
|
$text = str_replace(["[/table]\r", "[/table]\n"], '[/table]', $text);
|
||||||
|
|
||||||
|
$text = preg_replace_callback("/\[table\](.*?)\[\/table\]/ism",'bb_fix_lf',$text);
|
||||||
|
$text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>', $text);
|
||||||
|
|
||||||
|
$text = preg_replace_callback("/\[table border=1\](.*?)\[\/table\]/ism",'bb_fix_lf',$text);
|
||||||
|
$text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table class="table table-responsive table-bordered" >$1</table>', $text);
|
||||||
|
|
||||||
|
$text = preg_replace_callback("/\[table border=0\](.*?)\[\/table\]/ism",'bb_fix_lf',$text);
|
||||||
|
$text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table class="table table-responsive" >$1</table>', $text);
|
||||||
|
}
|
||||||
|
|
||||||
if (strpos($text,'[th]') !== false) {
|
if (strpos($text,'[th]') !== false) {
|
||||||
$text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '<th>$1</th>', $text);
|
$text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '<th>$1</th>', $text);
|
||||||
}
|
}
|
||||||
@@ -1566,13 +1580,6 @@ function bbcode($text, $options = []) {
|
|||||||
$text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>', $text);
|
$text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($text,'[/table]') !== false) {
|
|
||||||
$text = preg_replace_callback("/\[table\](.*?)\[\/table\]/ism",'bb_fix_lf',$text);
|
|
||||||
$text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>', $text);
|
|
||||||
$text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table class="table table-responsive table-bordered" >$1</table>', $text);
|
|
||||||
$text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table class="table table-responsive" >$1</table>', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = str_replace('[hr]', '<hr />', $text);
|
$text = str_replace('[hr]', '<hr />', $text);
|
||||||
|
|
||||||
// This is actually executed in prepare_body()
|
// This is actually executed in prepare_body()
|
||||||
|
|||||||
@@ -111,13 +111,25 @@ class BBCodeTest extends UnitTestCase {
|
|||||||
"some text\n[list]\n[*] item1\n[*] item2\n[/list]\nsome more text",
|
"some text\n[list]\n[*] item1\n[*] item2\n[/list]\nsome more text",
|
||||||
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
||||||
],
|
],
|
||||||
|
'list with linebreaks \n in text' => [
|
||||||
|
"some text\n[list]\n[*] item1\nsome text[*] item2\nsome text[/list]\nsome more text",
|
||||||
|
'some text<br /><ul class="listbullet"><li> item1<br />some text<li> item2<br />some text</ul>some more text'
|
||||||
|
],
|
||||||
'list with linebreaks \r' => [
|
'list with linebreaks \r' => [
|
||||||
"some text\r[list]\r[*] item1\r[*] item2\r[/list]\rsome more text",
|
"some text\r[list]\r[*] item1\r[*] item2\r[/list]\rsome more text",
|
||||||
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
||||||
],
|
],
|
||||||
|
'list with linebreaks \r in text' => [
|
||||||
|
"some text\r[list]\r[*] item1\rsome text\r[*] item2\rsome text\r[/list]\rsome more text",
|
||||||
|
'some text<br /><ul class="listbullet"><li> item1<br />some text<li> item2<br />some text</ul>some more text'
|
||||||
|
],
|
||||||
'list with linebreaks \r\n' => [
|
'list with linebreaks \r\n' => [
|
||||||
"some text\r\n[list]\r\n[*] item1\r\n[*] item2\r\n[/list]\r\nsome more text",
|
"some text\r\n[list]\r\n[*] item1\r\n[*] item2\r\n[/list]\r\nsome more text",
|
||||||
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
'some text<br /><ul class="listbullet"><li> item1<li> item2</ul>some more text'
|
||||||
|
],
|
||||||
|
'list with linebreaks \r\n in text' => [
|
||||||
|
"some text\r\n[list]\r\n[*] item1\r\nsome text[*] item2\r\nsome text[/list]\r\nsome more text",
|
||||||
|
'some text<br /><ul class="listbullet"><li> item1<br />some text<li> item2<br />some text</ul>some more text'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
12
vendor/composer/installed.php
vendored
12
vendor/composer/installed.php
vendored
@@ -1,9 +1,9 @@
|
|||||||
<?php return array(
|
<?php return array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'name' => 'zotlabs/hubzilla',
|
'name' => 'zotlabs/hubzilla',
|
||||||
'pretty_version' => 'dev-9.0RC',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-9.0RC',
|
'version' => 'dev-master',
|
||||||
'reference' => 'a18e873d08e733225c70b0ace31c3cbb025ff906',
|
'reference' => 'a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3',
|
||||||
'type' => 'application',
|
'type' => 'application',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
@@ -338,9 +338,9 @@
|
|||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'zotlabs/hubzilla' => array(
|
'zotlabs/hubzilla' => array(
|
||||||
'pretty_version' => 'dev-9.0RC',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-9.0RC',
|
'version' => 'dev-master',
|
||||||
'reference' => 'a18e873d08e733225c70b0ace31c3cbb025ff906',
|
'reference' => 'a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3',
|
||||||
'type' => 'application',
|
'type' => 'application',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|||||||
Reference in New Issue
Block a user