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