...# NIY bullet-tt
...$QUOTE = 2; # in blockquote
...sub html { local($title, $curstate, $fold, $a); local(@data) =
\n" unless $fold++; next; } $fold = 0; # state transitions if (/^>\s/) { &to_quote; } elsif (/^ [^ ]/) { &to_fmt; } else { &to_pre; } s/^>\s*//; # fix quote-tt s/^ ([^ ])/$1/; # fix indent-tt # bold-tt s#\*\*([^\*]*)\*\*#\376B\377$1\376/B\377#; # italic-tt s#~([^~]*)~#\376I\377$1\376/I\377#; # hot-tt s#\b([^\s]*)_\b# $h = $href{$1}; ($a = $1) =~ s,_, ,g; $h ? qq'\376A HREF="$h"\377$a\376/A\377' : "\376I\377$a\376/I\377"; #e; # underline-tt s#_([^\s]*)_# ($a = $1) =~ s,_, ,g; "\376I\377$a\376/I\377"; #e; print &htmlize($_), "\n"; } &to_fmt; print "\n"; } sub to_fmt { return if $curstate == $FMT; print "\n" if $curstate == $PRE; print "\n" if $curstate == $QUOTE; #XXX $curstate = $FMT; } sub to_pre { return if $curstate == $PRE; print "
\n" if $curstate == $FMT;
print "\n" if $curstate == $QUOTE; #XXX
$curstate = $PRE;
}
sub to_quote {
return if $curstate == $QUOTE;
print "\n" if $curstate == $FMT; #XXX
print "\n" if $curstate == $PRE; #XXX
$curstate = $QUOTE;
}
sub htmlize {
local($_) = @_;
s/\&/\&\#38\;/g; s/\\&\#60\;/g; s/\>/\&\#62\;/g;
s/\376//g; # convert back
$_;
}
sub title {
local($head, $i) = @_;
$data[$i--] = ".."; $data[$i] =~ s/^\s*//;
print "$data[$i] \n" unless $title++;
$data[$i] = ".. <$head>" . $data[$i] . "$head>";
}
&setext'html; # run standalone