in reply to Formatting paragraph
# First encode possible HTML, because the text is # supposed to be plain text use HTML::Entities(); $text = HTML::Entities::encode($text); # Convert Windows or Mac line terminators to Unix single \n $text =~ s/\r\n|\n\r/\n/g; # Remove leading and trailing white space $text =~ s/^\s*//; $text =~ s/\s*$//g # Convert all double line breaks to para tags $text =~ s|\n\s*\n|</p><p>|g # Convert any single line breaks to br tags $text =~ s|\n\s*|<br />|g # If text is more than just white space, add opening and # closing para tags $text = "<p>$text</p>" if $text;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Formatting paragraph
by Anonymous Monk on Feb 03, 2006 at 01:17 UTC | |
by blazar (Canon) on Feb 03, 2006 at 07:39 UTC |