Hi,RegExes sind für das relativ unstrukturierte HTML ziemlich ungeeignet, aber Du kannst es so machen (TreeBuilder parst das HTML, PrettyPrinter gibt formatierten und KORRIGIERTEN code aus):
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder;my $content = '<p>Hallo ich bin Blindtext. Mehr zu Blindetexten gibt es auf <a href="http://domain.de">doma <a href="index.php?articleId=45">...zum Artikel</a>';
my $tree = HTML::TreeBuilder->new;
$tree->parse_content($content);
my $hpp = new HTML::PrettyPrinter (
'linelength' => 130,
'quote_attr' => 1,
'allow_forced_nl'=> 1,
);
$hpp->set_force_nl(1,qw(body head table tr td));
$hpp->nl_before(2,qw(tr td p));
my $linearray_ref = $hpp->format($tree);
my $new_content = join('', @{$linearray_ref});
print $new_content;
Gruss,
svenXY
Datum: 06.12.2005-08:24
