mercury-parser/dist/generate-custom-parser.js.map
Adam Pash 8f42e119e8 feat: generator for custom parsers and some documentation
Squashed commit of the following:

commit deaf9e60d031d9ee06e74b8c0895495b187032a5
Author: Adam Pash <adam.pash@gmail.com>
Date:   Tue Sep 20 10:31:09 2016 -0400

    chore: README for custom parsers

commit a8e8ad633e0d1576a52dbc90ce31b98fb2ec21ee
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 23:36:09 2016 -0400

    draft of readme

commit 4f0f463f821465c282ce006378e5d55f8f41df5f
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 17:56:34 2016 -0400

    custom extractor used to build basic parser for theatlantic

commit c5562a3cede41f56c4e723dcfa1181b49dcaae4d
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 17:20:13 2016 -0400

    pre-commit to test custom parser generator

commit 7d50d5b7ab780b79fae38afcb87a7d1da5d139b2
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 17:19:55 2016 -0400

    feat: added nytimes parser

commit 58b8d83a56927177984ddfdf70830bc4f328f200
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 17:17:28 2016 -0400

    feat: can do fuzzy search or go straight to file

commit c99add753723a8e2ac64d51d7379ac8e23125526
Author: Adam Pash <adam.pash@gmail.com>
Date:   Mon Sep 19 10:52:26 2016 -0400

    refactored export for custom extractors for easier renames

commit 22563413669651bb497f1bb2a92085b71f2ae324
Author: Adam Pash <adam.pash@gmail.com>
Date:   Fri Sep 16 17:36:13 2016 -0400

    feat: custom extractor generation in place

commit 2285a29908a7f82a5de3c81f6b2b902ddec9bdaa
Author: Adam Pash <adam.pash@gmail.com>
Date:   Fri Sep 16 16:42:20 2016 -0400

    good progress
2016-09-20 10:37:03 -04:00

