Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Proper nesting of HTML to be enforced

by ysth (Canon)
on Feb 05, 2004 at 18:47 UTC ( #326841=note: print w/ replies, xml ) Need Help??


in reply to Proper nesting of HTML to be enforced

The qandaeditors' wiki has:

<B>Above these lines...<p>...top.</B>
that seems to be mishandled. It escapes the /B tag, but isn't adding a </b> before the <p>. (Assuming that the original is bad html, that's what I'm guessing it should be doing.)


Comment on Re: Proper nesting of HTML to be enforced
Download Code
Re^2: Proper nesting of HTML to be enforced (b p /b)
by tye (Cardinal) on Feb 05, 2004 at 19:17 UTC

    That's a design issue for the filter. The B is miss-nested, ending in a different block than it starts. Closing a non-block tag won't force a block tag to be closed. Opening a new block doesn't close non-block tags to prevent (huge?) thrash in existing 'sloppy' HTML that works in most browsers, regardless of what the standard says.

    They aren't perfect heuristics but they seem to work pretty well and are less restrictive than an HTML validator. Of course, it is quite simple and so is not nearly as DWIM as most browsers.

    You can take:

    <B>Above these lines...<p>...top.</B>
    which renders (with your current settings) as
    Above these lines...

    ...top.

    and gets filtered to
    <b>Above these lines...<p>...top.&lt;/B&gt;</p></b>
    and make it valid by changing it to
    <B>Above these lines...</b><p><b>...top.</B> ^^^^ ^^^
    Above these lines...

    ...top.

    or you can just make the PM filter happy with
    <B>Above these lines...<p>...top.</p></B> ^^^^
    Above these lines...

    ...top.

    (which shows the whole thing in bold in my browser, though the HTML validator complains about it)

    If you wanted to see the PM filter close the B tag because of the P tag, you'd need to

    <p><B>Above these lines...<p>...top.</B> ^^^

    Above these lines...

    ...top.

    which would get filtered into
    <p><b>Above these lines...</b></p><p>...top.&lt;/B&gt;</p>

    Above these lines...

    ...top.</B>

    If you have a suggestion for a better heuristic, my ears are open. It'd be interesting to see how many existing nodes would be changed by having a new block close any non-block tags. I'd expect quite a few, but I don't have evidence of that.

    Updated several times right after creation to add more detail in hopes of making things as clear as possible.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-10-30 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls