", $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:l': case 'list:u': # TODO: untested $out .= "\n"; array_pop($list_counter_stack); break; case '*': case '*:m': # TODO: untested if ($in[$i] != "\n") { $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; } } ?>