KISSY.Editor.add("htmlparser-htmlwriter",function(){function h(){h.superclass.constructor.call(this);this.indentationChars="\t";this.selfClosingEnd=" />";this.lineBreakChars="\n";this.forceSimpleAmpersand=e;this.sortAttributes=d;this._.indent=e;this._.indentation="";this._.rules={};var b=g.XHTML_DTD,a;for(a in i.mix({},b.$nonBodyContent,b.$block,b.$listItem,b.$tableContent))this.setRules(a,{indent:d,breakBeforeOpen:d,breakAfterOpen:d,breakBeforeClose:!b[a]["#"],breakAfterClose:d});this.setRules("br",
{breakAfterOpen:d});this.setRules("title",{indent:e,breakAfterOpen:e});this.setRules("style",{indent:e,breakBeforeClose:d});this.setRules("pre",{indent:e})}var c=KISSY,g=c.Editor,i=g.Utils,d=true,e=false;c.extend(h,g.HtmlParser.BasicWriter,{openTag:function(b){var a=this._.rules[b];if(this._.indent)this.indentation();else if(a&&a.breakBeforeOpen){this.lineBreak();this.indentation()}this._.output.push("<",b)},openTagClose:function(b,a){var f=this._.rules[b];if(a)this._.output.push(this.selfClosingEnd);
else{this._.output.push(">");if(f&&f.indent)this._.indentation+=this.indentationChars}f&&f.breakAfterOpen&&this.lineBreak()},attribute:function(b,a){if(typeof a=="string"){this.forceSimpleAmpersand&&(a=a.replace(/&amp;/g,"&"));a=i.htmlEncodeAttr(a)}this._.output.push(" ",b,'="',a,'"')},closeTag:function(b){var a=this._.rules[b];if(a&&a.indent)this._.indentation=this._.indentation.substr(this.indentationChars.length);if(this._.indent)this.indentation();else if(a&&a.breakBeforeClose){this.lineBreak();
this.indentation()}this._.output.push("</",b,">");a&&a.breakAfterClose&&this.lineBreak()},text:function(b){if(this._.indent){this.indentation();b=i.ltrim(b)}this._.output.push(b)},comment:function(b){this._.indent&&this.indentation();this._.output.push("<!--",b,"--\>")},lineBreak:function(){this._.output.length>0&&this._.output.push(this.lineBreakChars);this._.indent=d},indentation:function(){this._.output.push(this._.indentation);this._.indent=e},setRules:function(b,a){var f=this._.rules[b];if(f)i.mix(f,
a);else this._.rules[b]=a}});g.HtmlParser.HtmlWriter=h;g.HtmlParser.HtmlWriter=h;c=h.prototype;g.Utils.extern(c,{openTag:c.openTag,openTagClose:c.openTagClose,attribute:c.attribute,closeTag:c.closeTag,text:c.text,comment:c.comment,lineBreak:c.lineBreak,indentation:c.indentation,setRules:c.setRules})});
