Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 29th, 2003, 04:04 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
[js] HTML to XHTML

Hello,

I'm currently building a HTML to XHTML parser in JavaScript. I've made a function toArray(); to explode an input string. (ie <b>test</b> becomes array('<b>', 'test', '</b>'));

That function also corrects the HTML following the XHTML standard. The toArray() function returns an Array. That Array is fully XHTML compatible, execpt the nesting part.

Does anyone know of the existance of an algorithm that corrects the nesting of tags?

Reply With Quote
  #2  
Old August 29th, 2003, 07:36 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: [js] HTML to XHTML

uhh.. that is not that simple.

html parsers are very hard to do, since html is really sgml, which is a big brother of xml. xml (and xhtml) was invented to be easier to parse, even if it less capable than sgml.

so, no, i don't think it can easily be done with js.


now, if you are willing to do it on the server side (php?), there is html tidy program that parses "html tag soup" ;) (and/or converts it to xhtml)

http://tidy.sourceforge.net/


even better thing is that libtidy will soon be an extension to php, so, we will be able to do all sorts of neat stuff with it

Reply With Quote
  #3  
Old August 30th, 2003, 07:01 AM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: [js] HTML to XHTML

Well,

I finally managed to create a working parser. This parser converts HTML into XHTML. It's 95% safe and now I'm going to add some new things that are not compatible now. (ie: and IMG tag must have an alt attribute, enz)

I prefer a JS version, since some CMS Wysiwyg editors need XHTML support. Those editors are often made compatible for several programming languages like PHP, ASP, CF, Perl...
So, a JS parser is a perfect solution.
My parser parser a 120kb file (2100 lines of code) in 1.6 sec.

Reply With Quote
  #4  
Old August 30th, 2003, 10:47 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: [js] HTML to XHTML

are you willing to share that code? ;)

Reply With Quote
  #5  
Old August 30th, 2003, 04:47 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: [js] HTML to XHTML

Actually I'm not,

Good HTML to XHTML parsers are hard to find and I've spend lots of hours performance tuning. I'm going to sell the script to several CMS companies.
I already have a customer (yoehoe)...

My script reduced the number of errors on www.devarticles.com from 492 to 16... That's 97% reducing...

So, unfortunately I'm not going the share this stuff

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > [js] HTML to XHTML


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway