You possibly want something like this assuming the goal is to make plain text render with formatting intact as HTML.
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; # change newlines to <br> if desired - not required with <pre> s/\n/<br>\n/g; return $_; }
cheers
tachyon
In reply to Re: Substituting Newline Characters
by tachyon
in thread Substituting Newline Characters
by bkiahg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |