sub format { my $self = shift; my $source = shift; $previndent = 0; $prevtype = 0; @indentstack = (0); @rulestack = (0); # prime the pump with the null ruleset html(); foreach ( split("\n", $source) ) { ($indent, $type, $line, $info) = classify_line($_); $indent = $previndent if $type == $BLANK; if ( not maybe_new_scope() ) { while ( maybe_exit_scope() ) { } maybe_new_scope(); } maybe_emit_markup(); emit($self->markup($line)); $previndent = $indent; $prevtype = $type; } exit_scopes(); my $html = html(); return cleanup_html($html); }