| Next: HTML::BreakupText | Previous: HTML::AddNoFollow | [Table of Contents] |
HTML::Balance - A simple Perl module to ensure HTML is "balanced".
#!/usr/bin/perl -w
use HTML::Balance;
use strict;
my $html = q[ <p><i>This is a <b>test</i></p>];
my $output = HTML::Balance::balance( $html );
If you wish to display user supplied HTML text you may well find yourself a victim of people submitting malformed text, with tags that are not closed.
This module is designed to prevent that.
This code was taken from discussions held on Perlmonks. For full details please see the following URI:
http://www.perlmonks.org/?node_id=534760
Balance some HTML using the HTML::TreeBuilder module. This is designed to ensure all open HTML tags are closed.
Steve Kemp
http://www.steve.org.uk/
Copyright (c) 2005 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.