(tag, tagName)
| 393 | } |
| 394 | |
| 395 | function parseEndTag(tag, tagName) { |
| 396 | var pos; |
| 397 | |
| 398 | // Find the closest opened tag of the same type |
| 399 | if (tagName) { |
| 400 | pos = findTag(tagName); |
| 401 | } |
| 402 | // If no tag name is provided, clean shop |
| 403 | else { |
| 404 | pos = 0; |
| 405 | } |
| 406 | |
| 407 | if (pos >= 0) { |
| 408 | // Close all the open elements, up the stack |
| 409 | for (var i = stack.length - 1; i >= pos; i--) { |
| 410 | if (handler.end) { |
| 411 | handler.end(stack[i].tag, stack[i].attrs, i > pos || !tag); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | // Remove the open elements from the stack |
| 416 | stack.length = pos; |
| 417 | lastTag = pos && stack[pos - 1].tag; |
| 418 | } |
| 419 | else if (tagName.toLowerCase() === 'br') { |
| 420 | if (handler.start) { |
| 421 | handler.start(tagName, [], true, ''); |
| 422 | } |
| 423 | } |
| 424 | else if (tagName.toLowerCase() === 'p') { |
| 425 | if (handler.start) { |
| 426 | handler.start(tagName, [], false, '', true); |
| 427 | } |
| 428 | if (handler.end) { |
| 429 | handler.end(tagName, []); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | exports.HTMLParser = HTMLParser; |
no test coverage detected
searching dependent graphs…