Here is a very short Perl snippet that does Text (including code) to HTML. It will also escape the [ and ] for you so is PM HTML compatible!
my $text = "c:/text.pl"; open TEXT, $text or die "Oops can't open $text $!"; open HTML, ">$text.htm" or die "Oops can't write $text.htm $!"; print HTML "<pre>\n"; while (<TEXT>) { $_ = escapeHTML($_); print HTML $_; } print HTML "</pre>\n"; close HTML; close TEXT; sub escapeHTML { local $_ = shift; # make the required escapes s/&/&/g; s/"/"/g; s/</</g; s/>/>/g; # change tabs to 4 spaces s/\t/ /g; # make the whitespace escapes - not required within <pre> tags s/( {2,})/" " x length $1/eg; # make the brower bugfix escapes; s/\x8b/‹/g; s/\x9b/›/g; # make the PERL MONKS escapes (if desired) s/\[/[/g; s/\]/]/g; # change newlines to <br> if desired - not required with <pre> # s/\n/<br>\n/g; return $_; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: neat little win32 freeware utility
by tachyon
in thread neat little win32 freeware utility
by ralphie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |