chunlou has asked for the wisdom of the Perl Monks concerning the following question:

It's common for many people to denote paragraph in html with line break tag:

TEXT<br><br> MORETEXT<br><br>

instead of paragraph tag:

<p>TEXT</p> <p>MORETEXT</p>

Any existing snippets or modules that convert all <br> paragraph to <p> paragraph in a html file?

Thanks.

Replies are listed 'Best First'.
Re: Convert line break: TEXT<br><br> to paragraph: <p>TEXT</p>
by Anonymous Monk on Jul 03, 2003 at 00:02 UTC
    As you already know, TEXT<br /><br /> is not the same thing as <p>TEXT</p>. That would be the equivalent of comparing <h2>TEXT</h2> to <b>TEXT</b>.

    I'd personally look at how the page you're seeing is constructed, and convert on an as-needed basis. There are many uses for <br />, which do not necessarily convert to <p> directly.

    Look into HTML::TokeParser and HTML::TreeBuilder to abstract the text values of those tags and put them inside your nested paragraph tags.

    Just be aware that what you're doing is most-likely entirely wrong, but perl will let you do it.