summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/BBCodeParser.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/BBCodeParser.php b/src/BBCodeParser.php
index 1d15763..87c4175 100644
--- a/src/BBCodeParser.php
+++ b/src/BBCodeParser.php
@@ -103,17 +103,22 @@ class BBCodeParser {
$c = array_pop($list_counter_stack);
if (is_int($c)) {
- $out .= $c . '. ';
+ $out .= $c . '.';
$list_counter_stack[] = $c + 1;
}
else if ($c == '*') {
- $out .= $c . ' ';
+ $out .= $c;
$list_counter_stack[] = '*';
}
else {
- $out .= $c . '. ';
+ $out .= $c . '.';
$list_counter_stack[] = chr(ord($c)+1);
}
+
+ if ($in[$i] != ' ') {
+ # add space after item label only if there is not one already
+ $out .= ' ';
+ }
break;
case 'img':
$text_stack[] = $out;
@@ -169,13 +174,18 @@ class BBCodeParser {
case 'list:o':
case 'list:u':
# TODO: untested
- $out .= "\n";
array_pop($list_counter_stack);
+
+ if ($in[$i] != "\n") {
+ # add newline after list only if there is not one already
+ $out .= "\n";
+ }
break;
case '*':
case '*:m':
# TODO: untested
if ($in[$i] != "\n") {
+ # add newline after item only if there is not one already
$out .= "\n";
}
break;