in reply to ASCII to HTML
But anyway, depending on how complicated your text is, you may need something more powerful than just a regex. Take a look at HTML::FromText, which formats your text into HTML. It can handle a lot more formatting issues than just paragraphs.
The result:use HTML::FromText; my $str = <<TEXT; Foo is on this line, and bar is in this paragraph. Baz is in a new paragraph. TEXT print text2html($str, paras => 1);
If you decide to go with a regex, I've always just used<P>Foo is on this line, and bar is in this paragraph.</P> <P>Baz is in a new paragraph.</P>
which first replaces double-newlines and makes them paragraphs, and then formats line breaks. Plus it keeps the newlines there as a visual distinction, in case anyone actually needs to *read* the HTML. :)$str =~ s/\n\n/<p>\n\n/g; $str =~ s/\n/<br>\n/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: ASCII to HTML
by chromatic (Archbishop) on Apr 05, 2000 at 02:12 UTC | |
by btrott (Parson) on Apr 05, 2000 at 02:53 UTC | |
by little_mistress (Monk) on Apr 05, 2000 at 23:11 UTC | |
|
Re: Re: ASCII to HTML
by tecdady (Initiate) on Jun 19, 2002 at 00:56 UTC |