Zoe: Next time we smuggle stock, let's make it something smaller. Wash: Yeah, we should start dealing in those black-market beagles.

'Safe'


Buffistas Building a Better Board  

Do you have problems, concerns or recommendations about the technical side of the Phoenix? Air them here. Compliments also welcome.

To-do list


John H - Nov 16, 2002 6:42:33 pm PST #1517 of 10000

what I'm doing is typing "quote, Ctrl-V, quote,"

That'll do it -- just do "quote-quote, left-arrow, Ctrl-V" like Homesite does for you. Same keystrokes.


John H - Nov 16, 2002 6:58:30 pm PST #1518 of 10000

ita, when you have a moment, what are the legal tags here?

I really want to think about the tag-closer code again, but are there any legal tags, apart from <br> which don't need closing?


Jon B. - Nov 16, 2002 7:09:02 pm PST #1519 of 10000
A turkey in every toilet -- only in America!

I wouldn't swear to it, but poking around in the test site i found this list in the post-stripping function:

<a> <b> <i> <u> <ul> <ol> <li> <p> <br> <strike> <table> <tr> <td> <th> <font> <pre> <code>


John H - Nov 16, 2002 7:29:32 pm PST #1520 of 10000

Thanks Jon, that's like strip_tags(the list above), right?

So, only really BR, but what about the ones that don't need to be closed for it to work, but should be for the syntax, like P and LI? Hmmm. More thinking required.


Jon B. - Nov 16, 2002 8:05:02 pm PST #1521 of 10000
A turkey in every toilet -- only in America!

that's like strip_tags(the list above), right?

Pretty much, yeah.

what about the ones that don't need to be closed for it to work, but should be for the syntax, like P and LI?

I'd say close them. I'm all for compliant html where possible.

t edit although I see the problem --- you want the t /li to occur before the next t li or t /ul

Similarly, with the P tag.


John H - Nov 16, 2002 9:33:49 pm PST #1522 of 10000

Having thought about it for a while, it's only the tags that would create formatting problems further down the page that need to be handled. An unclosed LI tag won't cause the rest of the page to be indented, but an unclosed OL or UL will. Unclosed P tags won't cause any problems either.

I'm seeing the logic like this:

Go through the post, creating a list of all potential troublesome tags, i.e. when we encounter the first A tag, put it on a list.

When we encounter the next </A>, take that A tag off the list again.

If there's anything on the list at the end, close it.

It needs some more refinement, but that's essentially it, right?


John H - Nov 16, 2002 9:37:06 pm PST #1523 of 10000

I've just remember that the last big HTML problems were caused by unclosed attributes, not unclosed tags. I don't have any idea how to sort that out...


Rob - Nov 16, 2002 9:39:35 pm PST #1524 of 10000

Could you keep track of all open attributes and close them at the close of a tag?


John H - Nov 16, 2002 10:06:12 pm PST #1525 of 10000

It's possible but scary, to my brain.

I've already roughed out a version in Perl which just counts opening/closing tags. There are either more openings than closings, or there aren't.

It tells me, for this page, that the A tags are right on target, there are exactly the same number opening as closing, but the P tags aren't. Which we'd expect.

If it were are troublesome tag, like B, then it would just insert the closing-B x number of times where x is the difference between openers and closers.

For tags like A, FONT, B, I and so on, it won't necessarily perfect that post as the writer intended, but it should stop the error cascading on down the page at least.

For other tags, for instance table tags, it's a bit more scary.

[EDIT: just realised this script forces me to write "for(@openers)". Ha ha geek ha.]


Rob - Nov 16, 2002 10:25:34 pm PST #1526 of 10000

Well, you know tags can't nest, so you only have to deal with one at a time. It's just like the logic you laid out for tags, only for attributes.

Actually, it's easier then that, isn't it? It's just counting double-quotes, isn't it?

Start counting double quotes when you see a <, and if you have an odd number of them when you see > throw in an extra. Plus a pinch of salt.