", $out); $out = '> ' . $out; $out = array_pop($text_stack) . $out . "\n"; break; case 'code': # TODO: untested # FIXME: don't wordwrap code! $out .= "\n"; break; case 'list': case 'list:o': case 'list:u': # TODO: untested 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; case 'img': # TODO: untested $fn[] = $out; $out = array_pop($text_stack) . '[' . $fn_number++ . ']'; break; case 'attachment': break; case 'color': case 'size': # ignored break; default: throw new Exception('Unrecognized close tag: ' . $tag); } $state = self::TEXT; break; } } $out = wordwrap($out, 72); if (!empty($fn)) { # build footnotes $out .= "\n"; for ($i = 0; $i < count($fn); ++$i) { $out .= "\n[" . ($i+1) . '] ' . $fn[$i]; } } return $out; } } ?>