KISSY.Editor.add("htmlparser-filter",function(){function i(a){this._={elementNames:[],attributeNames:[],elements:{$length:0},attributes:{$length:0}};a&&this.addRules(a,10)}function m(a,b){for(var c=0;a&&c<b.length;c++){var d=b[c];a=a.replace(d[0],d[1])}return a}function l(a,b,c){if(typeof b=="function")b=[b];var d,g;g=a.length;var e=b&&b.length;if(e){for(d=0;d<g&&a[d].pri<c;d++);for(g=e-1;g>=0;g--)if(e=b[g]){e.pri=c;a.splice(d,0,e)}}}function n(a,b,c){if(b)for(var d in b){var g=a[d];a[d]=j(g,b[d],
c);g||a.$length++}}function j(a,b,c){if(b){b.pri=c;if(a){if(a.splice)l(a,b,c);else{a=a.pri>c?[b,a]:[a,b];a.filter=p}return a}else return b.filter=b}}function p(a){for(var b=a.type||a instanceof h.HtmlParser.Fragment,c=0;c<this.length;c++){if(b)var d=a.type,g=a.name;var e=this[c].apply(window,arguments);if(e===k)return e;if(b){if(e&&(e.name!=g||e.type!=d))return e}else if(typeof e!="string")return e;e!=undefined&&(a=e)}return a}var f=KISSY,h=f.Editor,o=h.NODE,k=false;f.augment(i,{addRules:function(a,
b){if(typeof b!="number")b=10;l(this._.elementNames,a.elementNames,b);l(this._.attributeNames,a.attributeNames,b);n(this._.elements,a.elements,b);n(this._.attributes,a.attributes,b);this._.text=j(this._.text,a.text,b)||this._.text;this._.comment=j(this._.comment,a.comment,b)||this._.comment;this._.root=j(this._.root,a.root,b)||this._.root},onElementName:function(a){return m(a,this._.elementNames)},onAttributeName:function(a){return m(a,this._.attributeNames)},onText:function(a){var b=this._.text;
return b?b.filter(a):a},onComment:function(a,b){var c=this._.comment;return c?c.filter(a,b):a},onFragment:function(a){var b=this._.root;return b?b.filter(a):a},onElement:function(a){for(var b=[this._.elements["^"],this._.elements[a.name],this._.elements.$],c,d=0;d<3;d++)if(c=b[d]){c=c.filter(a,this);if(c===k)return null;if(c&&c!=a)return this.onNode(c);if(a.parent&&!a.name)break}return a},onNode:function(a){var b=a.type;return b==o.NODE_ELEMENT?this.onElement(a):b==o.NODE_TEXT?new h.HtmlParser.Text(this.onText(a.value)):
null},onAttribute:function(a,b,c){if(b=this._.attributes[b]){a=b.filter(c,a,this);if(a===k)return k;if(typeof a!="undefined")return a}return c}});h.HtmlParser.Filter=i;f=i.prototype;h.Utils.extern(f,{addRules:f.addRules,onElementName:f.onElementName,onAttributeName:f.onAttributeName,onText:f.onText,onComment:f.onComment,onFragment:f.onFragment,onElement:f.onElement,onNode:f.onNode,onAttribute:f.onAttribute});h.HtmlParser.Filter=i});
