(html, options)
| 9284 | } |
| 9285 | |
| 9286 | function parseHTML (html, options) { |
| 9287 | var stack = []; |
| 9288 | var expectHTML = options.expectHTML; |
| 9289 | var isUnaryTag$$1 = options.isUnaryTag || no; |
| 9290 | var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no; |
| 9291 | var index = 0; |
| 9292 | var last, lastTag; |
| 9293 | while (html) { |
| 9294 | last = html; |
| 9295 | // Make sure we're not in a plaintext content element like script/style |
| 9296 | if (!lastTag || !isPlainTextElement(lastTag)) { |
| 9297 | var textEnd = html.indexOf('<'); |
| 9298 | if (textEnd === 0) { |
| 9299 | // Comment: |
| 9300 | if (comment.test(html)) { |
| 9301 | var commentEnd = html.indexOf('-->'); |
| 9302 | |
| 9303 | if (commentEnd >= 0) { |
| 9304 | if (options.shouldKeepComment) { |
| 9305 | options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3); |
| 9306 | } |
| 9307 | advance(commentEnd + 3); |
| 9308 | continue |
| 9309 | } |
| 9310 | } |
| 9311 | |
| 9312 | // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment |
| 9313 | if (conditionalComment.test(html)) { |
| 9314 | var conditionalEnd = html.indexOf(']>'); |
| 9315 | |
| 9316 | if (conditionalEnd >= 0) { |
| 9317 | advance(conditionalEnd + 2); |
| 9318 | continue |
| 9319 | } |
| 9320 | } |
| 9321 | |
| 9322 | // Doctype: |
| 9323 | var doctypeMatch = html.match(doctype); |
| 9324 | if (doctypeMatch) { |
| 9325 | advance(doctypeMatch[0].length); |
| 9326 | continue |
| 9327 | } |
| 9328 | |
| 9329 | // End tag: |
| 9330 | var endTagMatch = html.match(endTag); |
| 9331 | if (endTagMatch) { |
| 9332 | var curIndex = index; |
| 9333 | advance(endTagMatch[0].length); |
| 9334 | parseEndTag(endTagMatch[1], curIndex, index); |
| 9335 | continue |
| 9336 | } |
| 9337 | |
| 9338 | // Start tag: |
| 9339 | var startTagMatch = parseStartTag(); |
| 9340 | if (startTagMatch) { |
| 9341 | handleStartTag(startTagMatch); |
| 9342 | if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) { |
| 9343 | advance(1); |
no test coverage detected