summaryrefslogtreecommitdiff
path: root/src/BBCodeParser.php
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-04-27 19:22:17 +0000
committeruckelman <uckelman@nomic.net>2010-04-27 19:22:17 +0000
commite52bb4c8409da11660760578e73bea8011e51260 (patch)
tree741519b72237488db656bcbbb7070e9cf6e3da5f /src/BBCodeParser.php
parent85b9c8d01717c96951c4528edd3d89b44178b62b (diff)
Don't worry about extra newlines for now.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6763 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src/BBCodeParser.php')
-rw-r--r--src/BBCodeParser.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/BBCodeParser.php b/src/BBCodeParser.php
index 9c7be2c..a1f7236 100644
--- a/src/BBCodeParser.php
+++ b/src/BBCodeParser.php
@@ -91,16 +91,21 @@ class BBCodeParser {
$state = self::TEXT;
break;
case 'quote':
- $text_stack[] = $out . "\n";
+ if ($arg !== false) {
+ $text_stack[] = $out . "\n$arg wrote:\n";
+ }
+ else {
+ $text_stack[] = $out . "\n";
+ }
$out = '';
$state = self::TEXT;
break;
case 'code':
- $out .= "\n";
+ $out .= "\nCode:\n";
$state = self::TEXT;
break;
case 'list':
- if ($out[strlen($out)-1] != "\n") $out .= "\n";
+# if ($out[strlen($out)-1] != "\n") $out .= "\n";
switch ($arg) {
case '1': $list_counter_stack[] = 1; break;
@@ -108,10 +113,11 @@ class BBCodeParser {
default: $list_counter_stack[] = '*'; break;
}
- $state = self::WHSP;
+ $state = self::TEXT;
+# $state = self::WHSP;
break;
case '*':
- if ($out[strlen($out)-1] != "\n") $out .= "\n";
+# if ($out[strlen($out)-1] != "\n") $out .= "\n";
$out .= str_repeat(' ', 2*count($list_counter_stack));
$c = array_pop($list_counter_stack);
@@ -128,7 +134,8 @@ class BBCodeParser {
$list_counter_stack[] = chr(ord($c)+1);
}
- $state = self::WHSP;
+ $state = self::TEXT;
+# $state = self::WHSP;
break;
case 'img':
$text_stack[] = $out;
@@ -184,7 +191,7 @@ class BBCodeParser {
case 'code':
# TODO: untested
# FIXME: don't wordwrap code!
- $out .= "\n";
+ $out .= "\n\n";
$state = self::TEXT;
break;
case 'list':
@@ -192,12 +199,14 @@ class BBCodeParser {
case 'list:u':
array_pop($list_counter_stack);
$out .= "\n\n";
- $state = self::WHSP;
+# $state = self::WHSP;
+ $state = self::TEXT;
break;
case '*':
case '*:m':
- if ($out[strlen($out)-1] == "\n") $out = substr($out, 0, -1);
- $state = self::WHSP;
+# if ($out[strlen($out)-1] == "\n") $out = substr($out, 0, -1);
+# $state = self::WHSP;
+ $state = self::TEXT;
break;
case 'img':
# TODO: untested
@@ -230,6 +239,8 @@ class BBCodeParser {
for ($i = 0; $i < count($fn); ++$i) {
$out .= "\n[" . ($i+1) . '] ' . $fn[$i];
}
+
+ $out .= "\n";
}
return $out;