xsay: add support for sselp and xclip; output error message
[grml-scripts.git] / usr_bin / code2html
1 #!/usr/bin/perl -p
2 #
3 # code2html - convert code to html for posting to slashdot
4 #
5 # tchrist@perl.com
6 # Sunday, December 19th, 1999
7
8 BEGIN { print "<TT>\n" }        # and the spirit of awk...
9
10 # first kill all the tabs
11 1 while s{ \t + }
12          { " " x (length($&)*8 - length($`)%8) }ex;
13
14 # then the four standard naughty bits
15 s/&/&amp;/g;        # must remember to do this one first!
16 s/</&lt;/g;         # this is the most important one
17 s/>/&gt;/g;         # don't close too early
18 s/"/&quot;/g;       # only in embedded tags, i guess
19
20 # make lines break where they should
21 s/^\s*$/<P>/ || s/$/<BR>/;
22
23 # make sure spaces aren't squishticated so we
24 # can do indentation and properly align comments
25 s/  /&nbsp; /g;
26
27 END { print "</TT>\n" }         # ...shall be with us always