From ec947b4b08de552c1c9970cb596ac08c7e5a46e6 Mon Sep 17 00:00:00 2001 From: uckelman Date: Sun, 25 Apr 2010 21:15:18 +0000 Subject: Fixed list spacing. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6760 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/BBCodeParser.php | 18 ++++++++++++++---- 1 file 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; -- cgit v1.2.3