CKEDITOR.plugins.add('htmlwriter');CKEDITOR.htmlWriter=CKEDITOR.tools.createClass({base:CKEDITOR.htmlParser.basicWriter,$:function(){var c=this;c.base();c.indentationChars='\t';c.selfClosingEnd=' />';c.lineBreakChars='\n';c.forceSimpleAmpersand=0;c.sortAttributes=1;c._.indent=0;c._.indentation='';c._.inPre=0;c._.rules={};var a=CKEDITOR.dtd;for(var b in CKEDITOR.tools.extend({},a.$nonBodyContent,a.$block,a.$listItem,a.$tableContent))c.setRules(b,{indent:1,breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:!a[b]['#'],breakAfterClose:1});c.setRules('br',{breakAfterOpen:1});c.setRules('title',{indent:0,breakAfterOpen:0});c.setRules('style',{indent:0,breakBeforeClose:1});c.setRules('pre',{indent:0});},proto:{openTag:function(a,b){var d=this;var c=d._.rules[a];if(d._.indent)d.indentation();else if(c&&c.breakBeforeOpen){d.lineBreak();d.indentation();}d._.output.push('<',a);},openTagClose:function(a,b){var d=this;var c=d._.rules[a];if(b)d._.output.push(d.selfClosingEnd);else{d._.output.push('>');if(c&&c.indent)d._.indentation+=d.indentationChars;}if(c&&c.breakAfterOpen)d.lineBreak();a=='pre'&&(d._.inPre=1);},attribute:function(a,b){if(typeof b=='string'){this.forceSimpleAmpersand&&(b=b.replace(/&amp;/g,'&'));b=CKEDITOR.tools.htmlEncodeAttr(b);}this._.output.push(' ',a,'="',b,'"');},closeTag:function(a){var c=this;var b=c._.rules[a];if(b&&b.indent)c._.indentation=c._.indentation.substr(c.indentationChars.length);if(c._.indent)c.indentation();else if(b&&b.breakBeforeClose){c.lineBreak();c.indentation();}c._.output.push('</',a,'>');a=='pre'&&(c._.inPre=0);if(b&&b.breakAfterClose)c.lineBreak();},text:function(a){var b=this;if(b._.indent){b.indentation();!b._.inPre&&(a=CKEDITOR.tools.ltrim(a));}b._.output.push(a);},comment:function(a){if(this._.indent)this.indentation();this._.output.push('<!--',a,'-->');},lineBreak:function(){var a=this;if(!a._.inPre&&a._.output.length>0)a._.output.push(a.lineBreakChars);a._.indent=1;},indentation:function(){var a=this;if(!a._.inPre)a._.output.push(a._.indentation);a._.indent=0;},setRules:function(a,b){var c=this._.rules[a];if(c)CKEDITOR.tools.extend(c,b,true);else this._.rules[a]=b;}}});
