javascript - making a jquery plugin for prettifying html or minifying html -


i wanted make jquery plugin prettifying html code taking indent spaces option.

i wanted know how proceed this. should extract each dom element recursively & store & proceed it?

note: tried above mentioned procedure, doesn't work 4-5 tags & page crashes if there more dom elements passed in function.

the code recursive implementation like:

result=""; function serialize(domnode, indent) { //get tagname & attributes result+="<"+tagname+""+attributes+">"; var children=domnode.childnodes; (var i=0;i<children.length;i++) {     var node=children[i];     if(children[i].nodetype==3) {         result += children[i].data;     }     else if (children[i].nodetype == 1) {         result += serialize(children[i], indent);     } } result += "</"+tagname+">"; } 

ps: know code bad, need better implementations.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -