But on the other hand, I was very careful posting that table...
Angel ,'Conviction (1)'
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.
Can someone translate that into an if/elseif/else for me? My brain's in a slump.
If b greater than 0, broken.
elseif a greater than or equal to zero{
if a=b, fine
elseif a greater than 0, bad HTML, tags not closed in order
else, bad HTML, extra closing tags
}
I think. There's no a>0, b<0 option. Should there be?
There's no a>0, b<0 option.
Good question. That would be "tag opened but not closed in correct sequence, but more closing tags found overall than opening".
That could happen. Oh, oh, as could "a greater than one, b equals zero", which it's currently saying is OK.
Hmmm.
How about if I say I've coded up methods A and B and I just want you smart people to tell me what to do with them?
If I have two methods, with three possible outcomes each, that's actually nine cases, isn't it?
If I have two methods, with three possible outcomes each, that's actually nine cases, isn't it?
Yeah, but you're got that b greater than zero is always broken, so that brings it down to six cases (well, seven):
a>0, b=0
a=0, b=0
a<0, b=0
a>0, b<0
a=0, b<0
a<0, b<0
OK, this is really what it looks like:
A B Diagnosis 0 0 Everything is fine. 0 >0 Broken 0 <0 <0 0 <0 >0 Broken <0 <0 >0 0 >0 >0 Broken >0 <0
fill in the blanks for me?
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