1 line
212 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"file":null,"sources":["mercury.js","../scripts/templates/insert-values.js","../scripts/templates/index.js","../scripts/templates/custom-extractor.js","../scripts/templates/custom-extractor-test.js","../scripts/generate-custom-parser.js"],"sourcesContent":["'use strict';\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar URL = _interopDefault(require('url'));\nvar babelPolyfill = require('babel-polyfill');\nvar cheerio = _interopDefault(require('cheerio'));\nvar request = _interopDefault(require('request'));\nvar stringDirection = _interopDefault(require('string-direction'));\nvar validUrl = _interopDefault(require('valid-url'));\nvar moment = _interopDefault(require('moment'));\nvar wuzzy = _interopDefault(require('wuzzy'));\nvar difflib = _interopDefault(require('difflib'));\nvar ellipsize = _interopDefault(require('ellipsize'));\n\nvar _marked = [range].map(regeneratorRuntime.mark);\n\nfunction range() {\n var start = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];\n var end = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];\n return regeneratorRuntime.wrap(function range$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(start <= end)) {\n _context.next = 5;\n break;\n }\n\n _context.next = 3;\n return start += 1;\n\n case 3:\n _context.next = 0;\n break;\n\n case 5:\n case \"end\":\n return _context.stop();\n }\n }\n }, _marked[0], this);\n}\n\n// extremely simple url validation as a first step\nfunction validateUrl(_ref) {\n var hostname = _ref.hostname;\n\n // If this isn't a valid url, return an error message\n return !!hostname;\n}\n\nvar Errors = {\n badUrl: {\n error: true,\n messages: 'The url parameter passed does not look like a valid URL. Please check your data and try again.'\n }\n};\n\nvar REQUEST_HEADERS = {\n 'User-Agent': 'Readability - http://readability.com/about/'\n};\n\n// The number of milliseconds to attempt to fetch a resource before timing out.\nvar FETCH_TIMEOUT = 10000;\n\n// Content types that we do not extract content from\nvar BAD_CONTENT_TYPES = ['audio/mpeg', 'image/gif', 'image/jpeg', 'image/jpg'];\n\nvar BAD_CONTENT_TYPES_RE = new RegExp('^(' + BAD_CONTENT_TYPES.join('|') + ')$', 'i');\n\n// Use this setting as the maximum size an article can be\n// for us to attempt parsing. Defaults to 5 MB.\nvar MAX_CONTENT_LENGTH = 5242880;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n};\n\nvar asyncToGenerator = function (fn) {\n return function () {\n var gen = fn.apply(this, arguments);\n return new Promise(function (resolve, reject) {\n function step(key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n return Promise.resolve(value).then(function (value) {\n return step(\"next\", value);\n }, function (err) {\n return step(\"throw\", err);\n });\n }\n }\n\n return step(\"next\");\n });\n };\n};\n\nvar defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\nvar slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n}();\n\nfunction get(options) {\n return new Promise(function (resolve, reject) {\n request(options, function (err, response, body) {\n if (err) {\n reject(err);\n } else {\n resolve({ body: body, response: response });\n }\n });\n });\n}\n\n// Evaluate a response to ensure it's something we should be keeping.\n// This does not validate in the sense of a response being 200 level or\n// not. Validation here means that we haven't found reason to bail from\n// further processing of this url.\n\nfunction validateResponse(response) {\n var parseNon2xx = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];\n\n // Check if we got a valid status code\n if (response.statusMessage !== 'OK') {\n if (!response.statusCode) {\n throw new Error('Unable to fetch content. Original exception was ' + response.error);\n } else if (!parseNon2xx) {\n throw new Error('Resource returned a response status code of ' + response.statusCode + ' and resource was instructed to reject non-2xx level status codes.');\n }\n }\n\n var _response$headers = response.headers;\n var contentType = _response$headers['content-type'];\n var contentLength = _response$headers['content-length'];\n\n // Check that the content is not in BAD_CONTENT_TYPES\n\n if (BAD_CONTENT_TYPES_RE.test(contentType)) {\n throw new Error('Content-type for this resource was ' + contentType + ' and is not allowed.');\n }\n\n // Check that the content length is below maximum\n if (contentLength > MAX_CONTENT_LENGTH) {\n throw new Error('Content for this resource was too large. Maximum content length is ' + MAX_CONTENT_LENGTH + '.');\n }\n\n return true;\n}\n\n// Set our response attribute to the result of fetching our URL.\n// TODO: This should gracefully handle timeouts and raise the\n// proper exceptions on the many failure cases of HTTP.\n// TODO: Ensure we are not fetching something enormous. Always return\n// unicode content for HTML, with charset conversion.\n\nvar fetchResource = (function () {\n var _ref2 = asyncToGenerator(regeneratorRuntime.mark(function _callee(url, parsedUrl) {\n var options, _ref3, response, body;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n parsedUrl = parsedUrl || URL.parse(encodeURI(url));\n\n options = {\n url: parsedUrl,\n headers: _extends({}, REQUEST_HEADERS),\n timeout: FETCH_TIMEOUT,\n // Don't set encoding; fixes issues\n // w/gzipped responses\n encoding: null,\n // Accept cookies\n jar: true,\n // Accept and decode gzip\n gzip: true,\n // Follow any redirect\n followAllRedirects: true\n };\n _context.next = 4;\n return get(options);\n\n case 4:\n _ref3 = _context.sent;\n response = _ref3.response;\n body = _ref3.body;\n _context.prev = 7;\n\n validateResponse(response);\n return _context.abrupt('return', { body: body, response: response });\n\n case 12:\n _context.prev = 12;\n _context.t0 = _context['catch'](7);\n return _context.abrupt('return', Errors.badUrl);\n\n case 15:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this, [[7, 12]]);\n }));\n\n function fetchResource(_x2, _x3) {\n return _ref2.apply(this, arguments);\n }\n\n return fetchResource;\n})();\n\nfunction convertMetaProp($, from, to) {\n $('meta[' + from + ']').each(function (_, node) {\n var $node = $(node);\n\n var value = $node.attr(from);\n $node.attr(to, value);\n $node.removeAttr(from);\n });\n\n return $;\n}\n\n// For ease of use in extracting from meta tags,\n// replace the \"content\" attribute on meta tags with the\n// \"value\" attribute.\n//\n// In addition, normalize 'property' attributes to 'name' for ease of\n// querying later. See, e.g., og or twitter meta tags.\n\nfunction normalizeMetaTags($) {\n $ = convertMetaProp($, 'content', 'value');\n $ = convertMetaProp($, 'property', 'name');\n return $;\n}\n\nvar IS_LINK = new RegExp('https?://', 'i');\nvar IS_IMAGE = new RegExp('.(png|gif|jpe?g)', 'i');\n\nvar TAGS_TO_REMOVE = ['script', 'style', 'form'].join(',');\n\n// Convert all instances of images with potentially\n// lazy loaded images into normal images.\n// Many sites will have img tags with no source, or an image tag with a src\n// attribute that a is a placeholer. We need to be able to properly fill in\n// the src attribute so the images are no longer lazy loaded.\nfunction convertLazyLoadedImages($) {\n $('img').each(function (_, img) {\n Reflect.ownKeys(img.attribs).forEach(function (attr) {\n var value = img.attribs[attr];\n\n if (attr !== 'src' && IS_LINK.test(value) && IS_IMAGE.test(value)) {\n $(img).attr('src', value);\n }\n });\n });\n\n return $;\n}\n\nfunction isComment(index, node) {\n return node.type === 'comment';\n}\n\nfunction cleanComments($) {\n $.root().find('*').contents().filter(isComment).remove();\n\n return $;\n}\n\nfunction clean($) {\n $(TAGS_TO_REMOVE).remove();\n\n $ = cleanComments($);\n return $;\n}\n\nvar Resource = {\n\n // Create a Resource.\n //\n // :param url: The URL for the document we should retrieve.\n // :param response: If set, use as the response rather than\n // attempting to fetch it ourselves. Expects a\n // string.\n create: function create(url, preparedResponse, parsedUrl) {\n var _this = this;\n\n return asyncToGenerator(regeneratorRuntime.mark(function _callee() {\n var result, validResponse;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n result = void 0;\n\n if (!preparedResponse) {\n _context.next = 6;\n break;\n }\n\n validResponse = {\n statusMessage: 'OK',\n statusCode: 200,\n headers: {\n 'content-type': 'text/html',\n 'content-length': 500\n }\n };\n\n\n result = { body: preparedResponse, response: validResponse };\n _context.next = 9;\n break;\n\n case 6:\n _context.next = 8;\n return fetchResource(url, parsedUrl);\n\n case 8:\n result = _context.sent;\n\n case 9:\n if (!result.error) {\n _context.next = 11;\n break;\n }\n\n return _context.abrupt('return', result);\n\n case 11:\n return _context.abrupt('return', _this.generateDoc(result));\n\n case 12:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, _this);\n }))();\n },\n generateDoc: function generateDoc(_ref) {\n var content = _ref.body;\n var response = _ref.response;\n var contentType = response.headers['content-type'];\n\n // TODO: Implement is_text function from\n // https://github.com/ReadabilityHoldings/readability/blob/8dc89613241d04741ebd42fa9fa7df1b1d746303/readability/utils/text.py#L57\n\n if (!contentType.includes('html') && !contentType.includes('text')) {\n throw new Error('Content does not appear to be text.');\n }\n\n var $ = cheerio.load(content, { normalizeWhitespace: true });\n\n if ($.root().children().length === 0) {\n throw new Error('No children, likely a bad parse.');\n }\n\n $ = normalizeMetaTags($);\n $ = convertLazyLoadedImages($);\n $ = clean($);\n\n return $;\n }\n};\n\nvar NYMagExtractor = {\n domain: 'nymag.com',\n content: {\n // Order by most likely. Extractor will stop on first occurence\n selectors: ['div.article-content', 'section.body', 'article.article'],\n\n // Selectors to remove from the extracted content\n clean: ['.ad', '.single-related-story'],\n\n // Object of tranformations to make on matched elements\n // Each key is the selector, each value is the tag to\n // transform to.\n // If a function is given, it should return a string\n // to convert to or nothing (in which case it will not perform\n // the transformation.\n transforms: {\n // Convert h1s to h2s\n h1: 'h2',\n\n // Convert lazy-loaded noscript images to figures\n noscript: function noscript($node) {\n var $children = $node.children();\n if ($children.length === 1 && $children.get(0).tagName === 'img') {\n return 'figure';\n }\n\n return null;\n }\n }\n },\n\n title: {\n selectors: ['h1.lede-feature-title', 'h1.headline-primary', 'h1']\n },\n\n author: {\n selectors: ['.by-authors', '.lede-feature-author']\n },\n\n dek: {\n selectors: ['.lede-feature-teaser']\n },\n\n date_published: {\n selectors: ['time.article-timestamp[datetime]', 'time.article-timestamp']\n }\n};\n\nvar BloggerExtractor = {\n domain: 'blogspot.com',\n content: {\n // Blogger is insane and does not load its content\n // initially in the page, but it's all there\n // in noscript\n selectors: ['.post-content noscript'],\n\n // Selectors to remove from the extracted content\n clean: [],\n\n // Convert the noscript tag to a div\n transforms: {\n noscript: 'div'\n }\n },\n\n author: {\n selectors: ['.post-author-name']\n },\n\n title: {\n selectors: ['h2.title']\n },\n\n date_published: {\n selectors: ['span.publishdate']\n }\n};\n\nvar WikipediaExtractor = {\n domain: 'wikipedia.org',\n content: {\n selectors: ['#mw-content-text'],\n\n defaultCleaner: false,\n\n // transform top infobox to an image with caption\n transforms: {\n '.infobox img': function infoboxImg($node) {\n var $parent = $node.parents('.infobox');\n // Only prepend the first image in .infobox\n if ($parent.children('img').length === 0) {\n $parent.prepend($node);\n }\n },\n '.infobox caption': 'figcaption',\n '.infobox': 'figure'\n },\n\n // Selectors to remove from the extracted content\n clean: ['.mw-editsection', 'figure tr, figure td, figure tbody', '#toc', '.navbox']\n\n },\n\n author: 'Wikipedia Contributors',\n\n title: {\n selectors: ['h2.title']\n },\n\n date_published: {\n selectors: ['#footer-info-lastmod']\n }\n\n};\n\nvar TwitterExtractor = {\n domain: 'twitter.com',\n\n content: {\n transforms: {\n // We're transforming essentially the whole page here.\n // Twitter doesn't have nice selectors, so our initial\n // selector grabs the whole page, then we're re-writing\n // it to fit our needs before we clean it up.\n '.permalink[role=main]': function permalinkRoleMain($node, $) {\n var tweets = $node.find('.tweet');\n var $tweetContainer = $('<div id=\"TWEETS_GO_HERE\"></div>');\n $tweetContainer.append(tweets);\n $node.replaceWith($tweetContainer);\n },\n\n // Twitter wraps @ with s, which\n // renders as a strikethrough\n s: 'span'\n },\n\n selectors: ['.permalink[role=main]'],\n\n defaultCleaner: false,\n\n clean: ['.stream-item-footer', 'button', '.tweet-details-fixer']\n },\n\n author: {\n selectors: ['.tweet.permalink-tweet .username']\n },\n\n date_published: {\n selectors: ['.permalink-tweet ._timestamp[data-time-ms]']\n }\n\n};\n\nvar NYTimesExtractor = {\n title: {\n selectors: ['.g-headline', 'h1.headline']\n },\n\n author: {\n selectors: ['.g-byline', '.byline']\n },\n\n content: {\n selectors: ['div.g-blocks', 'article#story'],\n\n defaultCleaner: false,\n\n transforms: {\n 'img.g-lazy': function imgGLazy($node) {\n var src = $node.attr('src');\n // const widths = $node.attr('data-widths')\n // .slice(1)\n // .slice(0, -1)\n // .split(',');\n // if (widths.length) {\n // width = widths.slice(-1);\n // } else {\n // width = '900';\n // }\n var width = 640;\n\n src = src.replace('{{size}}', width);\n $node.attr('src', src);\n }\n },\n\n clean: ['.ad', 'header#story-header', '.story-body-1 .lede.video', '.visually-hidden', '#newsletter-promo', '.promo', '.comments-button', '.hidden']\n },\n\n date_published: null,\n\n lead_image_url: null,\n\n dek: null,\n\n next_page_url: null,\n\n excerpt: null\n};\n\nvar Extractors = {\n 'nymag.com': NYMagExtractor,\n 'blogspot.com': BloggerExtractor,\n 'wikipedia.org': WikipediaExtractor,\n 'twitter.com': TwitterExtractor,\n 'www.nytimes.com': NYTimesExtractor\n};\n\n// Spacer images to be removed\nvar SPACER_RE = new RegExp('trans|transparent|spacer|blank', 'i');\n\n// A list of tags to strip from the output if we encounter them.\nvar STRIP_OUTPUT_TAGS = ['title', 'script', 'noscript', 'link', 'style', 'hr', 'embed', 'iframe', 'object'];\n\n// cleanAttributes\nvar REMOVE_ATTRS = ['style', 'align'];\nvar REMOVE_ATTR_SELECTORS = REMOVE_ATTRS.map(function (selector) {\n return '[' + selector + ']';\n});\nvar REMOVE_ATTR_LIST = REMOVE_ATTRS.join(',');\nvar WHITELIST_ATTRS = ['src', 'href', 'class', 'id', 'score'];\nvar WHITELIST_ATTRS_RE = new RegExp('^(' + WHITELIST_ATTRS.join('|') + ')$', 'i');\n\n// removeEmpty\nvar REMOVE_EMPTY_TAGS = ['p'];\nvar REMOVE_EMPTY_SELECTORS = REMOVE_EMPTY_TAGS.map(function (tag) {\n return tag + ':empty';\n}).join(',');\n\n// cleanTags\nvar CLEAN_CONDITIONALLY_TAGS = ['ul', 'ol', 'table', 'div', 'button', 'form'].join(',');\n\n// cleanHeaders\nvar HEADER_TAGS = ['h2', 'h3', 'h4', 'h5', 'h6'];\nvar HEADER_TAG_LIST = HEADER_TAGS.join(',');\n\n// // CONTENT FETCHING CONSTANTS ////\n\n// A list of strings that can be considered unlikely candidates when\n// extracting content from a resource. These strings are joined together\n// and then tested for existence using re:test, so may contain simple,\n// non-pipe style regular expression queries if necessary.\nvar UNLIKELY_CANDIDATES_BLACKLIST = ['ad-break', 'adbox', 'advert', 'addthis', 'agegate', 'aux', 'blogger-labels', 'combx', 'comment', 'conversation', 'disqus', 'entry-unrelated', 'extra', 'foot',\n// 'form', // This is too generic, has too many false positives\n'header', 'hidden', 'loader', 'login', // Note: This can hit 'blogindex'.\n'menu', 'meta', 'nav', 'outbrain', 'pager', 'pagination', 'predicta', // readwriteweb inline ad box\n'presence_control_external', // lifehacker.com container full of false positives\n'popup', 'printfriendly', 'related', 'remove', 'remark', 'rss', 'share', 'shoutbox', 'sidebar', 'sociable', 'sponsor', 'taboola', 'tools'];\n\n// A list of strings that can be considered LIKELY candidates when\n// extracting content from a resource. Essentially, the inverse of the\n// blacklist above - if something matches both blacklist and whitelist,\n// it is kept. This is useful, for example, if something has a className\n// of \"rss-content entry-content\". It matched 'rss', so it would normally\n// be removed, however, it's also the entry content, so it should be left\n// alone.\n//\n// These strings are joined together and then tested for existence using\n// re:test, so may contain simple, non-pipe style regular expression queries\n// if necessary.\nvar UNLIKELY_CANDIDATES_WHITELIST = ['and', 'article', 'body', 'blogindex', 'column', 'content', 'entry-content-asset', 'format', // misuse of form\n'hfeed', 'hentry', 'hatom', 'main', 'page', 'posts', 'shadow'];\n\n// A list of tags which, if found inside, should cause a <div /> to NOT\n// be turned into a paragraph tag. Shallow div tags without these elements\n// should be turned into <p /> tags.\nvar DIV_TO_P_BLOCK_TAGS = ['a', 'blockquote', 'dl', 'div', 'img', 'p', 'pre', 'table'].join(',');\n\n// A list of tags that should be ignored when trying to find the top candidate\n// for a document.\nvar NON_TOP_CANDIDATE_TAGS = ['br', 'b', 'i', 'label', 'hr', 'area', 'base', 'basefont', 'input', 'img', 'link', 'meta'];\n\nvar NON_TOP_CANDIDATE_TAGS_RE = new RegExp('^(' + NON_TOP_CANDIDATE_TAGS.join('|') + ')$', 'i');\n\nvar PHOTO_HINTS = ['figure', 'photo', 'image', 'caption'];\nvar PHOTO_HINTS_RE = new RegExp(PHOTO_HINTS.join('|'), 'i');\n\n// A list of strings that denote a positive scoring for this content as being\n// an article container. Checked against className and id.\n//\n// TODO: Perhaps have these scale based on their odds of being quality?\nvar POSITIVE_SCORE_HINTS = ['article', 'articlecontent', 'instapaper_body', 'blog', 'body', 'content', 'entry-content-asset', 'entry', 'hentry', 'main', 'Normal', 'page', 'pagination', 'permalink', 'post', 'story', 'text', '[-_]copy', // usatoday\n'\\\\Bcopy'];\n\n// The above list, joined into a matching regular expression\nvar POSITIVE_SCORE_RE = new RegExp(POSITIVE_SCORE_HINTS.join('|'), 'i');\n\n// A list of strings that denote a negative scoring for this content as being\n// an article container. Checked against className and id.\n//\n// TODO: Perhaps have these scale based on their odds of being quality?\nvar NEGATIVE_SCORE_HINTS = ['adbox', 'advert', 'author', 'bio', 'bookmark', 'bottom', 'byline', 'clear', 'com-', 'combx', 'comment', 'comment\\\\B', 'contact', 'copy', 'credit', 'crumb', 'date', 'deck', 'excerpt', 'featured', // tnr.com has a featured_content which throws us off\n'foot', 'footer', 'footnote', 'graf', 'head', 'info', 'infotext', // newscientist.com copyright\n'instapaper_ignore', 'jump', 'linebreak', 'link', 'masthead', 'media', 'meta', 'modal', 'outbrain', // slate.com junk\n'promo', 'pr_', // autoblog - press release\n'related', 'respond', 'roundcontent', // lifehacker restricted content warning\n'scroll', 'secondary', 'share', 'shopping', 'shoutbox', 'side', 'sidebar', 'sponsor', 'stamp', 'sub', 'summary', 'tags', 'tools', 'widget'];\n// The above list, joined into a matching regular expression\nvar NEGATIVE_SCORE_RE = new RegExp(NEGATIVE_SCORE_HINTS.join('|'), 'i');\n\n// XPath to try to determine if a page is wordpress. Not always successful.\nvar IS_WP_SELECTOR = 'meta[name=generator][value^=WordPress]';\n\n// A list of words that, if found in link text or URLs, likely mean that\n// this link is not a next page link.\nvar EXTRANEOUS_LINK_HINTS = ['print', 'archive', 'comment', 'discuss', 'e-mail', 'email', 'share', 'reply', 'all', 'login', 'sign', 'single', 'adx', 'entry-unrelated'];\nvar EXTRANEOUS_LINK_HINTS_RE = new RegExp(EXTRANEOUS_LINK_HINTS.join('|'), 'i');\n\n// Match any phrase that looks like it could be page, or paging, or pagination\nvar PAGE_RE = new RegExp('pag(e|ing|inat)', 'i');\n\n// A list of all of the block level tags known in HTML5 and below. Taken from\n// http://bit.ly/qneNIT\nvar BLOCK_LEVEL_TAGS = ['article', 'aside', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'col', 'colgroup', 'dd', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'li', 'map', 'object', 'ol', 'output', 'p', 'pre', 'progress', 'section', 'table', 'tbody', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'ul', 'video'];\nvar BLOCK_LEVEL_TAGS_RE = new RegExp('^(' + BLOCK_LEVEL_TAGS.join('|') + ')$', 'i');\n\n// The removal is implemented as a blacklist and whitelist, this test finds\n// blacklisted elements that aren't whitelisted. We do this all in one\n// expression-both because it's only one pass, and because this skips the\n// serialization for whitelisted nodes.\nvar candidatesBlacklist = UNLIKELY_CANDIDATES_BLACKLIST.join('|');\nvar CANDIDATES_BLACKLIST = new RegExp(candidatesBlacklist, 'i');\n\nvar candidatesWhitelist = UNLIKELY_CANDIDATES_WHITELIST.join('|');\nvar CANDIDATES_WHITELIST = new RegExp(candidatesWhitelist, 'i');\n\nfunction stripUnlikelyCandidates($) {\n // Loop through the provided document and remove any non-link nodes\n // that are unlikely candidates for article content.\n //\n // Links are ignored because there are very often links to content\n // that are identified as non-body-content, but may be inside\n // article-like content.\n //\n // :param $: a cheerio object to strip nodes from\n // :return $: the cleaned cheerio object\n $('*').not('a').each(function (index, node) {\n var $node = $(node);\n var classes = $node.attr('class');\n var id = $node.attr('id');\n if (!id && !classes) return;\n\n var classAndId = (classes || '') + ' ' + (id || '');\n if (CANDIDATES_WHITELIST.test(classAndId)) {\n return;\n } else if (CANDIDATES_BLACKLIST.test(classAndId)) {\n $node.remove();\n }\n });\n\n return $;\n}\n\n// ## NOTES:\n// Another good candidate for refactoring/optimizing.\n// Very imperative code, I don't love it. - AP\n\n\n// Given cheerio object, convert consecutive <br /> tags into\n// <p /> tags instead.\n//\n// :param $: A cheerio object\n\nfunction brsToPs($) {\n var collapsing = false;\n $('br').each(function (index, element) {\n var nextElement = $(element).next().get(0);\n\n if (nextElement && nextElement.tagName === 'br') {\n collapsing = true;\n $(element).remove();\n } else if (collapsing) {\n collapsing = false;\n // $(element).replaceWith('<p />')\n paragraphize(element, $, true);\n }\n });\n\n return $;\n}\n\n// Given a node, turn it into a P if it is not already a P, and\n// make sure it conforms to the constraints of a P tag (I.E. does\n// not contain any other block tags.)\n//\n// If the node is a <br />, it treats the following inline siblings\n// as if they were its children.\n//\n// :param node: The node to paragraphize; this is a raw node\n// :param $: The cheerio object to handle dom manipulation\n// :param br: Whether or not the passed node is a br\n\nfunction paragraphize(node, $) {\n var br = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];\n\n var $node = $(node);\n\n if (br) {\n var sibling = node.nextSibling;\n var p = $('<p></p>');\n\n // while the next node is text or not a block level element\n // append it to a new p node\n while (sibling && !(sibling.tagName && BLOCK_LEVEL_TAGS_RE.test(sibling.tagName))) {\n var nextSibling = sibling.nextSibling;\n $(sibling).appendTo(p);\n sibling = nextSibling;\n }\n\n $node.replaceWith(p);\n $node.remove();\n return $;\n }\n\n return $;\n}\n\nfunction convertDivs($) {\n $('div').each(function (index, div) {\n var $div = $(div);\n var convertable = $div.children(DIV_TO_P_BLOCK_TAGS).length === 0;\n\n if (convertable) {\n convertNodeTo($div, $, 'p');\n }\n });\n\n return $;\n}\n\nfunction convertSpans($) {\n $('span').each(function (index, span) {\n var $span = $(span);\n var convertable = $span.parents('p, div').length === 0;\n if (convertable) {\n convertNodeTo($span, $, 'p');\n }\n });\n\n return $;\n}\n\n// Loop through the provided doc, and convert any p-like elements to\n// actual paragraph tags.\n//\n// Things fitting this criteria:\n// * Multiple consecutive <br /> tags.\n// * <div /> tags without block level elements inside of them\n// * <span /> tags who are not children of <p /> or <div /> tags.\n//\n// :param $: A cheerio object to search\n// :return cheerio object with new p elements\n// (By-reference mutation, though. Returned just for convenience.)\n\nfunction convertToParagraphs($) {\n $ = brsToPs($);\n $ = convertDivs($);\n $ = convertSpans($);\n\n return $;\n}\n\nfunction convertNodeTo($node, $) {\n var tag = arguments.length <= 2 || arguments[2] === undefined ? 'p' : arguments[2];\n\n var node = $node.get(0);\n if (!node) {\n return $;\n }\n\n var _$node$get = $node.get(0);\n\n var attribs = _$node$get.attribs;\n\n var attribString = Reflect.ownKeys(attribs).map(function (key) {\n return key + '=' + attribs[key];\n }).join(' ');\n\n $node.replaceWith('<' + tag + ' ' + attribString + '>' + $node.contents() + '</' + tag + '>');\n return $;\n}\n\nfunction cleanForHeight($img, $) {\n var height = parseInt($img.attr('height'), 10);\n var width = parseInt($img.attr('width'), 10) || 20;\n\n // Remove images that explicitly have very small heights or\n // widths, because they are most likely shims or icons,\n // which aren't very useful for reading.\n if ((height || 20) < 10 || width < 10) {\n $img.remove();\n } else if (height) {\n // Don't ever specify a height on images, so that we can\n // scale with respect to width without screwing up the\n // aspect ratio.\n $img.removeAttr('height');\n }\n\n return $;\n}\n\n// Cleans out images where the source string matches transparent/spacer/etc\n// TODO This seems very aggressive - AP\nfunction removeSpacers($img, $) {\n if (SPACER_RE.test($img.attr('src'))) {\n $img.remove();\n }\n\n return $;\n}\n\nfunction cleanImages($article, $) {\n $article.find('img').each(function (index, img) {\n var $img = $(img);\n\n cleanForHeight($img, $);\n removeSpacers($img, $);\n });\n\n return $;\n}\n\nfunction stripJunkTags(article, $) {\n $(STRIP_OUTPUT_TAGS.join(','), article).remove();\n\n return $;\n}\n\n// H1 tags are typically the article title, which should be extracted\n// by the title extractor instead. If there's less than 3 of them (<3),\n// strip them. Otherwise, turn 'em into H2s.\n\nfunction cleanHOnes(article, $) {\n var $hOnes = $('h1', article);\n\n if ($hOnes.length < 3) {\n $hOnes.each(function (index, node) {\n return $(node).remove();\n });\n } else {\n $hOnes.each(function (index, node) {\n convertNodeTo($(node), $, 'h2');\n });\n }\n\n return $;\n}\n\nfunction removeAllButWhitelist($article) {\n // $('*', article).each((index, node) => {\n $article.find('*').each(function (index, node) {\n node.attribs = Reflect.ownKeys(node.attribs).reduce(function (acc, attr) {\n if (WHITELIST_ATTRS_RE.test(attr)) {\n return _extends({}, acc, defineProperty({}, attr, node.attribs[attr]));\n }\n\n return acc;\n }, {});\n });\n}\n\n// function removeAttrs(article, $) {\n// REMOVE_ATTRS.forEach((attr) => {\n// $(`[${attr}]`, article).removeAttr(attr);\n// });\n// }\n\n// Remove attributes like style or align\nfunction cleanAttributes($article) {\n removeAllButWhitelist($article);\n\n return $article;\n}\n\nfunction removeEmpty($article, $) {\n $article.find('p').each(function (index, p) {\n var $p = $(p);\n if ($p.text().trim() === '') $p.remove();\n });\n\n return $;\n}\n\n// // CONTENT FETCHING CONSTANTS ////\n\n// A list of strings that can be considered unlikely candidates when\n// extracting content from a resource. These strings are joined together\n// and then tested for existence using re:test, so may contain simple,\n// non-pipe style regular expression queries if necessary.\nvar UNLIKELY_CANDIDATES_BLACKLIST$1 = ['ad-break', 'adbox', 'advert', 'addthis', 'agegate', 'aux', 'blogger-labels', 'combx', 'comment', 'conversation', 'disqus', 'entry-unrelated', 'extra', 'foot', 'form', 'header', 'hidden', 'loader', 'login', // Note: This can hit 'blogindex'.\n'menu', 'meta', 'nav', 'pager', 'pagination', 'predicta', // readwriteweb inline ad box\n'presence_control_external', // lifehacker.com container full of false positives\n'popup', 'printfriendly', 'related', 'remove', 'remark', 'rss', 'share', 'shoutbox', 'sidebar', 'sociable', 'sponsor', 'tools'];\n\n// A list of strings that can be considered LIKELY candidates when\n// extracting content from a resource. Essentially, the inverse of the\n// blacklist above - if something matches both blacklist and whitelist,\n// it is kept. This is useful, for example, if something has a className\n// of \"rss-content entry-content\". It matched 'rss', so it would normally\n// be removed, however, it's also the entry content, so it should be left\n// alone.\n//\n// These strings are joined together and then tested for existence using\n// re:test, so may contain simple, non-pipe style regular expression queries\n// if necessary.\nvar UNLIKELY_CANDIDATES_WHITELIST$1 = ['and', 'article', 'body', 'blogindex', 'column', 'content', 'entry-content-asset', 'format', // misuse of form\n'hfeed', 'hentry', 'hatom', 'main', 'page', 'posts', 'shadow'];\n\n// A list of tags which, if found inside, should cause a <div /> to NOT\n// be turned into a paragraph tag. Shallow div tags without these elements\n// should be turned into <p /> tags.\nvar DIV_TO_P_BLOCK_TAGS$1 = ['a', 'blockquote', 'dl', 'div', 'img', 'p', 'pre', 'table'].join(',');\n\n// A list of tags that should be ignored when trying to find the top candidate\n// for a document.\nvar NON_TOP_CANDIDATE_TAGS$1 = ['br', 'b', 'i', 'label', 'hr', 'area', 'base', 'basefont', 'input', 'img', 'link', 'meta'];\n\nvar NON_TOP_CANDIDATE_TAGS_RE$1 = new RegExp('^(' + NON_TOP_CANDIDATE_TAGS$1.join('|') + ')$', 'i');\n\n// A list of selectors that specify, very clearly, either hNews or other\n// very content-specific style content, like Blogger templates.\n// More examples here: http://microformats.org/wiki/blog-post-formats\nvar HNEWS_CONTENT_SELECTORS$1 = [['.hentry', '.entry-content'], ['entry', '.entry-content'], ['.entry', '.entry_content'], ['.post', '.postbody'], ['.post', '.post_body'], ['.post', '.post-body']];\n\nvar PHOTO_HINTS$1 = ['figure', 'photo', 'image', 'caption'];\nvar PHOTO_HINTS_RE$1 = new RegExp(PHOTO_HINTS$1.join('|'), 'i');\n\n// A list of strings that denote a positive scoring for this content as being\n// an article container. Checked against className and id.\n//\n// TODO: Perhaps have these scale based on their odds of being quality?\nvar POSITIVE_SCORE_HINTS$1 = ['article', 'articlecontent', 'instapaper_body', 'blog', 'body', 'content', 'entry-content-asset', 'entry', 'hentry', 'main', 'Normal', 'page', 'pagination', 'permalink', 'post', 'story', 'text', '[-_]copy', // usatoday\n'\\\\Bcopy'];\n\n// The above list, joined into a matching regular expression\nvar POSITIVE_SCORE_RE$1 = new RegExp(POSITIVE_SCORE_HINTS$1.join('|'), 'i');\n\n// Readability publisher-specific guidelines\nvar READABILITY_ASSET$1 = new RegExp('entry-content-asset', 'i');\n\n// A list of strings that denote a negative scoring for this content as being\n// an article container. Checked against className and id.\n//\n// TODO: Perhaps have these scale based on their odds of being quality?\nvar NEGATIVE_SCORE_HINTS$1 = ['adbox', 'advert', 'author', 'bio', 'bookmark', 'bottom', 'byline', 'clear', 'com-', 'combx', 'comment', 'comment\\\\B', 'contact', 'copy', 'credit', 'crumb', 'date', 'deck', 'excerpt', 'featured', // tnr.com has a featured_content which throws us off\n'foot', 'footer', 'footnote', 'graf', 'head', 'info', 'infotext', // newscientist.com copyright\n'instapaper_ignore', 'jump', 'linebreak', 'link', 'masthead', 'media', 'meta', 'modal', 'outbrain', // slate.com junk\n'promo', 'pr_', // autoblog - press release\n'related', 'respond', 'roundcontent', // lifehacker restricted content warning\n'scroll', 'secondary', 'share', 'shopping', 'shoutbox', 'side', 'sidebar', 'sponsor', 'stamp', 'sub', 'summary', 'tags', 'tools', 'widget'];\n// The above list, joined into a matching regular expression\nvar NEGATIVE_SCORE_RE$1 = new RegExp(NEGATIVE_SCORE_HINTS$1.join('|'), 'i');\n\n// A list of all of the block level tags known in HTML5 and below. Taken from\n// http://bit.ly/qneNIT\nvar BLOCK_LEVEL_TAGS$1 = ['article', 'aside', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'col', 'colgroup', 'dd', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'li', 'map', 'object', 'ol', 'output', 'p', 'pre', 'progress', 'section', 'table', 'tbody', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'ul', 'video'];\nvar BLOCK_LEVEL_TAGS_RE$1 = new RegExp('^(' + BLOCK_LEVEL_TAGS$1.join('|') + ')$', 'i');\n\n// The removal is implemented as a blacklist and whitelist, this test finds\n// blacklisted elements that aren't whitelisted. We do this all in one\n// expression-both because it's only one pass, and because this skips the\n// serialization for whitelisted nodes.\nvar candidatesBlacklist$1 = UNLIKELY_CANDIDATES_BLACKLIST$1.join('|');\nvar candidatesWhitelist$1 = UNLIKELY_CANDIDATES_WHITELIST$1.join('|');\nvar PARAGRAPH_SCORE_TAGS$1 = new RegExp('^(p|li|span|pre)$', 'i');\nvar CHILD_CONTENT_TAGS$1 = new RegExp('^(td|blockquote|ol|ul|dl)$', 'i');\nvar BAD_TAGS$1 = new RegExp('^(address|form)$', 'i');\n\n// Get the score of a node based on its className and id.\nfunction getWeight(node) {\n var classes = node.attr('class');\n var id = node.attr('id');\n var score = 0;\n\n if (id) {\n // if id exists, try to score on both positive and negative\n if (POSITIVE_SCORE_RE$1.test(id)) {\n score += 25;\n }\n if (NEGATIVE_SCORE_RE$1.test(id)) {\n score -= 25;\n }\n }\n\n if (classes) {\n if (score === 0) {\n // if classes exist and id did not contribute to score\n // try to score on both positive and negative\n if (POSITIVE_SCORE_RE$1.test(classes)) {\n score += 25;\n }\n if (NEGATIVE_SCORE_RE$1.test(classes)) {\n score -= 25;\n }\n }\n\n // even if score has been set by id, add score for\n // possible photo matches\n // \"try to keep photos if we can\"\n if (PHOTO_HINTS_RE$1.test(classes)) {\n score += 10;\n }\n\n // add 25 if class matches entry-content-asset,\n // a class apparently instructed for use in the\n // Readability publisher guidelines\n // https://www.readability.com/developers/guidelines\n if (READABILITY_ASSET$1.test(classes)) {\n score += 25;\n }\n }\n\n return score;\n}\n\n// returns the score of a node based on\n// the node's score attribute\n// returns null if no score set\nfunction getScore($node) {\n return parseFloat($node.attr('score')) || null;\n}\n\n// return 1 for every comma in text\nfunction scoreCommas(text) {\n return (text.match(/,/g) || []).length;\n}\n\nvar idkRe = new RegExp('^(p|pre)$', 'i');\n\nfunction scoreLength(textLength) {\n var tagName = arguments.length <= 1 || arguments[1] === undefined ? 'p' : arguments[1];\n\n var chunks = textLength / 50;\n\n if (chunks > 0) {\n var lengthBonus = void 0;\n\n // No idea why p or pre are being tamped down here\n // but just following the source for now\n // Not even sure why tagName is included here,\n // since this is only being called from the context\n // of scoreParagraph\n if (idkRe.test(tagName)) {\n lengthBonus = chunks - 2;\n } else {\n lengthBonus = chunks - 1.25;\n }\n\n return Math.min(Math.max(lengthBonus, 0), 3);\n }\n\n return 0;\n}\n\n// Score a paragraph using various methods. Things like number of\n// commas, etc. Higher is better.\nfunction scoreParagraph(node) {\n var score = 1;\n var text = node.text().trim();\n var textLength = text.length;\n\n // If this paragraph is less than 25 characters, don't count it.\n if (textLength < 25) {\n return 0;\n }\n\n // Add points for any commas within this paragraph\n score += scoreCommas(text);\n\n // For every 50 characters in this paragraph, add another point. Up\n // to 3 points.\n score += scoreLength(textLength);\n\n // Articles can end with short paragraphs when people are being clever\n // but they can also end with short paragraphs setting up lists of junk\n // that we strip. This negative tweaks junk setup paragraphs just below\n // the cutoff threshold.\n if (text.slice(-1) === ':') {\n score -= 1;\n }\n\n return score;\n}\n\nfunction setScore($node, $, score) {\n $node.attr('score', score);\n return $node;\n}\n\nfunction addScore($node, $, amount) {\n try {\n var score = getOrInitScore($node, $) + amount;\n setScore($node, $, score);\n } catch (e) {\n // Ignoring; error occurs in scoreNode\n }\n\n return $node;\n}\n\n// Adds 1/4 of a child's score to its parent\nfunction addToParent(node, $, score) {\n var parent = node.parent();\n if (parent) {\n addScore(parent, $, score * 0.25);\n }\n\n return node;\n}\n\n// gets and returns the score if it exists\n// if not, initializes a score based on\n// the node's tag type\nfunction getOrInitScore($node, $) {\n var weightNodes = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];\n\n var score = getScore($node);\n\n if (score) {\n return score;\n }\n\n score = scoreNode($node);\n\n if (weightNodes) {\n score += getWeight($node);\n }\n\n addToParent($node, $, score);\n\n return score;\n}\n\n// Score an individual node. Has some smarts for paragraphs, otherwise\n// just scores based on tag.\nfunction scoreNode($node) {\n var _$node$get = $node.get(0);\n\n var tagName = _$node$get.tagName;\n\n // TODO: Consider ordering by most likely.\n // E.g., if divs are a more common tag on a page,\n // Could save doing that regex test on every node AP\n\n if (PARAGRAPH_SCORE_TAGS$1.test(tagName)) {\n return scoreParagraph($node);\n } else if (tagName === 'div') {\n return 5;\n } else if (CHILD_CONTENT_TAGS$1.test(tagName)) {\n return 3;\n } else if (BAD_TAGS$1.test(tagName)) {\n return -3;\n } else if (tagName === 'th') {\n return -5;\n }\n\n return 0;\n}\n\nfunction convertSpans$1($node, $) {\n if ($node.get(0)) {\n var _$node$get = $node.get(0);\n\n var tagName = _$node$get.tagName;\n\n\n if (tagName === 'span') {\n // convert spans to divs\n convertNodeTo($node, $, 'div');\n }\n }\n}\n\nfunction addScoreTo($node, $, score) {\n if ($node) {\n convertSpans$1($node, $);\n addScore($node, $, score);\n }\n}\n\nfunction scorePs($, weightNodes) {\n $('p, pre').not('[score]').each(function (index, node) {\n // The raw score for this paragraph, before we add any parent/child\n // scores.\n var $node = $(node);\n $node = setScore($node, $, getOrInitScore($node, $, weightNodes));\n\n var $parent = $node.parent();\n var rawScore = scoreNode($node);\n\n addScoreTo($parent, $, rawScore, weightNodes);\n if ($parent) {\n // Add half of the individual content score to the\n // grandparent\n addScoreTo($parent.parent(), $, rawScore / 2, weightNodes);\n }\n });\n\n return $;\n}\n\n// score content. Parents get the full value of their children's\n// content score, grandparents half\nfunction scoreContent($) {\n var weightNodes = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];\n\n // First, look for special hNews based selectors and give them a big\n // boost, if they exist\n HNEWS_CONTENT_SELECTORS$1.forEach(function (_ref) {\n var _ref2 = slicedToArray(_ref, 2);\n\n var parentSelector = _ref2[0];\n var childSelector = _ref2[1];\n\n $(parentSelector + ' ' + childSelector).each(function (index, node) {\n addScore($(node).parent(parentSelector), $, 80);\n });\n });\n\n // Doubling this again\n // Previous solution caused a bug\n // in which parents weren't retaining\n // scores. This is not ideal, and\n // should be fixed.\n scorePs($, weightNodes);\n scorePs($, weightNodes);\n\n return $;\n}\n\nvar NORMALIZE_RE = /\\s{2,}/g;\n\nfunction normalizeSpaces(text) {\n return text.replace(NORMALIZE_RE, ' ').trim();\n}\n\n// Given a node type to search for, and a list of regular expressions,\n// look to see if this extraction can be found in the URL. Expects\n// that each expression in r_list will return group(1) as the proper\n// string to be cleaned.\n// Only used for date_published currently.\nfunction extractFromUrl(url, regexList) {\n var matchRe = regexList.find(function (re) {\n return re.test(url);\n });\n if (matchRe) {\n return matchRe.exec(url)[1];\n }\n\n return null;\n}\n\n// An expression that looks to try to find the page digit within a URL, if\n// it exists.\n// Matches:\n// page=1\n// pg=1\n// p=1\n// paging=12\n// pag=7\n// pagination/1\n// paging/88\n// pa/83\n// p/11\n//\n// Does not match:\n// pg=102\n// page:2\nvar PAGE_IN_HREF_RE = new RegExp('(page|paging|(p(a|g|ag)?(e|enum|ewanted|ing|ination)))?(=|/)([0-9]{1,3})', 'i');\n\nvar HAS_ALPHA_RE = /[a-z]/i;\n\nvar IS_ALPHA_RE = /^[a-z]+$/i;\nvar IS_DIGIT_RE = /^[0-9]+$/i;\n\nfunction pageNumFromUrl(url) {\n var matches = url.match(PAGE_IN_HREF_RE);\n if (!matches) return null;\n\n var pageNum = parseInt(matches[6], 10);\n\n // Return pageNum < 100, otherwise\n // return null\n return pageNum < 100 ? pageNum : null;\n}\n\nfunction removeAnchor(url) {\n return url.split('#')[0].replace(/\\/$/, '');\n}\n\nfunction isGoodSegment(segment, index, firstSegmentHasLetters) {\n var goodSegment = true;\n\n // If this is purely a number, and it's the first or second\n // url_segment, it's probably a page number. Remove it.\n if (index < 2 && IS_DIGIT_RE.test(segment) && segment.length < 3) {\n goodSegment = true;\n }\n\n // If this is the first url_segment and it's just \"index\",\n // remove it\n if (index === 0 && segment.toLowerCase() === 'index') {\n goodSegment = false;\n }\n\n // If our first or second url_segment is smaller than 3 characters,\n // and the first url_segment had no alphas, remove it.\n if (index < 2 && segment.length < 3 && !firstSegmentHasLetters) {\n goodSegment = false;\n }\n\n return goodSegment;\n}\n\n// Take a URL, and return the article base of said URL. That is, no\n// pagination data exists in it. Useful for comparing to other links\n// that might have pagination data within them.\nfunction articleBaseUrl(url, parsed) {\n var parsedUrl = parsed || URL.parse(url);\n var protocol = parsedUrl.protocol;\n var host = parsedUrl.host;\n var path = parsedUrl.path;\n\n\n var firstSegmentHasLetters = false;\n var cleanedSegments = path.split('/').reverse().reduce(function (acc, rawSegment, index) {\n var segment = rawSegment;\n\n // Split off and save anything that looks like a file type.\n if (segment.includes('.')) {\n var _segment$split = segment.split('.');\n\n var _segment$split2 = slicedToArray(_segment$split, 2);\n\n var possibleSegment = _segment$split2[0];\n var fileExt = _segment$split2[1];\n\n if (IS_ALPHA_RE.test(fileExt)) {\n segment = possibleSegment;\n }\n }\n\n // If our first or second segment has anything looking like a page\n // number, remove it.\n if (PAGE_IN_HREF_RE.test(segment) && index < 2) {\n segment = segment.replace(PAGE_IN_HREF_RE, '');\n }\n\n // If we're on the first segment, check to see if we have any\n // characters in it. The first segment is actually the last bit of\n // the URL, and this will be helpful to determine if we're on a URL\n // segment that looks like \"/2/\" for example.\n if (index === 0) {\n firstSegmentHasLetters = HAS_ALPHA_RE.test(segment);\n }\n\n // If it's not marked for deletion, push it to cleaned_segments.\n if (isGoodSegment(segment, index, firstSegmentHasLetters)) {\n acc.push(segment);\n }\n\n return acc;\n }, []);\n\n return protocol + '//' + host + cleanedSegments.reverse().join('/');\n}\n\n// Given a string, return True if it appears to have an ending sentence\n// within it, false otherwise.\nvar SENTENCE_END_RE = new RegExp('.( |$)');\nfunction hasSentenceEnd(text) {\n return SENTENCE_END_RE.test(text);\n}\n\n// Now that we have a top_candidate, look through the siblings of\n// it to see if any of them are decently scored. If they are, they\n// may be split parts of the content (Like two divs, a preamble and\n// a body.) Example:\n// http://articles.latimes.com/2009/oct/14/business/fi-bigtvs14\nfunction mergeSiblings($candidate, topScore, $) {\n if (!$candidate.parent().length) {\n return $candidate;\n }\n\n var siblingScoreThreshold = Math.max(10, topScore * 0.25);\n var wrappingDiv = $('<div></div>');\n\n $candidate.parent().children().each(function (index, sibling) {\n var $sibling = $(sibling);\n // Ignore tags like BR, HR, etc\n if (NON_TOP_CANDIDATE_TAGS_RE$1.test(sibling.tagName)) {\n return null;\n }\n\n var siblingScore = getScore($sibling);\n if (siblingScore) {\n if ($sibling === $candidate) {\n wrappingDiv.append($sibling);\n } else {\n var contentBonus = 0;\n var density = linkDensity($sibling);\n\n // If sibling has a very low link density,\n // give it a small bonus\n if (density < 0.05) {\n contentBonus += 20;\n }\n\n // If sibling has a high link density,\n // give it a penalty\n if (density >= 0.5) {\n contentBonus -= 20;\n }\n\n // If sibling node has the same class as\n // candidate, give it a bonus\n if ($sibling.attr('class') === $candidate.attr('class')) {\n contentBonus += topScore * 0.2;\n }\n\n var newScore = siblingScore + contentBonus;\n\n if (newScore >= siblingScoreThreshold) {\n return wrappingDiv.append($sibling);\n } else if (sibling.tagName === 'p') {\n var siblingContent = $sibling.text();\n var siblingContentLength = textLength(siblingContent);\n\n if (siblingContentLength > 80 && density < 0.25) {\n return wrappingDiv.append($sibling);\n } else if (siblingContentLength <= 80 && density === 0 && hasSentenceEnd(siblingContent)) {\n return wrappingDiv.append($sibling);\n }\n }\n }\n }\n\n return null;\n });\n\n return wrappingDiv;\n}\n\n// After we've calculated scores, loop through all of the possible\n// candidate nodes we found and find the one with the highest score.\nfunction findTopCandidate($) {\n var $candidate = void 0;\n var topScore = 0;\n\n $('[score]').each(function (index, node) {\n // Ignore tags like BR, HR, etc\n if (NON_TOP_CANDIDATE_TAGS_RE$1.test(node.tagName)) {\n return;\n }\n\n var $node = $(node);\n var score = getScore($node);\n\n if (score > topScore) {\n topScore = score;\n $candidate = $node;\n }\n });\n\n // If we don't have a candidate, return the body\n // or whatever the first element is\n if (!$candidate) {\n return $('body') || $('*').first();\n }\n\n $candidate = mergeSiblings($candidate, topScore, $);\n\n return $candidate;\n}\n\nfunction removeUnlessContent($node, $, weight) {\n // Explicitly save entry-content-asset tags, which are\n // noted as valuable in the Publisher guidelines. For now\n // this works everywhere. We may want to consider making\n // this less of a sure-thing later.\n if ($node.hasClass('entry-content-asset')) {\n return;\n }\n\n var content = normalizeSpaces($node.text());\n\n if (scoreCommas(content) < 10) {\n var pCount = $('p', $node).length;\n var inputCount = $('input', $node).length;\n\n // Looks like a form, too many inputs.\n if (inputCount > pCount / 3) {\n $node.remove();\n return;\n }\n\n var contentLength = content.length;\n var imgCount = $('img', $node).length;\n\n // Content is too short, and there are no images, so\n // this is probably junk content.\n if (contentLength < 25 && imgCount === 0) {\n $node.remove();\n return;\n }\n\n var density = linkDensity($node);\n\n // Too high of link density, is probably a menu or\n // something similar.\n // console.log(weight, density, contentLength)\n if (weight < 25 && density > 0.2 && contentLength > 75) {\n $node.remove();\n return;\n }\n\n // Too high of a link density, despite the score being\n // high.\n if (weight >= 25 && density > 0.5) {\n // Don't remove the node if it's a list and the\n // previous sibling starts with a colon though. That\n // means it's probably content.\n var tagName = $node.get(0).tagName;\n var nodeIsList = tagName === 'ol' || tagName === 'ul';\n if (nodeIsList) {\n var previousNode = $node.prev();\n if (previousNode && normalizeSpaces(previousNode.text()).slice(-1) === ':') {\n return;\n }\n }\n\n $node.remove();\n return;\n }\n\n var scriptCount = $('script', $node).length;\n\n // Too many script tags, not enough content.\n if (scriptCount > 0 && contentLength < 150) {\n $node.remove();\n return;\n }\n }\n}\n\n// Given an article, clean it of some superfluous content specified by\n// tags. Things like forms, ads, etc.\n//\n// Tags is an array of tag name's to search through. (like div, form,\n// etc)\n//\n// Return this same doc.\nfunction cleanTags($article, $) {\n $(CLEAN_CONDITIONALLY_TAGS, $article).each(function (index, node) {\n var $node = $(node);\n var weight = getScore($node);\n if (!weight) {\n weight = getOrInitScore($node, $);\n setScore($node, $, weight);\n }\n\n // drop node if its weight is < 0\n if (weight < 0) {\n $node.remove();\n } else {\n // deteremine if node seems like content\n removeUnlessContent($node, $, weight);\n }\n });\n\n return $;\n}\n\nfunction cleanHeaders($article, $) {\n var title = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];\n\n $(HEADER_TAG_LIST, $article).each(function (index, header) {\n var $header = $(header);\n // Remove any headers that appear before all other p tags in the\n // document. This probably means that it was part of the title, a\n // subtitle or something else extraneous like a datestamp or byline,\n // all of which should be handled by other metadata handling.\n if ($($header, $article).prevAll('p').length === 0) {\n return $header.remove();\n }\n\n // Remove any headers that match the title exactly.\n if (normalizeSpaces($(header).text()) === title) {\n return $header.remove();\n }\n\n // If this header has a negative weight, it's probably junk.\n // Get rid of it.\n if (getWeight($(header)) < 0) {\n return $header.remove();\n }\n\n return $header;\n });\n\n return $;\n}\n\n// Rewrite the tag name to div if it's a top level node like body or\n// html to avoid later complications with multiple body tags.\n\nfunction rewriteTopLevel(article, $) {\n // I'm not using context here because\n // it's problematic when converting the\n // top-level/root node - AP\n $ = convertNodeTo($('html'), $, 'div');\n $ = convertNodeTo($('body'), $, 'div');\n\n return $;\n}\n\nfunction absolutize($, rootUrl, attr, $content) {\n $('[' + attr + ']', $content).each(function (_, node) {\n var url = node.attribs[attr];\n var absoluteUrl = URL.resolve(rootUrl, url);\n\n node.attribs[attr] = absoluteUrl;\n });\n}\n\nfunction makeLinksAbsolute($content, $, url) {\n ['href', 'src'].forEach(function (attr) {\n return absolutize($, url, attr, $content);\n });\n\n return $content;\n}\n\nfunction textLength(text) {\n return text.trim().replace(/\\s+/g, ' ').length;\n}\n\n// Determines what percentage of the text\n// in a node is link text\n// Takes a node, returns a float\nfunction linkDensity($node) {\n var totalTextLength = textLength($node.text());\n\n var linkText = $node.find('a').text();\n var linkLength = textLength(linkText);\n\n if (totalTextLength > 0) {\n return linkLength / totalTextLength;\n } else if (totalTextLength === 0 && linkLength > 0) {\n return 1;\n }\n\n return 0;\n}\n\n// Given a node type to search for, and a list of meta tag names to\n// search for, find a meta tag associated.\n\nfunction extractFromMeta($, metaNames, cachedNames) {\n var cleanTags = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];\n\n var foundNames = metaNames.filter(function (name) {\n return cachedNames.indexOf(name) !== -1;\n });\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n var _loop = function _loop() {\n var name = _step.value;\n\n var type = 'name';\n var value = 'value';\n\n var nodes = $('meta[' + type + '=\"' + name + '\"]');\n\n // Get the unique value of every matching node, in case there\n // are two meta tags with the same name and value.\n // Remove empty values.\n var values = nodes.map(function (index, node) {\n return $(node).attr(value);\n }).toArray().filter(function (text) {\n return text !== '';\n });\n\n // If we have more than one value for the same name, we have a\n // conflict and can't trust any of them. Skip this name. If we have\n // zero, that means our meta tags had no values. Skip this name\n // also.\n if (values.length === 1) {\n var metaValue = void 0;\n // Meta values that contain HTML should be stripped, as they\n // weren't subject to cleaning previously.\n if (cleanTags) {\n metaValue = stripTags(values[0], $);\n } else {\n metaValue = values[0];\n }\n\n return {\n v: metaValue\n };\n }\n };\n\n for (var _iterator = foundNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _ret = _loop();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === \"object\") return _ret.v;\n }\n\n // If nothing is found, return null\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n}\n\nfunction isGoodNode($node, maxChildren) {\n // If it has a number of children, it's more likely a container\n // element. Skip it.\n if ($node.children().length > maxChildren) {\n return false;\n }\n // If it looks to be within a comment, skip it.\n if (withinComment($node)) {\n return false;\n }\n\n return true;\n}\n\n// Given a a list of selectors find content that may\n// be extractable from the document. This is for flat\n// meta-information, like author, title, date published, etc.\nfunction extractFromSelectors($, selectors) {\n var maxChildren = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];\n var textOnly = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = selectors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var selector = _step.value;\n\n var nodes = $(selector);\n\n // If we didn't get exactly one of this selector, this may be\n // a list of articles or comments. Skip it.\n if (nodes.length === 1) {\n var $node = $(nodes[0]);\n\n if (isGoodNode($node, maxChildren)) {\n var content = void 0;\n if (textOnly) {\n content = $node.text();\n } else {\n content = $node.html();\n }\n\n if (content) {\n return content;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n}\n\n// strips all tags from a string of text\nfunction stripTags(text, $) {\n // Wrapping text in html element prevents errors when text\n // has no html\n var cleanText = $('<span>' + text + '</span>').text();\n return cleanText === '' ? text : cleanText;\n}\n\nfunction withinComment($node) {\n var parents = $node.parents().toArray();\n var commentParent = parents.find(function (parent) {\n var classAndId = parent.attribs.class + ' ' + parent.attribs.id;\n return classAndId.includes('comment');\n });\n\n return commentParent !== undefined;\n}\n\n// Given a node, determine if it's article-like enough to return\n// param: node (a cheerio node)\n// return: boolean\n\nfunction nodeIsSufficient($node) {\n return $node.text().trim().length >= 100;\n}\n\nfunction isWordpress($) {\n return $(IS_WP_SELECTOR).length > 0;\n}\n\n// CLEAN AUTHOR CONSTANTS\nvar CLEAN_AUTHOR_RE = /^\\s*(posted |written )?by\\s*:?\\s*(.*)/i;\n// author = re.sub(r'^\\s*(posted |written )?by\\s*:?\\s*(.*)(?i)',\n\n// CLEAN DEK CONSTANTS\nvar TEXT_LINK_RE = new RegExp('http(s)?://', 'i');\n// CLEAN DATE PUBLISHED CONSTANTS\nvar MS_DATE_STRING = /^\\d{13}$/i;\nvar SEC_DATE_STRING = /^\\d{10}$/i;\nvar CLEAN_DATE_STRING_RE = /^\\s*published\\s*:?\\s*(.*)/i;\nvar TIME_MERIDIAN_SPACE_RE = /(.*\\d)(am|pm)(.*)/i;\nvar TIME_MERIDIAN_DOTS_RE = /\\.m\\./i;\nvar months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];\nvar allMonths = months.join('|');\nvar timestamp1 = '[0-9]{1,2}:[0-9]{2,2}( ?[ap].?m.?)?';\nvar timestamp2 = '[0-9]{1,2}[/-][0-9]{1,2}[/-][0-9]{2,4}';\nvar SPLIT_DATE_STRING = new RegExp('(' + timestamp1 + ')|(' + timestamp2 + ')|([0-9]{1,4})|(' + allMonths + ')', 'ig');\n\n// CLEAN TITLE CONSTANTS\n// A regular expression that will match separating characters on a\n// title, that usually denote breadcrumbs or something similar.\nvar TITLE_SPLITTERS_RE = /(: | - | \\| )/g;\n\nvar DOMAIN_ENDINGS_RE = new RegExp('.com$|.net$|.org$|.co.uk$', 'g');\n\n// Take an author string (like 'By David Smith ') and clean it to\n// just the name(s): 'David Smith'.\nfunction cleanAuthor(author) {\n return author.replace(CLEAN_AUTHOR_RE, '$2').trim();\n}\n\nfunction clean$1(leadImageUrl) {\n leadImageUrl = leadImageUrl.trim();\n if (validUrl.isWebUri(leadImageUrl)) {\n return leadImageUrl;\n }\n\n return null;\n}\n\n// Take a dek HTML fragment, and return the cleaned version of it.\n// Return None if the dek wasn't good enough.\nfunction cleanDek(dek, _ref) {\n var $ = _ref.$;\n\n // Sanity check that we didn't get too short or long of a dek.\n if (dek.length > 1000 || dek.length < 5) return null;\n\n var dekText = stripTags(dek, $);\n\n // Plain text links shouldn't exist in the dek. If we have some, it's\n // not a good dek - bail.\n if (TEXT_LINK_RE.test(dekText)) return null;\n\n return dekText.trim();\n}\n\n// Is there a compelling reason to use moment here?\n// Mostly only being used for the isValid() method,\n// but could just check for 'Invalid Date' string.\n\nfunction cleanDateString(dateString) {\n return (dateString.match(SPLIT_DATE_STRING) || []).join(' ').replace(TIME_MERIDIAN_DOTS_RE, 'm').replace(TIME_MERIDIAN_SPACE_RE, '$1 $2 $3').replace(CLEAN_DATE_STRING_RE, '$1').trim();\n}\n\n// Take a date published string, and hopefully return a date out of\n// it. Return none if we fail.\nfunction cleanDatePublished(dateString) {\n // If string is in milliseconds or seconds, convert to int\n if (MS_DATE_STRING.test(dateString) || SEC_DATE_STRING.test(dateString)) {\n dateString = parseInt(dateString, 10);\n }\n\n var date = moment(new Date(dateString));\n\n if (!date.isValid()) {\n dateString = cleanDateString(dateString);\n date = moment(new Date(dateString));\n }\n\n return date.isValid() ? date.toISOString() : null;\n}\n\n// Clean our article content, returning a new, cleaned node.\n\nfunction extractCleanNode(article, _ref) {\n var $ = _ref.$;\n var _ref$cleanConditional = _ref.cleanConditionally;\n var cleanConditionally = _ref$cleanConditional === undefined ? true : _ref$cleanConditional;\n var _ref$title = _ref.title;\n var title = _ref$title === undefined ? '' : _ref$title;\n var _ref$url = _ref.url;\n var url = _ref$url === undefined ? '' : _ref$url;\n\n // Rewrite the tag name to div if it's a top level node like body or\n // html to avoid later complications with multiple body tags.\n rewriteTopLevel(article, $);\n\n // Drop small images and spacer images\n cleanImages(article, $);\n\n // Drop certain tags like <title>, etc\n // This is -mostly- for cleanliness, not security.\n stripJunkTags(article, $);\n\n // H1 tags are typically the article title, which should be extracted\n // by the title extractor instead. If there's less than 3 of them (<3),\n // strip them. Otherwise, turn 'em into H2s.\n cleanHOnes(article, $);\n\n // Clean headers\n cleanHeaders(article, $, title);\n\n // Make links absolute\n makeLinksAbsolute(article, $, url);\n\n // Remove unnecessary attributes\n cleanAttributes(article);\n\n // We used to clean UL's and OL's here, but it was leading to\n // too many in-article lists being removed. Consider a better\n // way to detect menus particularly and remove them.\n cleanTags(article, $, cleanConditionally);\n\n // Remove empty paragraph nodes\n removeEmpty(article, $);\n\n return article;\n}\n\nfunction cleanTitle(title, _ref) {\n var url = _ref.url;\n var $ = _ref.$;\n\n // If title has |, :, or - in it, see if\n // we can clean it up.\n if (TITLE_SPLITTERS_RE.test(title)) {\n title = resolveSplitTitle(title, url);\n }\n\n // Final sanity check that we didn't get a crazy title.\n // if (title.length > 150 || title.length < 15) {\n if (title.length > 150) {\n // If we did, return h1 from the document if it exists\n var h1 = $('h1');\n if (h1.length === 1) {\n title = h1.text();\n }\n }\n\n // strip any html tags in the title text\n return stripTags(title, $).trim();\n}\n\nfunction extractBreadcrumbTitle(splitTitle, text) {\n // This must be a very breadcrumbed title, like:\n // The Best Gadgets on Earth : Bits : Blogs : NYTimes.com\n // NYTimes - Blogs - Bits - The Best Gadgets on Earth\n if (splitTitle.length >= 6) {\n var _ret = function () {\n // Look to see if we can find a breadcrumb splitter that happens\n // more than once. If we can, we'll be able to better pull out\n // the title.\n var termCounts = splitTitle.reduce(function (acc, titleText) {\n acc[titleText] = acc[titleText] ? acc[titleText] + 1 : 1;\n return acc;\n }, {});\n\n var _Reflect$ownKeys$redu = Reflect.ownKeys(termCounts).reduce(function (acc, key) {\n if (acc[1] < termCounts[key]) {\n return [key, termCounts[key]];\n }\n\n return acc;\n }, [0, 0]);\n\n var _Reflect$ownKeys$redu2 = slicedToArray(_Reflect$ownKeys$redu, 2);\n\n var maxTerm = _Reflect$ownKeys$redu2[0];\n var termCount = _Reflect$ownKeys$redu2[1];\n\n // We found a splitter that was used more than once, so it\n // is probably the breadcrumber. Split our title on that instead.\n // Note: max_term should be <= 4 characters, so that \" >> \"\n // will match, but nothing longer than that.\n\n if (termCount >= 2 && maxTerm.length <= 4) {\n splitTitle = text.split(maxTerm);\n }\n\n var splitEnds = [splitTitle[0], splitTitle.slice(-1)];\n var longestEnd = splitEnds.reduce(function (acc, end) {\n return acc.length > end.length ? acc : end;\n }, '');\n\n if (longestEnd.length > 10) {\n return {\n v: longestEnd\n };\n }\n\n return {\n v: text\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === \"object\") return _ret.v;\n }\n\n return null;\n}\n\nfunction cleanDomainFromTitle(splitTitle, url) {\n // Search the ends of the title, looking for bits that fuzzy match\n // the URL too closely. If one is found, discard it and return the\n // rest.\n //\n // Strip out the big TLDs - it just makes the matching a bit more\n // accurate. Not the end of the world if it doesn't strip right.\n var _URL$parse = URL.parse(url);\n\n var host = _URL$parse.host;\n\n var nakedDomain = host.replace(DOMAIN_ENDINGS_RE, '');\n\n var startSlug = splitTitle[0].toLowerCase().replace(' ', '');\n var startSlugRatio = wuzzy.levenshtein(startSlug, nakedDomain);\n\n if (startSlugRatio > 0.4 && startSlug.length > 5) {\n return splitTitle.slice(2).join('');\n }\n\n var endSlug = splitTitle.slice(-1)[0].toLowerCase().replace(' ', '');\n var endSlugRatio = wuzzy.levenshtein(endSlug, nakedDomain);\n\n if (endSlugRatio > 0.4 && endSlug.length >= 5) {\n return splitTitle.slice(0, -2).join('');\n }\n\n return null;\n}\n\n// Given a title with separators in it (colons, dashes, etc),\n// resolve whether any of the segments should be removed.\nfunction resolveSplitTitle(title) {\n var url = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];\n\n // Splits while preserving splitters, like:\n // ['The New New York', ' - ', 'The Washington Post']\n var splitTitle = title.split(TITLE_SPLITTERS_RE);\n if (splitTitle.length === 1) {\n return title;\n }\n\n var newTitle = extractBreadcrumbTitle(splitTitle, title);\n if (newTitle) return newTitle;\n\n newTitle = cleanDomainFromTitle(splitTitle, url);\n if (newTitle) return newTitle;\n\n // Fuzzy ratio didn't find anything, so this title is probably legit.\n // Just return it all.\n return title;\n}\n\nvar Cleaners = {\n author: cleanAuthor,\n lead_image_url: clean$1,\n dek: cleanDek,\n date_published: cleanDatePublished,\n content: extractCleanNode,\n title: cleanTitle\n};\n\n// Using a variety of scoring techniques, extract the content most\n// likely to be article text.\n//\n// If strip_unlikely_candidates is True, remove any elements that\n// match certain criteria first. (Like, does this element have a\n// classname of \"comment\")\n//\n// If weight_nodes is True, use classNames and IDs to determine the\n// worthiness of nodes.\n//\n// Returns a cheerio object $\nfunction extractBestNode($, opts) {\n // clone the node so we can get back to our\n // initial parsed state if needed\n // TODO Do I need this? AP\n // let $root = $.root().clone()\n\n\n if (opts.stripUnlikelyCandidates) {\n $ = stripUnlikelyCandidates($);\n }\n\n $ = convertToParagraphs($);\n $ = scoreContent($, opts.weightNodes);\n var $topCandidate = findTopCandidate($);\n\n return $topCandidate;\n}\n\nvar GenericContentExtractor = {\n defaultOpts: {\n stripUnlikelyCandidates: true,\n weightNodes: true,\n cleanConditionally: true\n },\n\n // Extract the content for this resource - initially, pass in our\n // most restrictive opts which will return the highest quality\n // content. On each failure, retry with slightly more lax opts.\n //\n // :param return_type: string. If \"node\", should return the content\n // as a cheerio node rather than as an HTML string.\n //\n // Opts:\n // stripUnlikelyCandidates: Remove any elements that match\n // non-article-like criteria first.(Like, does this element\n // have a classname of \"comment\")\n //\n // weightNodes: Modify an elements score based on whether it has\n // certain classNames or IDs. Examples: Subtract if a node has\n // a className of 'comment', Add if a node has an ID of\n // 'entry-content'.\n //\n // cleanConditionally: Clean the node to return of some\n // superfluous content. Things like forms, ads, etc.\n extract: function extract(_ref, opts) {\n var $ = _ref.$;\n var html = _ref.html;\n var title = _ref.title;\n var url = _ref.url;\n\n opts = _extends({}, this.defaultOpts, opts);\n\n $ = $ || cheerio.load(html);\n\n // Cascade through our extraction-specific opts in an ordered fashion,\n // turning them off as we try to extract content.\n var node = this.getContentNode($, title, url, opts);\n\n if (nodeIsSufficient(node)) {\n return this.cleanAndReturnNode(node, $);\n }\n\n // We didn't succeed on first pass, one by one disable our\n // extraction opts and try again.\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = Reflect.ownKeys(opts).filter(function (k) {\n return opts[k] === true;\n })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n\n opts[key] = false;\n $ = cheerio.load(html);\n\n node = this.getContentNode($, title, url, opts);\n\n if (nodeIsSufficient(node)) {\n break;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return this.cleanAndReturnNode(node, $);\n },\n\n\n // Get node given current options\n getContentNode: function getContentNode($, title, url, opts) {\n return extractCleanNode(extractBestNode($, opts), {\n $: $,\n cleanConditionally: opts.cleanConditionally,\n title: title,\n url: url\n });\n },\n\n\n // Once we got here, either we're at our last-resort node, or\n // we broke early. Make sure we at least have -something- before we\n // move forward.\n cleanAndReturnNode: function cleanAndReturnNode(node, $) {\n if (!node) {\n return null;\n }\n\n return normalizeSpaces($.html(node));\n\n // if return_type == \"html\":\n // return normalize_spaces(node_to_html(node))\n // else:\n // return node\n }\n};\n\n// TODO: It would be great if we could merge the meta and selector lists into\n// a list of objects, because we could then rank them better. For example,\n// .hentry .entry-title is far better suited than <meta title>.\n\n// An ordered list of meta tag names that denote likely article titles. All\n// attributes should be lowercase for faster case-insensitive matching. From\n// most distinct to least distinct.\nvar STRONG_TITLE_META_TAGS = ['tweetmeme-title', 'dc.title', 'rbtitle', 'headline', 'title'];\n\n// og:title is weak because it typically contains context that we don't like,\n// for example the source site's name. Gotta get that brand into facebook!\nvar WEAK_TITLE_META_TAGS = ['og:title'];\n\n// An ordered list of XPath Selectors to find likely article titles. From\n// most explicit to least explicit.\n//\n// Note - this does not use classes like CSS. This checks to see if the string\n// exists in the className, which is not as accurate as .className (which\n// splits on spaces/endlines), but for our purposes it's close enough. The\n// speed tradeoff is worth the accuracy hit.\nvar STRONG_TITLE_SELECTORS = ['.hentry .entry-title', 'h1#articleHeader', 'h1.articleHeader', 'h1.article', '.instapaper_title', '#meebo-title'];\n\nvar WEAK_TITLE_SELECTORS = ['article h1', '#entry-title', '.entry-title', '#entryTitle', '#entrytitle', '.entryTitle', '.entrytitle', '#articleTitle', '.articleTitle', 'post post-title', 'h1.title', 'h2.article', 'h1', 'html head title', 'title'];\n\nvar GenericTitleExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var url = _ref.url;\n var metaCache = _ref.metaCache;\n\n // First, check to see if we have a matching meta tag that we can make\n // use of that is strongly associated with the headline.\n var title = void 0;\n\n title = extractFromMeta($, STRONG_TITLE_META_TAGS, metaCache);\n if (title) return cleanTitle(title, { url: url, $: $ });\n\n // Second, look through our content selectors for the most likely\n // article title that is strongly associated with the headline.\n title = extractFromSelectors($, STRONG_TITLE_SELECTORS);\n if (title) return cleanTitle(title, { url: url, $: $ });\n\n // Third, check for weaker meta tags that may match.\n title = extractFromMeta($, WEAK_TITLE_META_TAGS, metaCache);\n if (title) return cleanTitle(title, { url: url, $: $ });\n\n // Last, look for weaker selector tags that may match.\n title = extractFromSelectors($, WEAK_TITLE_SELECTORS);\n if (title) return cleanTitle(title, { url: url, $: $ });\n\n // If no matches, return an empty string\n return '';\n }\n};\n\n// An ordered list of meta tag names that denote likely article authors. All\n// attributes should be lowercase for faster case-insensitive matching. From\n// most distinct to least distinct.\n//\n// Note: \"author\" is too often the -developer- of the page, so it is not\n// added here.\nvar AUTHOR_META_TAGS = ['byl', 'clmst', 'dc.author', 'dcsext.author', 'dc.creator', 'rbauthors', 'authors'];\n\nvar AUTHOR_MAX_LENGTH = 300;\n\n// An ordered list of XPath Selectors to find likely article authors. From\n// most explicit to least explicit.\n//\n// Note - this does not use classes like CSS. This checks to see if the string\n// exists in the className, which is not as accurate as .className (which\n// splits on spaces/endlines), but for our purposes it's close enough. The\n// speed tradeoff is worth the accuracy hit.\nvar AUTHOR_SELECTORS = ['.entry .entry-author', '.author.vcard .fn', '.author .vcard .fn', '.byline.vcard .fn', '.byline .vcard .fn', '.byline .by .author', '.byline .by', '.byline .author', '.post-author.vcard', '.post-author .vcard', 'a[rel=author]', '#by_author', '.by_author', '#entryAuthor', '.entryAuthor', '.byline a[href*=author]', '#author .authorname', '.author .authorname', '#author', '.author', '.articleauthor', '.ArticleAuthor', '.byline'];\n\n// An ordered list of Selectors to find likely article authors, with\n// regular expression for content.\nvar bylineRe = /^[\\n\\s]*By/i;\nvar BYLINE_SELECTORS_RE = [['#byline', bylineRe], ['.byline', bylineRe]];\n\nvar GenericAuthorExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var metaCache = _ref.metaCache;\n\n var author = void 0;\n\n // First, check to see if we have a matching\n // meta tag that we can make use of.\n author = extractFromMeta($, AUTHOR_META_TAGS, metaCache);\n if (author && author.length < AUTHOR_MAX_LENGTH) {\n return cleanAuthor(author);\n }\n\n // Second, look through our selectors looking for potential authors.\n author = extractFromSelectors($, AUTHOR_SELECTORS, 2);\n if (author && author.length < AUTHOR_MAX_LENGTH) {\n return cleanAuthor(author);\n }\n\n // Last, use our looser regular-expression based selectors for\n // potential authors.\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = BYLINE_SELECTORS_RE[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _ref4 = _step.value;\n\n var _ref3 = slicedToArray(_ref4, 2);\n\n var selector = _ref3[0];\n var regex = _ref3[1];\n\n var node = $(selector);\n if (node.length === 1) {\n var text = node.text();\n if (regex.test(text)) {\n return cleanAuthor(text);\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n }\n};\n\n// An ordered list of meta tag names that denote\n// likely date published dates. All attributes\n// should be lowercase for faster case-insensitive matching.\n// From most distinct to least distinct.\nvar DATE_PUBLISHED_META_TAGS = ['article:published_time', 'displaydate', 'dc.date', 'dc.date.issued', 'rbpubdate', 'publish_date', 'pub_date', 'pagedate', 'pubdate', 'revision_date', 'doc_date', 'date_created', 'content_create_date', 'lastmodified', 'created', 'date'];\n\n// An ordered list of XPath Selectors to find\n// likely date published dates. From most explicit\n// to least explicit.\nvar DATE_PUBLISHED_SELECTORS = ['.hentry .dtstamp.published', '.hentry .published', '.hentry .dtstamp.updated', '.hentry .updated', '.single .published', '.meta .published', '.meta .postDate', '.entry-date', '.byline .date', '.postmetadata .date', '.article_datetime', '.date-header', '.story-date', '.dateStamp', '#story .datetime', '.dateline', '.pubdate'];\n\n// An ordered list of compiled regular expressions to find likely date\n// published dates from the URL. These should always have the first\n// reference be a date string that is parseable by dateutil.parser.parse\nvar abbrevMonthsStr = '(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)';\nvar DATE_PUBLISHED_URL_RES = [\n// /2012/01/27/ but not /2012/01/293\nnew RegExp('/(20\\\\d{2}/\\\\d{2}/\\\\d{2})/', 'i'),\n// 20120127 or 20120127T but not 2012012733 or 8201201733\n// /[^0-9](20\\d{2}[01]\\d[0-3]\\d)([^0-9]|$)/i,\n// 2012-01-27\nnew RegExp('(20\\\\d{2}-[01]\\\\d-[0-3]\\\\d)', 'i'),\n// /2012/jan/27/\nnew RegExp('/(20\\\\d{2}/' + abbrevMonthsStr + '/[0-3]\\\\d)/', 'i')];\n\nvar GenericDatePublishedExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var url = _ref.url;\n var metaCache = _ref.metaCache;\n\n var datePublished = void 0;\n // First, check to see if we have a matching meta tag\n // that we can make use of.\n // Don't try cleaning tags from this string\n datePublished = extractFromMeta($, DATE_PUBLISHED_META_TAGS, metaCache, false);\n if (datePublished) return cleanDatePublished(datePublished);\n\n // Second, look through our selectors looking for potential\n // date_published's.\n datePublished = extractFromSelectors($, DATE_PUBLISHED_SELECTORS);\n if (datePublished) return cleanDatePublished(datePublished);\n\n // Lastly, look to see if a dately string exists in the URL\n datePublished = extractFromUrl(url, DATE_PUBLISHED_URL_RES);\n if (datePublished) return cleanDatePublished(datePublished);\n\n return null;\n }\n};\n\n// import {\n// DEK_META_TAGS,\n// DEK_SELECTORS,\n// DEK_URL_RES,\n// } from './constants';\n\n// import { cleanDek } from 'cleaners';\n\n// import {\n// extractFromMeta,\n// extractFromSelectors,\n// } from 'utils/dom';\n\n// Currently there is only one selector for\n// deks. We should simply return null here\n// until we have a more robust generic option.\n// Below is the original source for this, for reference.\nvar GenericDekExtractor = {\n // extract({ $, content, metaCache }) {\n extract: function extract() {\n return null;\n }\n};\n\n// An ordered list of meta tag names that denote likely article leading images.\n// All attributes should be lowercase for faster case-insensitive matching.\n// From most distinct to least distinct.\nvar LEAD_IMAGE_URL_META_TAGS = ['og:image', 'twitter:image', 'image_src'];\n\nvar LEAD_IMAGE_URL_SELECTORS = ['link[rel=image_src]'];\n\nvar POSITIVE_LEAD_IMAGE_URL_HINTS = ['upload', 'wp-content', 'large', 'photo', 'wp-image'];\nvar POSITIVE_LEAD_IMAGE_URL_HINTS_RE = new RegExp(POSITIVE_LEAD_IMAGE_URL_HINTS.join('|'), 'i');\n\nvar NEGATIVE_LEAD_IMAGE_URL_HINTS = ['spacer', 'sprite', 'blank', 'throbber', 'gradient', 'tile', 'bg', 'background', 'icon', 'social', 'header', 'hdr', 'advert', 'spinner', 'loader', 'loading', 'default', 'rating', 'share', 'facebook', 'twitter', 'theme', 'promo', 'ads', 'wp-includes'];\nvar NEGATIVE_LEAD_IMAGE_URL_HINTS_RE = new RegExp(NEGATIVE_LEAD_IMAGE_URL_HINTS.join('|'), 'i');\n\nvar GIF_RE = /\\.gif(\\?.*)?$/i;\nvar JPG_RE = /\\.jpe?g(\\?.*)?$/i;\n\nfunction getSig($node) {\n return ($node.attr('class') || '') + ' ' + ($node.attr('id') || '');\n}\n\n// Scores image urls based on a variety of heuristics.\nfunction scoreImageUrl(url) {\n url = url.trim();\n var score = 0;\n\n if (POSITIVE_LEAD_IMAGE_URL_HINTS_RE.test(url)) {\n score += 20;\n }\n\n if (NEGATIVE_LEAD_IMAGE_URL_HINTS_RE.test(url)) {\n score -= 20;\n }\n\n // TODO: We might want to consider removing this as\n // gifs are much more common/popular than they once were\n if (GIF_RE.test(url)) {\n score -= 10;\n }\n\n if (JPG_RE.test(url)) {\n score += 10;\n }\n\n // PNGs are neutral.\n\n return score;\n}\n\n// Alt attribute usually means non-presentational image.\nfunction scoreAttr($img) {\n if ($img.attr('alt')) {\n return 5;\n }\n\n return 0;\n}\n\n// Look through our parent and grandparent for figure-like\n// container elements, give a bonus if we find them\nfunction scoreByParents($img) {\n var score = 0;\n var $figParent = $img.parents('figure').first();\n\n if ($figParent.length === 1) {\n score += 25;\n }\n\n var $parent = $img.parent();\n var $gParent = void 0;\n if ($parent.length === 1) {\n $gParent = $parent.parent();\n }\n\n [$parent, $gParent].forEach(function ($node) {\n if (PHOTO_HINTS_RE$1.test(getSig($node))) {\n score += 15;\n }\n });\n\n return score;\n}\n\n// Look at our immediate sibling and see if it looks like it's a\n// caption. Bonus if so.\nfunction scoreBySibling($img) {\n var score = 0;\n var $sibling = $img.next();\n var sibling = $sibling.get(0);\n\n if (sibling && sibling.tagName === 'figcaption') {\n score += 25;\n }\n\n if (PHOTO_HINTS_RE$1.test(getSig($sibling))) {\n score += 15;\n }\n\n return score;\n}\n\nfunction scoreByDimensions($img) {\n var score = 0;\n\n var width = parseFloat($img.attr('width'));\n var height = parseFloat($img.attr('height'));\n var src = $img.attr('src');\n\n // Penalty for skinny images\n if (width && width <= 50) {\n score -= 50;\n }\n\n // Penalty for short images\n if (height && height <= 50) {\n score -= 50;\n }\n\n if (width && height && !src.includes('sprite')) {\n var area = width * height;\n if (area < 5000) {\n // Smaller than 50 x 100\n score -= 100;\n } else {\n score += Math.round(area / 1000);\n }\n }\n\n return score;\n}\n\nfunction scoreByPosition($imgs, index) {\n return $imgs.length / 2 - index;\n}\n\n// Given a resource, try to find the lead image URL from within\n// it. Like content and next page extraction, uses a scoring system\n// to determine what the most likely image may be. Short circuits\n// on really probable things like og:image meta tags.\n//\n// Potential signals to still take advantage of:\n// * domain\n// * weird aspect ratio\nvar GenericLeadImageUrlExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var content = _ref.content;\n var metaCache = _ref.metaCache;\n\n var cleanUrl = void 0;\n\n // Check to see if we have a matching meta tag that we can make use of.\n // Moving this higher because common practice is now to use large\n // images on things like Open Graph or Twitter cards.\n // images usually have for things like Open Graph.\n var imageUrl = extractFromMeta($, LEAD_IMAGE_URL_META_TAGS, metaCache, false);\n\n if (imageUrl) {\n cleanUrl = clean$1(imageUrl);\n\n if (cleanUrl) return cleanUrl;\n }\n\n // Next, try to find the \"best\" image via the content.\n // We'd rather not have to fetch each image and check dimensions,\n // so try to do some analysis and determine them instead.\n var imgs = $('img', content).toArray();\n var imgScores = {};\n\n imgs.forEach(function (img, index) {\n var $img = $(img);\n var src = $img.attr('src');\n\n if (!src) return;\n\n var score = scoreImageUrl(src);\n score += scoreAttr($img);\n score += scoreByParents($img);\n score += scoreBySibling($img);\n score += scoreByDimensions($img);\n score += scoreByPosition(imgs, index);\n\n imgScores[src] = score;\n });\n\n var _Reflect$ownKeys$redu = Reflect.ownKeys(imgScores).reduce(function (acc, key) {\n return imgScores[key] > acc[1] ? [key, imgScores[key]] : acc;\n }, [null, 0]);\n\n var _Reflect$ownKeys$redu2 = slicedToArray(_Reflect$ownKeys$redu, 2);\n\n var topUrl = _Reflect$ownKeys$redu2[0];\n var topScore = _Reflect$ownKeys$redu2[1];\n\n\n if (topScore > 0) {\n cleanUrl = clean$1(topUrl);\n\n if (cleanUrl) return cleanUrl;\n }\n\n // If nothing else worked, check to see if there are any really\n // probable nodes in the doc, like <link rel=\"image_src\" />.\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = LEAD_IMAGE_URL_SELECTORS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var selector = _step.value;\n\n var $node = $(selector).first();\n var src = $node.attr('src');\n if (src) {\n cleanUrl = clean$1(src);\n if (cleanUrl) return cleanUrl;\n }\n\n var href = $node.attr('href');\n if (href) {\n cleanUrl = clean$1(href);\n if (cleanUrl) return cleanUrl;\n }\n\n var value = $node.attr('value');\n if (value) {\n cleanUrl = clean$1(value);\n if (cleanUrl) return cleanUrl;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n }\n};\n\n// def extract(self):\n// \"\"\"\n// # First, try to find the \"best\" image via the content.\n// # We'd rather not have to fetch each image and check dimensions,\n// # so try to do some analysis and determine them instead.\n// content = self.extractor.extract_content(return_type=\"node\")\n// imgs = content.xpath('.//img')\n// img_scores = defaultdict(int)\n// logger.debug('Scoring %d images from content', len(imgs))\n// for (i, img) in enumerate(imgs):\n// img_score = 0\n//\n// if not 'src' in img.attrib:\n// logger.debug('No src attribute found')\n// continue\n//\n// try:\n// parsed_img = urlparse(img.attrib['src'])\n// img_path = parsed_img.path.lower()\n// except ValueError:\n// logger.debug('ValueError getting img path.')\n// continue\n// logger.debug('Image path is %s', img_path)\n//\n// if constants.POSITIVE_LEAD_IMAGE_URL_HINTS_RE.match(img_path):\n// logger.debug('Positive URL hints match. Adding 20.')\n// img_score += 20\n//\n// if constants.NEGATIVE_LEAD_IMAGE_URL_HINTS_RE.match(img_path):\n// logger.debug('Negative URL hints match. Subtracting 20.')\n// img_score -= 20\n//\n// # Gifs are more often structure than photos\n// if img_path.endswith('gif'):\n// logger.debug('gif found. Subtracting 10.')\n// img_score -= 10\n//\n// # JPGs are more often photographs\n// if img_path.endswith('jpg'):\n// logger.debug('jpg found. Adding 10.')\n// img_score += 10\n//\n// # PNGs are neutral.\n//\n// # Alt attribute usually means non-presentational image.\n// if 'alt' in img.attrib and len(img.attrib['alt']) > 5:\n// logger.debug('alt attribute found. Adding 5.')\n// img_score += 5\n//\n// # Look through our parent and grandparent for figure-like\n// # container elements, give a bonus if we find them\n// parents = [img.getparent()]\n// if parents[0] is not None and parents[0].getparent() is not None:\n// parents.append(parents[0].getparent())\n// for p in parents:\n// if p.tag == 'figure':\n// logger.debug('Parent with <figure> tag found. Adding 25.')\n// img_score += 25\n//\n// p_sig = ' '.join([p.get('id', ''), p.get('class', '')])\n// if constants.PHOTO_HINTS_RE.search(p_sig):\n// logger.debug('Photo hints regex match. Adding 15.')\n// img_score += 15\n//\n// # Look at our immediate sibling and see if it looks like it's a\n// # caption. Bonus if so.\n// sibling = img.getnext()\n// if sibling is not None:\n// if sibling.tag == 'figcaption':\n// img_score += 25\n//\n// sib_sig = ' '.join([sibling.get('id', ''),\n// sibling.get('class', '')]).lower()\n// if 'caption' in sib_sig:\n// img_score += 15\n//\n// # Pull out width/height if they were set.\n// img_width = None\n// img_height = None\n// if 'width' in img.attrib:\n// try:\n// img_width = float(img.get('width'))\n// except ValueError:\n// pass\n// if 'height' in img.attrib:\n// try:\n// img_height = float(img.get('height'))\n// except ValueError:\n// pass\n//\n// # Penalty for skinny images\n// if img_width and img_width <= 50:\n// logger.debug('Skinny image found. Subtracting 50.')\n// img_score -= 50\n//\n// # Penalty for short images\n// if img_height and img_height <= 50:\n// # Wide, short images are more common than narrow, tall ones\n// logger.debug('Short image found. Subtracting 25.')\n// img_score -= 25\n//\n// if img_width and img_height and not 'sprite' in img_path:\n// area = img_width * img_height\n//\n// if area < 5000: # Smaller than 50x100\n// logger.debug('Image with small area found. Subtracting 100.')\n// img_score -= 100\n// else:\n// img_score += round(area/1000.0)\n//\n// # If the image is higher on the page than other images,\n// # it gets a bonus. Penalty if lower.\n// logger.debug('Adding page placement bonus of %d.', len(imgs)/2 - i)\n// img_score += len(imgs)/2 - i\n//\n// # Use the raw src here because we munged img_path for case\n// # insensitivity\n// logger.debug('Final score is %d.', img_score)\n// img_scores[img.attrib['src']] += img_score\n//\n// top_score = 0\n// top_url = None\n// for (url, score) in img_scores.items():\n// if score > top_score:\n// top_url = url\n// top_score = score\n//\n// if top_score > 0:\n// logger.debug('Using top score image from content. Score was %d', top_score)\n// return top_url\n//\n//\n// # If nothing else worked, check to see if there are any really\n// # probable nodes in the doc, like <link rel=\"image_src\" />.\n// logger.debug('Trying to find lead image in probable nodes')\n// for selector in constants.LEAD_IMAGE_URL_SELECTORS:\n// nodes = self.resource.extract_by_selector(selector)\n// for node in nodes:\n// clean_value = None\n// if node.attrib.get('src'):\n// clean_value = self.clean(node.attrib['src'])\n//\n// if not clean_value and node.attrib.get('href'):\n// clean_value = self.clean(node.attrib['href'])\n//\n// if not clean_value and node.attrib.get('value'):\n// clean_value = self.clean(node.attrib['value'])\n//\n// if clean_value:\n// logger.debug('Found lead image in probable nodes.')\n// logger.debug('Node was: %s', node)\n// return clean_value\n//\n// return None\n\nfunction scoreSimilarity(score, articleUrl, href) {\n // Do this last and only if we have a real candidate, because it's\n // potentially expensive computationally. Compare the link to this\n // URL using difflib to get the % similarity of these URLs. On a\n // sliding scale, subtract points from this link based on\n // similarity.\n if (score > 0) {\n var similarity = new difflib.SequenceMatcher(null, articleUrl, href).ratio();\n // Subtract .1 from diff_percent when calculating modifier,\n // which means that if it's less than 10% different, we give a\n // bonus instead. Ex:\n // 3% different = +17.5 points\n // 10% different = 0 points\n // 20% different = -25 points\n var diffPercent = 1.0 - similarity;\n var diffModifier = -(250 * (diffPercent - 0.2));\n return score + diffModifier;\n }\n\n return 0;\n}\n\nfunction scoreLinkText(linkText, pageNum) {\n // If the link text can be parsed as a number, give it a minor\n // bonus, with a slight bias towards lower numbered pages. This is\n // so that pages that might not have 'next' in their text can still\n // get scored, and sorted properly by score.\n var score = 0;\n\n if (IS_DIGIT_RE.test(linkText.trim())) {\n var linkTextAsNum = parseInt(linkText, 10);\n // If it's the first page, we already got it on the first call.\n // Give it a negative score. Otherwise, up to page 10, give a\n // small bonus.\n if (linkTextAsNum < 2) {\n score = -30;\n } else {\n score = Math.max(0, 10 - linkTextAsNum);\n }\n\n // If it appears that the current page number is greater than\n // this links page number, it's a very bad sign. Give it a big\n // penalty.\n if (pageNum && pageNum >= linkTextAsNum) {\n score -= 50;\n }\n }\n\n return score;\n}\n\nfunction scorePageInLink(pageNum, isWp) {\n // page in the link = bonus. Intentionally ignore wordpress because\n // their ?p=123 link style gets caught by this even though it means\n // separate documents entirely.\n if (pageNum && !isWp) {\n return 50;\n }\n\n return 0;\n}\n\nvar DIGIT_RE$2 = /\\d/;\n\n// A list of words that, if found in link text or URLs, likely mean that\n// this link is not a next page link.\nvar EXTRANEOUS_LINK_HINTS$1 = ['print', 'archive', 'comment', 'discuss', 'e-mail', 'email', 'share', 'reply', 'all', 'login', 'sign', 'single', 'adx', 'entry-unrelated'];\nvar EXTRANEOUS_LINK_HINTS_RE$1 = new RegExp(EXTRANEOUS_LINK_HINTS$1.join('|'), 'i');\n\n// Match any link text/classname/id that looks like it could mean the next\n// page. Things like: next, continue, >, >>, » but not >|, »| as those can\n// mean last page.\nvar NEXT_LINK_TEXT_RE$1 = new RegExp('(next|weiter|continue|>([^|]|$)|»([^|]|$))', 'i');\n\n// Match any link text/classname/id that looks like it is an end link: things\n// like \"first\", \"last\", \"end\", etc.\nvar CAP_LINK_TEXT_RE$1 = new RegExp('(first|last|end)', 'i');\n\n// Match any link text/classname/id that looks like it means the previous\n// page.\nvar PREV_LINK_TEXT_RE$1 = new RegExp('(prev|earl|old|new|<|«)', 'i');\n\nfunction scoreExtraneousLinks(href) {\n // If the URL itself contains extraneous values, give a penalty.\n if (EXTRANEOUS_LINK_HINTS_RE$1.test(href)) {\n return -25;\n }\n\n return 0;\n}\n\nfunction makeSig$1($link) {\n return ($link.attr('class') || '') + ' ' + ($link.attr('id') || '');\n}\n\nfunction scoreByParents$1($link) {\n // If a parent node contains paging-like classname or id, give a\n // bonus. Additionally, if a parent_node contains bad content\n // (like 'sponsor'), give a penalty.\n var $parent = $link.parent();\n var positiveMatch = false;\n var negativeMatch = false;\n var score = 0;\n\n Array.from(range(0, 4)).forEach(function () {\n if ($parent.length === 0) {\n return;\n }\n\n var parentData = makeSig$1($parent, ' ');\n\n // If we have 'page' or 'paging' in our data, that's a good\n // sign. Add a bonus.\n if (!positiveMatch && PAGE_RE.test(parentData)) {\n positiveMatch = true;\n score += 25;\n }\n\n // If we have 'comment' or something in our data, and\n // we don't have something like 'content' as well, that's\n // a bad sign. Give a penalty.\n if (!negativeMatch && NEGATIVE_SCORE_RE.test(parentData) && EXTRANEOUS_LINK_HINTS_RE$1.test(parentData)) {\n if (!POSITIVE_SCORE_RE.test(parentData)) {\n negativeMatch = true;\n score -= 25;\n }\n }\n\n $parent = $parent.parent();\n });\n\n return score;\n}\n\nfunction scorePrevLink(linkData) {\n // If the link has something like \"previous\", its definitely\n // an old link, skip it.\n if (PREV_LINK_TEXT_RE$1.test(linkData)) {\n return -200;\n }\n\n return 0;\n}\n\nfunction shouldScore(href, articleUrl, baseUrl, parsedUrl, linkText, previousUrls) {\n // skip if we've already fetched this url\n if (previousUrls.find(function (url) {\n return href === url;\n }) !== undefined) {\n return false;\n }\n\n // If we've already parsed this URL, or the URL matches the base\n // URL, or is empty, skip it.\n if (!href || href === articleUrl || href === baseUrl) {\n return false;\n }\n\n var hostname = parsedUrl.hostname;\n\n var _URL$parse = URL.parse(href);\n\n var linkHost = _URL$parse.hostname;\n\n // Domain mismatch.\n\n if (linkHost !== hostname) {\n return false;\n }\n\n // If href doesn't contain a digit after removing the base URL,\n // it's certainly not the next page.\n var fragment = href.replace(baseUrl, '');\n if (!DIGIT_RE$2.test(fragment)) {\n return false;\n }\n\n // This link has extraneous content (like \"comment\") in its link\n // text, so we skip it.\n if (EXTRANEOUS_LINK_HINTS_RE$1.test(linkText)) {\n return false;\n }\n\n // Next page link text is never long, skip if it is too long.\n if (linkText.length > 25) {\n return false;\n }\n\n return true;\n}\n\nfunction scoreBaseUrl(href, baseRegex) {\n // If the baseUrl isn't part of this URL, penalize this\n // link. It could still be the link, but the odds are lower.\n // Example:\n // http://www.actionscript.org/resources/articles/745/1/JavaScript-and-VBScript-Injection-in-ActionScript-3/Page1.html\n if (!baseRegex.test(href)) {\n return -25;\n }\n\n return 0;\n}\n\nfunction scoreNextLinkText(linkData) {\n // Things like \"next\", \">>\", etc.\n if (NEXT_LINK_TEXT_RE$1.test(linkData)) {\n return 50;\n }\n\n return 0;\n}\n\nfunction scoreCapLinks(linkData) {\n // Cap links are links like \"last\", etc.\n if (CAP_LINK_TEXT_RE$1.test(linkData)) {\n // If we found a link like \"last\", but we've already seen that\n // this link is also \"next\", it's fine. If it's not been\n // previously marked as \"next\", then it's probably bad.\n // Penalize.\n if (NEXT_LINK_TEXT_RE$1.test(linkData)) {\n return -65;\n }\n }\n\n return 0;\n}\n\nfunction makeBaseRegex(baseUrl) {\n return new RegExp('^' + baseUrl, 'i');\n}\n\nfunction makeSig($link, linkText) {\n return (linkText || $link.text()) + ' ' + ($link.attr('class') || '') + ' ' + ($link.attr('id') || '');\n}\n\nfunction scoreLinks(_ref) {\n var links = _ref.links;\n var articleUrl = _ref.articleUrl;\n var baseUrl = _ref.baseUrl;\n var parsedUrl = _ref.parsedUrl;\n var $ = _ref.$;\n var _ref$previousUrls = _ref.previousUrls;\n var previousUrls = _ref$previousUrls === undefined ? [] : _ref$previousUrls;\n\n parsedUrl = parsedUrl || URL.parse(articleUrl);\n var baseRegex = makeBaseRegex(baseUrl);\n var isWp = isWordpress($);\n\n // Loop through all links, looking for hints that they may be next-page\n // links. Things like having \"page\" in their textContent, className or\n // id, or being a child of a node with a page-y className or id.\n //\n // After we do that, assign each page a score, and pick the one that\n // looks most like the next page link, as long as its score is strong\n // enough to have decent confidence.\n var scoredPages = links.reduce(function (possiblePages, link) {\n // Remove any anchor data since we don't do a good job\n // standardizing URLs (it's hard), we're going to do\n // some checking with and without a trailing slash\n var href = removeAnchor(link.attribs.href);\n var $link = $(link);\n var linkText = $link.text();\n\n if (!shouldScore(href, articleUrl, baseUrl, parsedUrl, linkText, previousUrls)) {\n return possiblePages;\n }\n\n // ## PASSED THE FIRST-PASS TESTS. Start scoring. ##\n if (!possiblePages[href]) {\n possiblePages[href] = {\n score: 0,\n linkText: linkText,\n href: href\n };\n } else {\n possiblePages[href].linkText = possiblePages[href].linkText + '|' + linkText;\n }\n\n var possiblePage = possiblePages[href];\n var linkData = makeSig($link, linkText);\n var pageNum = pageNumFromUrl(href);\n\n var score = scoreBaseUrl(href, baseRegex);\n score += scoreNextLinkText(linkData);\n score += scoreCapLinks(linkData);\n score += scorePrevLink(linkData);\n score += scoreByParents$1($link);\n score += scoreExtraneousLinks(href);\n score += scorePageInLink(pageNum, isWp);\n score += scoreLinkText(linkText, pageNum);\n score += scoreSimilarity(score, articleUrl, href);\n\n possiblePage.score = score;\n\n return possiblePages;\n }, {});\n\n return Reflect.ownKeys(scoredPages).length === 0 ? null : scoredPages;\n}\n\n// Looks for and returns next page url\n// for multi-page articles\nvar GenericNextPageUrlExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var url = _ref.url;\n var parsedUrl = _ref.parsedUrl;\n var _ref$previousUrls = _ref.previousUrls;\n var previousUrls = _ref$previousUrls === undefined ? [] : _ref$previousUrls;\n\n parsedUrl = parsedUrl || URL.parse(url);\n\n var articleUrl = removeAnchor(url);\n var baseUrl = articleBaseUrl(url, parsedUrl);\n\n var links = $('a[href]').toArray();\n\n var scoredLinks = scoreLinks({\n links: links,\n articleUrl: articleUrl,\n baseUrl: baseUrl,\n parsedUrl: parsedUrl,\n $: $,\n previousUrls: previousUrls\n });\n\n // If no links were scored, return null\n if (!scoredLinks) return null;\n\n // now that we've scored all possible pages,\n // find the biggest one.\n var topPage = Reflect.ownKeys(scoredLinks).reduce(function (acc, link) {\n var scoredLink = scoredLinks[link];\n return scoredLink.score > acc.score ? scoredLink : acc;\n }, { score: -100 });\n\n // If the score is less than 50, we're not confident enough to use it,\n // so we fail.\n if (topPage.score >= 50) {\n return topPage.href;\n }\n\n return null;\n }\n};\n\nvar CANONICAL_META_SELECTORS = ['og:url'];\n\nfunction parseDomain(url) {\n var parsedUrl = URL.parse(url);\n var hostname = parsedUrl.hostname;\n\n return hostname;\n}\n\nfunction result(url) {\n return {\n url: url,\n domain: parseDomain(url)\n };\n}\n\nvar GenericUrlExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var url = _ref.url;\n var metaCache = _ref.metaCache;\n\n var $canonical = $('link[rel=canonical]');\n if ($canonical.length !== 0) {\n var href = $canonical.attr('href');\n if (href) {\n return result(href);\n }\n }\n\n var metaUrl = extractFromMeta($, CANONICAL_META_SELECTORS, metaCache);\n if (metaUrl) {\n return result(metaUrl);\n }\n\n return result(url);\n }\n};\n\nvar EXCERPT_META_SELECTORS = ['og:description', 'twitter:description'];\n\nfunction clean$2(content, $) {\n var maxLength = arguments.length <= 2 || arguments[2] === undefined ? 200 : arguments[2];\n\n content = content.replace(/[\\s\\n]+/g, ' ').trim();\n return ellipsize(content, maxLength, { ellipse: '&hellip;' });\n}\n\nvar GenericExcerptExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$;\n var content = _ref.content;\n var metaCache = _ref.metaCache;\n\n var excerpt = extractFromMeta($, EXCERPT_META_SELECTORS, metaCache);\n if (excerpt) {\n return clean$2(stripTags(excerpt, $));\n }\n // Fall back to excerpting from the extracted content\n var maxLength = 200;\n var shortContent = content.slice(0, maxLength * 5);\n return clean$2($(shortContent).text(), $, maxLength);\n }\n};\n\nvar GenericWordCountExtractor = {\n extract: function extract(_ref) {\n var content = _ref.content;\n\n var $ = cheerio.load(content);\n\n var text = normalizeSpaces($('div').first().text());\n return text.split(/\\s/).length;\n }\n};\n\nvar GenericExtractor = {\n // This extractor is the default for all domains\n domain: '*',\n title: GenericTitleExtractor.extract,\n date_published: GenericDatePublishedExtractor.extract,\n author: GenericAuthorExtractor.extract,\n content: GenericContentExtractor.extract.bind(GenericContentExtractor),\n lead_image_url: GenericLeadImageUrlExtractor.extract,\n dek: GenericDekExtractor.extract,\n next_page_url: GenericNextPageUrlExtractor.extract,\n url_and_domain: GenericUrlExtractor.extract,\n excerpt: GenericExcerptExtractor.extract,\n word_count: GenericWordCountExtractor.extract,\n direction: function direction(_ref) {\n var title = _ref.title;\n return stringDirection.getDirection(title);\n },\n\n extract: function extract(options) {\n var html = options.html;\n\n\n if (html) {\n var $ = cheerio.load(html);\n options.$ = $;\n }\n\n var title = this.title(options);\n var date_published = this.date_published(options);\n var author = this.author(options);\n var content = this.content(_extends({}, options, { title: title }));\n var lead_image_url = this.lead_image_url(_extends({}, options, { content: content }));\n var dek = this.dek(_extends({}, options, { content: content }));\n var next_page_url = this.next_page_url(options);\n var excerpt = this.excerpt(_extends({}, options, { content: content }));\n var word_count = this.word_count(_extends({}, options, { content: content }));\n var direction = this.direction({ title: title });\n\n var _url_and_domain = this.url_and_domain(options);\n\n var url = _url_and_domain.url;\n var domain = _url_and_domain.domain;\n\n\n return {\n title: title,\n author: author,\n date_published: date_published || null,\n dek: dek,\n lead_image_url: lead_image_url,\n content: content,\n next_page_url: next_page_url,\n url: url,\n domain: domain,\n excerpt: excerpt,\n word_count: word_count,\n direction: direction\n };\n }\n};\n\nfunction getExtractor(url, parsedUrl) {\n parsedUrl = parsedUrl || URL.parse(url);\n var _parsedUrl = parsedUrl;\n var hostname = _parsedUrl.hostname;\n\n var baseDomain = hostname.split('.').slice(-2).join('.');\n\n return Extractors[hostname] || Extractors[baseDomain] || GenericExtractor;\n}\n\nvar ATTR_RE = /\\[([\\w-]+)\\]/;\n\n// Remove elements by an array of selectors\nfunction cleanBySelectors($content, $, _ref) {\n var clean = _ref.clean;\n\n if (!clean) return $content;\n\n $(clean.join(','), $content).remove();\n\n return $content;\n}\n\n// Transform matching elements\nfunction transformElements($content, $, _ref2) {\n var transforms = _ref2.transforms;\n\n if (!transforms) return $content;\n\n Reflect.ownKeys(transforms).forEach(function (key) {\n var $matches = $(key, $content);\n var value = transforms[key];\n\n // If value is a string, convert directly\n if (typeof value === 'string') {\n $matches.each(function (index, node) {\n convertNodeTo($(node), $, transforms[key]);\n });\n } else if (typeof value === 'function') {\n // If value is function, apply function to node\n $matches.each(function (index, node) {\n var result = value($(node), $);\n // If function returns a string, convert node to that value\n if (typeof result === 'string') {\n convertNodeTo($(node), $, result);\n }\n });\n }\n });\n\n return $content;\n}\n\nfunction select(opts) {\n var $ = opts.$;\n var type = opts.type;\n var extractionOpts = opts.extractionOpts;\n var _opts$extractHtml = opts.extractHtml;\n var extractHtml = _opts$extractHtml === undefined ? false : _opts$extractHtml;\n // Skip if there's not extraction for this type\n\n if (!extractionOpts) return null;\n\n // If a string is hardcoded for a type (e.g., Wikipedia\n // contributors), return the string\n if (typeof extractionOpts === 'string') return extractionOpts;\n\n var selectors = extractionOpts.selectors;\n var _extractionOpts$defau = extractionOpts.defaultCleaner;\n var defaultCleaner = _extractionOpts$defau === undefined ? true : _extractionOpts$defau;\n\n\n var matchingSelector = selectors.find(function (selector) {\n return $(selector).length === 1 && $(selector).text().trim() !== '';\n });\n\n if (!matchingSelector) return null;\n\n // Declaring result; will contain either\n // text or html, which will be cleaned\n // by the appropriate cleaner type\n\n // If the selector type requests html as its return type\n // transform and clean the element with provided selectors\n if (extractHtml) {\n var $content = $(matchingSelector);\n\n // Wrap in div so transformation can take place on root element\n $content.wrap($('<div></div>'));\n $content = $content.parent();\n\n $content = transformElements($content, $, extractionOpts);\n $content = cleanBySelectors($content, $, extractionOpts);\n\n if (defaultCleaner) {\n $content = Cleaners[type]($content, opts);\n }\n\n return $.html($content);\n }\n // if selector includes an attr (e.g., img[src]),\n // extract the attr\n var attr = matchingSelector.match(ATTR_RE);\n var result = void 0;\n\n if (attr) {\n result = $(matchingSelector).attr(attr[1]);\n } else {\n // otherwise use the text of the node\n result = $(matchingSelector).text();\n }\n\n // Allow custom extractor to skip default cleaner\n // for this type; defaults to true\n if (defaultCleaner) {\n return Cleaners[type](result, opts);\n }\n\n return result;\n}\n\nfunction extractResult(opts) {\n var type = opts.type;\n var extractor = opts.extractor;\n\n // If nothing matches the selector,\n // run the Generic extraction\n\n return select(_extends({}, opts, { extractionOpts: extractor[type] })) || GenericExtractor[type](opts);\n}\n\nvar RootExtractor = {\n extract: function extract() {\n var extractor = arguments.length <= 0 || arguments[0] === undefined ? GenericExtractor : arguments[0];\n var opts = arguments[1];\n var _opts = opts;\n var contentOnly = _opts.contentOnly;\n var extractedTitle = _opts.extractedTitle;\n // This is the generic extractor. Run its extract method\n\n if (extractor.domain === '*') return extractor.extract(opts);\n\n opts = _extends({}, opts, {\n extractor: extractor\n });\n\n if (contentOnly) {\n var _content = extractResult(_extends({}, opts, { type: 'content', extractHtml: true, title: extractedTitle\n }));\n return {\n content: _content\n };\n }\n var title = extractResult(_extends({}, opts, { type: 'title' }));\n var date_published = extractResult(_extends({}, opts, { type: 'date_published' }));\n var author = extractResult(_extends({}, opts, { type: 'author' }));\n var next_page_url = extractResult(_extends({}, opts, { type: 'next_page_url' }));\n var content = extractResult(_extends({}, opts, { type: 'content', extractHtml: true, title: title\n }));\n var lead_image_url = extractResult(_extends({}, opts, { type: 'lead_image_url', content: content }));\n var dek = extractResult(_extends({}, opts, { type: 'dek', content: content }));\n var excerpt = extractResult(_extends({}, opts, { type: 'excerpt', content: content }));\n var word_count = extractResult(_extends({}, opts, { type: 'word_count', content: content }));\n var direction = extractResult(_extends({}, opts, { type: 'direction', title: title }));\n\n var _extractResult = extractResult(_extends({}, opts, { type: 'url_and_domain' }));\n\n var url = _extractResult.url;\n var domain = _extractResult.domain;\n\n\n return {\n title: title,\n content: content,\n author: author,\n date_published: date_published,\n lead_image_url: lead_image_url,\n dek: dek,\n next_page_url: next_page_url,\n url: url,\n domain: domain,\n excerpt: excerpt,\n word_count: word_count,\n direction: direction\n };\n }\n};\n\nvar collectAllPages = (function () {\n var _ref = asyncToGenerator(regeneratorRuntime.mark(function _callee(_ref2) {\n var next_page_url = _ref2.next_page_url;\n var html = _ref2.html;\n var $ = _ref2.$;\n var metaCache = _ref2.metaCache;\n var result = _ref2.result;\n var Extractor = _ref2.Extractor;\n var title = _ref2.title;\n var url = _ref2.url;\n var pages, previousUrls, extractorOpts, nextPageResult;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n // At this point, we've fetched just the first page\n pages = 1;\n previousUrls = [removeAnchor(url)];\n\n // If we've gone over 26 pages, something has\n // likely gone wrong.\n\n case 2:\n if (!(next_page_url && pages < 26)) {\n _context.next = 15;\n break;\n }\n\n pages += 1;\n _context.next = 6;\n return Resource.create(next_page_url);\n\n case 6:\n $ = _context.sent;\n\n html = $.html();\n\n extractorOpts = {\n url: next_page_url,\n html: html,\n $: $,\n metaCache: metaCache,\n contentOnly: true,\n extractedTitle: title,\n previousUrls: previousUrls\n };\n nextPageResult = RootExtractor.extract(Extractor, extractorOpts);\n\n\n previousUrls.push(next_page_url);\n result = _extends({}, result, {\n content: '\\n ' + result.content + '\\n <hr>\\n <h4>Page ' + pages + '</h4>\\n ' + nextPageResult.content + '\\n '\n });\n\n next_page_url = nextPageResult.next_page_url;\n _context.next = 2;\n break;\n\n case 15:\n return _context.abrupt('return', _extends({}, result, {\n total_pages: pages,\n pages_rendered: pages\n }));\n\n case 16:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function collectAllPages(_x) {\n return _ref.apply(this, arguments);\n }\n\n return collectAllPages;\n})();\n\nvar Mercury = {\n parse: function parse(url, html) {\n var _this = this;\n\n var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n return asyncToGenerator(regeneratorRuntime.mark(function _callee() {\n var _ref, _ref$fetchAllPages, fetchAllPages, parsedUrl, Extractor, $, metaCache, result, _result, title, next_page_url;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _ref = opts || true;\n _ref$fetchAllPages = _ref.fetchAllPages;\n fetchAllPages = _ref$fetchAllPages === undefined ? true : _ref$fetchAllPages;\n parsedUrl = URL.parse(url);\n\n if (validateUrl(parsedUrl)) {\n _context.next = 6;\n break;\n }\n\n return _context.abrupt('return', Errors.badUrl);\n\n case 6:\n Extractor = getExtractor(url, parsedUrl);\n // console.log(`Using extractor for ${Extractor.domain}`);\n\n _context.next = 9;\n return Resource.create(url, html, parsedUrl);\n\n case 9:\n $ = _context.sent;\n\n if (!$.error) {\n _context.next = 12;\n break;\n }\n\n return _context.abrupt('return', $);\n\n case 12:\n\n html = $.html();\n\n // Cached value of every meta name in our document.\n // Used when extracting title/author/date_published/dek\n metaCache = $('meta').map(function (_, node) {\n return $(node).attr('name');\n }).toArray();\n result = RootExtractor.extract(Extractor, { url: url, html: html, $: $, metaCache: metaCache, parsedUrl: parsedUrl });\n _result = result;\n title = _result.title;\n next_page_url = _result.next_page_url;\n\n // Fetch more pages if next_page_url found\n\n if (!(fetchAllPages && next_page_url)) {\n _context.next = 24;\n break;\n }\n\n _context.next = 21;\n return collectAllPages({\n Extractor: Extractor,\n next_page_url: next_page_url,\n html: html,\n $: $,\n metaCache: metaCache,\n result: result,\n title: title,\n url: url\n });\n\n case 21:\n result = _context.sent;\n _context.next = 25;\n break;\n\n case 24:\n result = _extends({}, result, {\n total_pages: 1,\n rendered_pages: 1\n });\n\n case 25:\n return _context.abrupt('return', result);\n\n case 26:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, _this);\n }))();\n },\n\n\n // A convenience method for getting a resource\n // to work with, e.g., for custom extractor generator\n fetchResource: function fetchResource(url) {\n var _this2 = this;\n\n return asyncToGenerator(regeneratorRuntime.mark(function _callee2() {\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return Resource.create(url);\n\n case 2:\n return _context2.abrupt('return', _context2.sent);\n\n case 3:\n case 'end':\n return _context2.stop();\n }\n }\n }, _callee2, _this2);\n }))();\n }\n};\n\nmodule.exports = Mercury;\n//# sourceMappingURL=mercury.js.map\n","export default function insertValues(strings, ...values) {\n if (values.length) {\n return strings.reduce((result, part, idx) => {\n let value = values[idx];\n\n if (value && typeof value.toString === 'function') {\n value = value.toString();\n } else {\n value = '';\n }\n\n return result + part + value;\n }, '');\n }\n\n return strings.join('');\n}\n","import insertValues from './insert-values'\n\nconst bodyPattern = /^\\n([\\s\\S]+)\\s{2}$/gm;\nconst trailingWhitespace = /\\s+$/;\n\nexport default function template(strings, ...values) {\n const compiled = insertValues(strings, ...values);\n let [body] = compiled.match(bodyPattern) || [];\n let indentLevel = /^\\s{0,4}(.+)$/g;\n\n if (!body) {\n body = compiled;\n indentLevel = /^\\s{0,2}(.+)$/g;\n }\n\n return body.split('\\n')\n .slice(1)\n .map((line) => {\n line = line.replace(indentLevel, '$1');\n\n if (trailingWhitespace.test(line)) {\n line = line.replace(trailingWhitespace, '');\n }\n\n return line;\n })\n .join('\\n');\n}\n","import template from './index';\n\nexport default function (hostname) {\n return template`\n // Rename CustomExtractor\n // to fit your publication\n export const CustomExtractor = {\n domain: '${hostname}',\n title: {\n selectors: [\n // enter title selectors\n ],\n },\n\n content: {\n selectors: [\n // enter content selectors\n ],\n\n // Is there anything in the content you selected that needs transformed\n // before it's consumable content? E.g., unusual lazy loaded images\n transforms: [\n ],\n\n // Is there anything that is in the result that shouldn't be?\n // The clean selectors will remove anything that matches from\n // the result\n clean: [\n\n ]\n },\n\n date_published: null,\n\n lead_image_url: null,\n\n dek: null,\n\n next_page_url: null,\n\n excerpt: null,\n }\n `;\n}\n","import template from './index';\n\nexport default function (file, url, dir) {\n return template`\n import assert from 'assert';\n import fs from 'fs';\n import URL from 'url';\n import cheerio from 'cheerio';\n\n import Mercury from 'mercury';\n import getExtractor from 'extractors/get-extractor';\n\n // Rename CustomExtractor\n describe('CustomExtractor', () => {\n it('is selected properly', () => {\n // To pass this test, rename your extractor in\n // ${dir}/index.js\n // then add your new extractor to\n // src/extractors/all.js\n const url = '${url}';\n const extractor = getExtractor(url);\n assert.equal(extractor.domain, URL.parse(url).hostname)\n })\n\n it('works with a starter story', (async) () => {\n // To pass this test, begin filling out your\n // selectors in ${dir}/index.js. This test is just\n // a stub; you can add more fields to test as much of\n // your parser as possible.\n const html = fs.readFileSync('${file}');\n const uri = '${url}';\n\n const { content, title, author } = await Mercury.parse(uri, html);\n const $ = cheerio.load(content);\n const text = $('*').first()\n .text()\n .trim()\n .slice(0, 20);\n\n // Update these values with the expected values from\n // the article.\n assert.equal(title, '');\n assert.equal(author, '');\n assert.equal(text, '');\n });\n });\n `;\n}\n","import fs from 'fs'\nimport URL from 'url'\nimport inquirer from 'inquirer'\nimport ora from 'ora'\n\nimport Mercury from '../dist/mercury'\nimport extractorTemplate from './templates/custom-extractor'\nimport extractorTestTemplate from './templates/custom-extractor-test'\n\nconst questions = [\n {\n type: 'input',\n name: 'website',\n message: 'Paste a url to an article you\\'d like to create or extend a parser for:',\n validate(value) {\n const { hostname } = URL.parse(value);\n if (hostname) return true;\n\n return false;\n },\n },\n];\n\ninquirer.prompt(questions).then((answers) => {\n scaffoldCustomParser(answers.website);\n});\n\nlet spinner;\nfunction confirm(fn, args, msg, newParser) {\n spinner = ora({ text: msg });\n spinner.start();\n const result = fn.apply(null, args);\n\n if (result && result.then) {\n result.then(r => savePage(r, args, newParser));\n } else {\n spinner.succeed();\n }\n\n return result;\n}\n\nfunction savePage($, [url], newParser) {\n const { hostname } = URL.parse(url);\n\n spinner.succeed();\n\n const filename = new Date().getTime();\n const file = `./fixtures/${hostname}/${filename}.html`;\n\n fs.writeFileSync(file, $.html());\n\n if (newParser) {\n confirm(generateScaffold, [url, file], 'Generating parser and tests');\n console.log(`Your custom site extractor has been set up. To get started building it, run\n npm test -- ${getDir(url)}/index.test.js`)\n } else {\n console.log(`It looks like you already have a custom parser for this url.\nThe page you linked to has been added to ${file}. Copy and paste\nthe following code to use that page in your tests:\nconst html = fs.readFileSync('${file}');`)\n }\n}\n\nfunction generateScaffold(url, file) {\n const { hostname } = URL.parse(url);\n const extractor = extractorTemplate(hostname)\n const extractorTest = extractorTestTemplate(file, url, getDir(url))\n\n fs.writeFileSync(`${getDir(url)}/index.js`, extractor)\n fs.writeFileSync(`${getDir(url)}/index.test.js`, extractorTest)\n}\n\nfunction confirmCreateDir(dir, msg) {\n if (!fs.existsSync(dir)) {\n confirm(fs.mkdirSync, [dir], msg);\n }\n}\n\nfunction scaffoldCustomParser(url) {\n const dir = getDir(url);\n const { hostname } = URL.parse(url);\n let newParser = false\n\n if (!fs.existsSync(dir)) {\n newParser = true\n confirmCreateDir(dir, `Creating ${hostname} directory`);\n confirmCreateDir(`./fixtures/${hostname}`, 'Creating fixtures directory');\n }\n\n confirm(Mercury.fetchResource, [url], 'Fetching fixture', newParser);\n}\n\nfunction getDir(url) {\n const { hostname } = URL.parse(url);\n return `./src/extractors/custom/${hostname}`;\n}\n"],"names":["ex","_interopDefault","require$$9","require$$8","require$$7","require$$6","require$$5","require$$4","require$$3","require$$2","require$$1","require$$0","range","map","regeneratorRuntime","mark","arguments","length","undefined","wrap","_context","prev","next","start","end","stop","_marked","_ref","hostname","badUrl","error","messages","BAD_CONTENT_TYPES","join","babelHelpers.typeof","Symbol","iterator","obj","constructor","fn","apply","resolve","reject","key","arg","gen","info","value","done","then","err","Object","defineProperty","enumerable","configurable","writable","assign","target","i","prototype","hasOwnProperty","call","source","arr","_s","_n","_i","_arr","push","_d","_e","Array","isArray","options","request","response","body","statusMessage","statusCode","parseNon2xx","headers","_response$headers","BAD_CONTENT_TYPES_RE","test","contentType","contentLength","MAX_CONTENT_LENGTH","asyncToGenerator","url","parsedUrl","_ref3","URL","parse","encodeURI","_extends","REQUEST_HEADERS","timeout","FETCH_TIMEOUT","encoding","jar","gzip","followAllRedirects","sent","validateResponse","abrupt","t0","Errors","_callee","_x2","_x3","$","from","to","each","_","node","$node","attr","removeAttr","convertMetaProp","img","Reflect","ownKeys","attribs","forEach","IS_LINK","IS_IMAGE","index","type","root","find","contents","filter","isComment","remove","TAGS_TO_REMOVE","cleanComments","create","preparedResponse","validResponse","result","_this","generateDoc","includes","cheerio","load","content","normalizeWhitespace","children","normalizeMetaTags","convertLazyLoadedImages","clean","domain","selectors","transforms","h1","noscript","$children","get","tagName","title","author","dek","date_published","defaultCleaner","parents","$parent","prepend","$tweetContainer","append","tweets","replaceWith","s","src","replace","width","lead_image_url","next_page_url","excerpt","NYMagExtractor","BloggerExtractor","WikipediaExtractor","TwitterExtractor","NYTimesExtractor","REMOVE_ATTRS","selector","WHITELIST_ATTRS","REMOVE_EMPTY_TAGS","tag","HEADER_TAGS","NON_TOP_CANDIDATE_TAGS","PHOTO_HINTS","POSITIVE_SCORE_HINTS","NEGATIVE_SCORE_HINTS","EXTRANEOUS_LINK_HINTS","BLOCK_LEVEL_TAGS","UNLIKELY_CANDIDATES_BLACKLIST","candidatesBlacklist","UNLIKELY_CANDIDATES_WHITELIST","candidatesWhitelist","not","id","classes","CANDIDATES_WHITELIST","classAndId","CANDIDATES_BLACKLIST","element","nextElement","collapsing","paragraphize","br","nextSibling","sibling","BLOCK_LEVEL_TAGS_RE","appendTo","p","div","$div","DIV_TO_P_BLOCK_TAGS","convertable","convertNodeTo","span","$span","brsToPs","convertDivs","convertSpans","_$node$get","attribString","$img","parseInt","height","SPACER_RE","$article","cleanForHeight","removeSpacers","article","STRIP_OUTPUT_TAGS","$hOnes","reduce","acc","WHITELIST_ATTRS_RE","removeAllButWhitelist","$p","text","trim","NON_TOP_CANDIDATE_TAGS$1","PHOTO_HINTS$1","POSITIVE_SCORE_HINTS$1","NEGATIVE_SCORE_HINTS$1","BLOCK_LEVEL_TAGS$1","UNLIKELY_CANDIDATES_BLACKLIST$1","UNLIKELY_CANDIDATES_WHITELIST$1","POSITIVE_SCORE_RE$1","score","NEGATIVE_SCORE_RE$1","PHOTO_HINTS_RE$1","READABILITY_ASSET$1","match","textLength","chunks","idkRe","lengthBonus","min","Math","max","scoreCommas","scoreLength","slice","amount","getOrInitScore","setScore","e","parent","addScore","getScore","scoreNode","weightNodes","getWeight","addToParent","PARAGRAPH_SCORE_TAGS$1","CHILD_CONTENT_TAGS$1","BAD_TAGS$1","convertSpans$1","addScoreTo","rawScore","HNEWS_CONTENT_SELECTORS$1","slicedToArray","_ref2","parentSelector","childSelector","scorePs","NORMALIZE_RE","regexList","re","matchRe","exec","PAGE_IN_HREF_RE","matches","pageNum","split","segment","firstSegmentHasLetters","IS_DIGIT_RE","goodSegment","toLowerCase","parsed","protocol","host","path","reverse","rawSegment","_segment$split","_segment$split2","IS_ALPHA_RE","fileExt","possibleSegment","HAS_ALPHA_RE","isGoodSegment","cleanedSegments","$candidate","topScore","NON_TOP_CANDIDATE_TAGS_RE$1","$sibling","siblingScore","wrappingDiv","linkDensity","density","contentBonus","newScore","siblingScoreThreshold","siblingContent","siblingContentLength","hasSentenceEnd","first","mergeSiblings","weight","hasClass","normalizeSpaces","inputCount","pCount","imgCount","nodeIsList","previousNode","scriptCount","CLEAN_CONDITIONALLY_TAGS","removeUnlessContent","HEADER_TAG_LIST","header","$header","prevAll","rootUrl","$content","absoluteUrl","linkText","totalTextLength","linkLength","metaNames","cachedNames","name","indexOf","_step","nodes","toArray","values","cleanTags","metaValue","stripTags","v","foundNames","_iteratorNormalCompletion","_iterator","_loop","_typeof","_ret","_didIteratorError","_iteratorError","return","maxChildren","withinComment","isGoodNode","textOnly","html","cleanText","class","IS_WP_SELECTOR","months","timestamp1","timestamp2","allMonths","CLEAN_AUTHOR_RE","leadImageUrl","validUrl","isWebUri","TEXT_LINK_RE","dekText","dateString","SPLIT_DATE_STRING","TIME_MERIDIAN_DOTS_RE","TIME_MERIDIAN_SPACE_RE","CLEAN_DATE_STRING_RE","MS_DATE_STRING","SEC_DATE_STRING","moment","date","isValid","cleanDateString","toISOString","cleanConditionally","_ref$cleanConditional","_ref$title","_ref$url","rewriteTopLevel","cleanImages","stripJunkTags","cleanHOnes","cleanHeaders","makeLinksAbsolute","cleanAttributes","removeEmpty","TITLE_SPLITTERS_RE","resolveSplitTitle","splitTitle","titleText","termCounts","_Reflect$ownKeys$redu","_Reflect$ownKeys$redu2","termCount","maxTerm","splitEnds","longestEnd","_URL$parse","DOMAIN_ENDINGS_RE","wuzzy","levenshtein","startSlug","nakedDomain","startSlugRatio","endSlug","endSlugRatio","extractBreadcrumbTitle","newTitle","cleanDomainFromTitle","cleanAuthor","clean$1","cleanDek","cleanDatePublished","extractCleanNode","cleanTitle","opts","stripUnlikelyCandidates","convertToParagraphs","scoreContent","findTopCandidate","defaultOpts","extract","getContentNode","nodeIsSufficient","cleanAndReturnNode","k","extractBestNode","metaCache","extractFromMeta","STRONG_TITLE_META_TAGS","extractFromSelectors","STRONG_TITLE_SELECTORS","WEAK_TITLE_META_TAGS","WEAK_TITLE_SELECTORS","bylineRe","AUTHOR_META_TAGS","AUTHOR_MAX_LENGTH","AUTHOR_SELECTORS","BYLINE_SELECTORS_RE","_ref4","regex","abbrevMonthsStr","datePublished","DATE_PUBLISHED_META_TAGS","DATE_PUBLISHED_SELECTORS","extractFromUrl","DATE_PUBLISHED_URL_RES","POSITIVE_LEAD_IMAGE_URL_HINTS","NEGATIVE_LEAD_IMAGE_URL_HINTS","POSITIVE_LEAD_IMAGE_URL_HINTS_RE","NEGATIVE_LEAD_IMAGE_URL_HINTS_RE","GIF_RE","JPG_RE","$figParent","$gParent","getSig","parseFloat","area","round","$imgs","LEAD_IMAGE_URL_META_TAGS","imageUrl","cleanUrl","imgs","scoreImageUrl","scoreAttr","scoreByParents","scoreBySibling","scoreByDimensions","scoreByPosition","imgScores","topUrl","LEAD_IMAGE_URL_SELECTORS","href","articleUrl","SequenceMatcher","ratio","similarity","diffPercent","diffModifier","linkTextAsNum","isWp","EXTRANEOUS_LINK_HINTS$1","EXTRANEOUS_LINK_HINTS_RE$1","$link","makeSig$1","positiveMatch","PAGE_RE","parentData","negativeMatch","NEGATIVE_SCORE_RE","POSITIVE_SCORE_RE","linkData","PREV_LINK_TEXT_RE$1","baseUrl","previousUrls","linkHost","DIGIT_RE$2","fragment","baseRegex","NEXT_LINK_TEXT_RE$1","CAP_LINK_TEXT_RE$1","links","_ref$previousUrls","makeBaseRegex","isWordpress","possiblePages","link","removeAnchor","shouldScore","makeSig","pageNumFromUrl","scoreBaseUrl","scoreNextLinkText","scoreCapLinks","scorePrevLink","scoreByParents$1","scoreExtraneousLinks","scorePageInLink","scoreLinkText","scoreSimilarity","possiblePage","scoredPages","articleBaseUrl","scoreLinks","scoredLinks","scoredLink","topPage","parseDomain","$canonical","CANONICAL_META_SELECTORS","metaUrl","maxLength","ellipse","EXCERPT_META_SELECTORS","shortContent","GenericTitleExtractor","GenericDatePublishedExtractor","GenericAuthorExtractor","GenericContentExtractor","bind","GenericLeadImageUrlExtractor","GenericDekExtractor","GenericNextPageUrlExtractor","url_and_domain","GenericUrlExtractor","GenericExcerptExtractor","word_count","GenericWordCountExtractor","direction","getDirection","_url_and_domain","_parsedUrl","Extractors","baseDomain","GenericExtractor","$matches","extractionOpts","extractHtml","_opts$extractHtml","_extractionOpts$defau","matchingSelector","transformElements","cleanBySelectors","Cleaners","ATTR_RE","extractor","_opts","contentOnly","extractedTitle","extractResult","_content","_extractResult","Extractor","extractorOpts","nextPageResult","pages","RootExtractor","total_pages","pages_rendered","_x","_ref$fetchAllPages","fetchAllPages","_result","validateUrl","getExtractor","rendered_pages","fetchResource","_context2","_callee2","_this2","module","exports","Mercury","insertValues","strings","part","idx","toString","bodyPattern","trailingWhitespace","template","compiled","indentLevel","line","file","dir","questions","inquirer","prompt","answers","website","spinner","confirm","args","msg","newParser","ora","savePage","r","succeed","filename","Date","getTime","writeFileSync","generateScaffold","log","getDir","extractorTemplate","extractorTest","extractorTestTemplate","confirmCreateDir","fs","existsSync","mkdirSync","scaffoldCustomParser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAAA,aAEA,wBAAA,CAA0BA,EAA1B,CAA8B,CAAE,WAAe,UAAA,mCAAOA,EAAP,KAAc,QAArB,EAAkC,cAAnC,CAAsDA,GAAG,SAAH,CAAtD,CAAsEA,EAA7E,CAAkF,CAElH,UAAUC,gBAAgBC,GAAhB,CAAV,CACA,oBAAoBC,aAApB,CACA,cAAcF,gBAAgBG,OAAhB,CAAd,CACA,cAAcH,gBAAgBI,OAAhB,CAAd,CACA,sBAAsBJ,gBAAgBK,eAAhB,CAAtB,CACA,eAAeL,gBAAgBM,QAAhB,CAAf,CACA,aAAaN,gBAAgBO,MAAhB,CAAb,CACA,YAAYP,gBAAgBQ,KAAhB,CAAZ,CACA,cAAcR,gBAAgBS,OAAhB,CAAd,CACA,gBAAgBT,gBAAgBU,SAAhB,CAAhB,CAEA,YAAc,CAACC,KAA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