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