summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-04-25 17:39:20 +0000
committeruckelman <uckelman@nomic.net>2010-04-25 17:39:20 +0000
commita41c349410198fd324cc893169ab17f2f69561e2 (patch)
tree5cae790194abdc800dbb92c2fc768a9ad20eac74 /src
parent17e5654c1583939217c31f876419bc2f6d6edc43 (diff)
Testing quote parsing.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6743 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r--src/BBCodeParser.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/BBCodeParser.php b/src/BBCodeParser.php
index 85f4cc7..ddec8f7 100644
--- a/src/BBCodeParser.php
+++ b/src/BBCodeParser.php
@@ -11,8 +11,9 @@ class BBCodeParser {
function parse($in, $uid) {
+ $quote_stack = array();
+
$arg_stack = array();
- $contents_stack = array();
$fn_number = 1;
$fn = array();
@@ -20,8 +21,7 @@ class BBCodeParser {
$i = 0;
$len = strlen($in);
- $indent = '';
- $list_conter_stack = array();
+ $list_counter_stack = array();
$out = '';
@@ -83,12 +83,14 @@ class BBCodeParser {
# nothing to do on opening
break;
case 'quote':
+ $quote_stack[] = $out;
+ $out = '';
break;
case 'code':
+ $out .= "\n";
break;
case 'list':
$out .= "\n";
- $indent .= ' ';
switch ($arg) {
case '1': $list_counter_stack[] = 1; break;
@@ -98,7 +100,7 @@ class BBCodeParser {
break;
case '*':
- $out .= "\n" . $indent;
+ $out .= "\n" . str_repeat(' ', count($list_counter_stack));
$c = array_pop($list_counter_stack);
if ($c == '*') {
@@ -151,15 +153,23 @@ class BBCodeParser {
}
break;
case 'quote':
+ $level = count($quote_stack);
+ $out = wordwrap($out, 72 - 2*$level);
+ $out = str_replace("\n", "\n> ", $out);
+ $out = '> ' . $out;
+ $out = array_pop($quote_stack) . $out;
break;
case 'code':
+ $out .= "\n";
break;
case 'list':
$out .= "\n";
- $indent = substr($indent, -1);
array_pop($list_counter_stack);
break;
case '*':
+ if ($in[$i] != "\n") {
+ $out .= "\n";
+ }
break;
case 'img':
break;