in reply to How do I remove newlines between nested different delimiters on different lines?

If you want this kind of things done "properly" you could use HTML::Parser (or some friend). It's quite easy to use and you can format the tags in whatever way you want.

Here's one way of doing it:
use HTML::Parser; sub quote { my ($delim, $text) = @_; $text =~ s/([\\\Q$delim\E])/\\$1/g; return "$delim$text$delim"; } sub fix_tags { my ($tags) = @_; my $result; my $p = HTML::Parser::->new( api_version => 3, start_h => [ sub { my ($tagname, $attr, $attrseq) = @_; my @pairs = map { "$_=" . quote('"', $attr->{$_}) } @$attrseq; $result .= '<' . join(' ', $tagname, @pairs) . '>'; }, 'tagname, attr, attrseq' ], default_h => [ sub { $result .= shift }, 'text' ], ); $p->parse($html); return $result; }
Cheers,
-Anomo
  • Comment on Re: How do I remove newlines between nested different delimiters on different lines?
  • Download Code