| 138 | | function parseHTML(str, strip_tags, ignore_tags){ |
| 139 | | var exp = '^[\\s\\S]*?<html(?:\\s[^>]*)?>|</html\\s*>[\\S\\s]*$'; |
| 140 | | if (strip_tags) { |
| 141 | | strip_tags = strip_tags instanceof Array && strip_tags.length > 1 |
| 142 | | ? '(?:' + strip_tags.join('|') + ')' |
| 143 | | : String(strip_tags); |
| 144 | | exp += '|<' + strip_tags + '(?:\\s[^>]*)?>|</' + strip_tags + '\\s*>'; |
| 145 | | } |
| | 138 | function parseHTML(str, ignore_tags){ |
| | 139 | var exp = "^[\\s\\S]*?<html(?:\\s[^>]*)?>|</html\\s*>[\\S\\s]*$"; |
| 148 | | exp += '|' + ignore_tags.map(function(tag) { |
| 149 | | return '<' + tag + '(?:\\s[^>]*)?>.*?</' + tag + '\\s*>'; |
| 150 | | }).join('|'); |
| 151 | | } |
| 152 | | str = str.replace(new RegExp(exp, 'ig'), ''); |
| 153 | | var res = document.implementation.createDocument(null, 'html', null); |
| | 142 | ignore_tags = ignore_tags.filter(function(tag) { |
| | 143 | if (tag[tag.length - 1] != "/") return true; |
| | 144 | tag = tag.replace(/\/$/, ""); |
| | 145 | exp += "|" + "<" + tag + "(?:\\s[^>]*)?>.*?</" + tag + "\\s*>"; |
| | 146 | return false; |
| | 147 | }); |
| | 148 | if (ignore_tags.length > 0) { |
| | 149 | ignore_tags = ignore_tags.length > 1 |
| | 150 | ? "(?:" + ignore_tags.join("|") + ")" |
| | 151 | : String(ignore_tags); |
| | 152 | exp += "|<" + ignore_tags + "(?:\\s[^>]*)?>|</" + ignore_tags + "\\s*>"; |
| | 153 | } |
| | 154 | } |
| | 155 | str = str.replace(new RegExp(exp, "ig"), ""); |
| | 156 | var res = document.implementation.createDocument(null, "html", null); |