(html)
| 48 | } |
| 49 | |
| 50 | function parseHtml(html) { |
| 51 | var stripWayback = options.stripWayback || false |
| 52 | if (stripWayback) { |
| 53 | html = stripWaybackToolbar(html) |
| 54 | } |
| 55 | var $ = cheerio.load(html) |
| 56 | result.pageTitle = $('head > title').text() |
| 57 | result.html = html |
| 58 | |
| 59 | $('[rel=stylesheet]').each(function () { |
| 60 | var link = $(this).attr('href') |
| 61 | if (isPresent(link)) { |
| 62 | result.links.push(createLink(link, url)) |
| 63 | } else { |
| 64 | result.styles.push(stripHtmlComments($(this).html())) |
| 65 | } |
| 66 | }) |
| 67 | |
| 68 | $('style').each(function () { |
| 69 | result.styles.push(stripHtmlComments($(this).html())) |
| 70 | }) |
| 71 | |
| 72 | status.total = result.links.length + result.styles.length |
| 73 | if (!status.total) { |
| 74 | handleResolve() |
| 75 | } |
| 76 | |
| 77 | result.links.forEach(function (link) { |
| 78 | getLinkContents(link.url, options) |
| 79 | .then(function (css) { |
| 80 | handleCssFromLink(link, css) |
| 81 | }) |
| 82 | .catch(function (error) { |
| 83 | link.error = error |
| 84 | status.parsed++ |
| 85 | handleResolve() |
| 86 | }) |
| 87 | }) |
| 88 | |
| 89 | result.styles.forEach(function (css) { |
| 90 | result.css += css |
| 91 | status.parsed++ |
| 92 | handleResolve() |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | function handleCssFromLink(link, css) { |
| 97 | link.css += css |
no test coverage detected
searching dependent graphs…