/ Published in: ActionScript 3
Sometimes you need to tween htmlText with Tweener and Text Shortcuts :)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function close_dangling_tags(str:String):String { var open_tags:Array = str.match(/<[a-z]+( .*)?(?!\/)>/img).map(function(e:*,i:int,arr:Array):String{return e.substr(1,e.length-2) }); var closed_tags:Array = str.match(/<\/[a-z]+>/img).map(function(e:*,i:int,arr:Array):String{return e.substr(1,e.length-2) }); if (open_tags.length == closed_tags.length){ return str; } var tag_heap:Array = new Array(); for each(var tag:String in open_tags) { tag_heap.push(tag); while (tag_heap.length && closed_tags.length && ArrayTools.last(tag_heap) == ArrayTools.first(closed_tags)) { tag_heap.pop(); closed_tags.shift(); } } return str+tag_heap.reverse().map(function(e:*,i:int,arr:Array):String{return '</'+e+'>'}).join(''); }