Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Ensuring HTML is "balanced"

by apotheon (Deacon)
on Mar 09, 2006 at 14:34 UTC ( [id://535395]=note: print w/replies, xml ) Need Help??


in reply to Re: Ensuring HTML is "balanced"
in thread Ensuring HTML is "balanced"

. . . except that you also need to account for closing tags that aren't nested properly. For instance, in the following example, using that simple stack approach would give you extra closing tags:

Try <i><b>this</i></b> on for size.

Instead of fixing improper nesting, a straight-up stack matching approach would give you this:

Try <i><b>this</b></i></b> on for size.

It's also probably best these days to stick to valid XHTML, which means that all tags get closed (for instance, use <hr /> instead of <hr>).

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re^3: Ensuring HTML is "balanced"
by DrHyde (Prior) on Mar 10, 2006 at 12:21 UTC
    Detecting that error is so trivial that I thought it not worthy to mention.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://535395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found