go ahead... be a heretic | |
PerlMonks |
Re: Re: Re: Fixing Bad HTMLby seattlejohn (Deacon) |
on Nov 17, 2002 at 23:05 UTC ( [id://213614]=note: print w/replies, xml ) | Need Help?? |
Though I'd be inclined to disallow sloppy markup like this (as others have suggested), one option I've used in the past is to backtrack up the stack looking for a matching tag and autoclosing any open tags I pass along the way.
In this case that would proceed something like this. You get to the </B> and look at the tag at the top of the stack. It's not a <B>, it's an <I>, so you generate a </I> yourself and pop that off the stack, then try again. This time it is a <B> so you can just pop it off the top and you move on. The next closing tag is </I>. Since there's no matching open tag on the stack, you simply remove it. $perlmonks{seattlejohn} = 'John Clyman';
In Section
Seekers of Perl Wisdom
|
|