in reply to Re: Removing font tags using HTML::TreeBuilder
in thread Removing font tags using HTML::TreeBuilder

Bah, that won't handle nested font tags properly, this is better
#!/usr/bin/perl -- use warnings; use strict; use HTML::TreeBuilder; my $html = <<'__HTML__'; <p>and a <font face="Verdana">one <a href="link.html">two</a> three</f +ont> four</p> <p>another |<font name="one">one</font>| and another |<font name="two" +> one </font>|</p> <p>6 nested font tags <font>1<font>2<font>3<font>4<font>5<font>6</font>5</font>4</font>3</fo +nt>2</font>1</font> </p> __HTML__ { my $h = HTML::TreeBuilder->new_from_content($html); print $h->as_HTML('<>&',' ',{}), "\n"; for my $font( $h->look_down(_tag => q{font}) ){ $font->replace_with_content( $font->content_refs_list ); } print $h->as_HTML('<>&',' ',{}), "\n"; } __END__ <html> <head> </head> <body> <p>and a <font face="Verdana">one <a href="link.html">two</a> three< +/font> four</p> <p>another |<font name="one">one</font>| and another |<font name="tw +o"> one </font>|</p> <p>6 nested font tags <font>1<font>2<font>3<font>4<font>5<font>6</fo +nt>5</font>4</font>3</font>2</font>1</font></p> </body> </html> <html> <head> </head> <body> <p>and a one <a href="link.html">two</a> three four</p> <p>another |one| and another | one |</p> <p>6 nested font tags 12345654321</p> </body> </html>