PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Dec 05, 2019 8:01 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Wed Dec 22, 2010 8:38 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Wed Dec 22, 2010 8:59 pm 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
If a tag is never opened or a tag is never closed, the regexp will not detect it and will just leave it alone.
Wondering why correct the invalid nesting instead of just parsing it?

Edit| I mean, if a parser could be wrote to correct all invalid nests and open and close tags, then that would be beyond the scope of amazing. But seems like a rather complex chore.

_________________
- A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
PostPosted: Wed Dec 22, 2010 9:20 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
If you can define expected inputs & outputs, I think I could wing whatever is specified. However IMO the list of specs could become rather large if we try and do too much, I think its definitely worth considering.

Perhaps before we do that, we could do one that outputs invalid XHTML (and keep that as a separate mode as well)? That will provide some value to some users, and help us better gauge the complexity. Or not?


Top
 Profile  
 
PostPosted: Wed Dec 22, 2010 9:50 pm 
Offline
Tranquility In Moderation
User avatar

Joined: Sun Feb 06, 2005 8:18 pm
Posts: 5001
Location: Indiana
OK, I think there are several "modes" here that have been discussed (from my understanding)

1) As it currently is
2) One that parses all tags, even if they're improperly nested, producing invalid xhtml
3) One that produces valid xhtml
4) One that fixes invalid nesting and produces valid xhtml

Have I got it straight?

1 and 2 would be great. 3 would be awesome, 4 would be asking too much (though definitely cool)

And if 3 or 4 were to be done, wouldn't that replace 1 and 2? (I mean why have 1 and 2, if 3-4 could do the same thing but with valid output)

_________________
- A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.


Top
 Profile  
 
PostPosted: Wed Dec 22, 2010 10:06 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
1 & 3 sound the same.


Top
 Profile  
 
PostPosted: Wed Dec 22, 2010 11:27 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California
Lets start with adding number 2. We already have 1/3, all we have to do is break it out into a separate object, then create a drop-in replacement that uses method 2.


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 12:13 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 1:52 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California
I'll start on separating out the matching object sometime today, probably this morning.


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 3:39 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California
Done. Feedback?


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 10:43 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida


Top
 Profile  
 
PostPosted: Thu Dec 23, 2010 11:42 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Fri Dec 24, 2010 12:10 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida


Top
 Profile  
 
PostPosted: Fri Dec 24, 2010 12:28 am 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Tue Jan 04, 2011 5:47 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
The way I'd recommend tackling this new strategy is to first get the old strategy under unit test. Right now its tested indirectly thru "base.php".

(@Jonah & Scott)
The way I understand this currently works is the current strategy finds "positions" of matches. It then loops thru matches, replacing with replacements. Each time it does this it factors in the difference of the length of the old & new text, so that it can update the positions. (the difference in length between the matched text & the text to be substituted is subtracted from the positions of all remaining matches)

We have no unit tests that show that these sub-systems find the right positions, but we do show that the thing as a whole works, in our tests.

I'd find it really easy to do this feature, if we first had some tests that shows the inputs & outputs for finding positions with the current strategy. From there I could duplicate the tests, and modify the expected positions as per the new algorithm, from there I could duplicate & change the existing implementation and modify it to do matching differently until the tests pass, then we could refactor. I don't mean to rant about tests, just saying how I'd keep the ball rolling if I were familiar enough with the code, or if it had enough tests for me to do this in this area.

If you guys can get at least 1 test showing an input string, and the output array of positions, I could probably take it from there...


Top
 Profile  
 
PostPosted: Fri Jan 07, 2011 2:48 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group