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
First blank: extra closing tags. Probably OK.
Second blank: I think this means tags aren't closed in order. I'm not entirely sure how A works, though, or what a<0 means practically.
Third blank: extra closing tags and tags not closed in order, I think.
Fourth blank: Tags not closed in order, but all close.
Fifth blank: extra closing tags and tags not closed in order.
(I'm not even going to try to put that in a table, because I know I'll break something.)
Oh this is just
spiralling
out of control, or at least it's gone too far for my brain to figure it out.
I just noticed that
<b>test test test <i>test</i></i>
causes the total tag count to come out to zero, because of course the too-many-b-tags is cancelled out by the not-enough-i-tags and so it's giving the all clear.
Brain Hurt. Need Alcohol. But -- Payday Tomorrow! What Do?
I'm not entirely sure how A works, though, or what a<0 means practically
A goes like this: when we find an opening tag, put it onto the end of a list of opening tags. When we find a closing tag, if it matches the last item in the list of opening tags, we remove the last item of the list.
So if we encounter B, then, I, then FONT, and then later we encounter /FONT, then /I, then /B, we got as high as three and then went back to zero.
So it's logically impossible for A to be less than zero, because the only cases in which stuff gets removed are based on there still being at least one tag in A.
So we don't need "A less than zero" cases after all.
I think you should drop the associative array. You don't need it.
Instead, each time you find an open tag, push it into the array. Each time you find a closing tag, search your array from the end going backwards until you find a matching open. Delete the matching open from the array.
At the end, walk the array backwards and emit one closing tag for each opening tag still in the array.
Back to:
A
B
Diagnosis
0
0
Everything is fine.
0
>0
Broken
0
<0
>0
0
>0
>0
Broken
>0
<0
you should drop the associative array. You don't need it.
Why did I think I needed it? Oh yeah, because the array might not work if the closing tags were present, just not in the right order. And your recipe fixes that.
What do people think? It's certainly a flawed implementation the way it is now, just giving an overall total, because like I said, 1000 missing open-bold tags and 1000 extra close-font tags comes out to zero, giving a false negative.
First blank: extra closing tags. Probably OK.
Second blank: tags out of order, but all close. Probably OK.
Third blank: tags closed out of order, plus extra closing tags.
extra closing tags. Probably OK.
...unless one of them is
t /table
Yeah this is just a check of formatting tags at the moment. The problem with table tags is you can't just count them, you have to validate a structure: TABLEs containing x number of TRs containing x number of TDs...
I think I might have to go back to that link with the full PHP parser...
I bet that if you put in a close table tag for each open table tag, the board wouldn't be broken and all would be good. The message itself might look like crap, but we're not trying to solve that problem.
John, if you'll send me a copy of the test setup from your server, I'll take a whack at coding it up tonight.