mirror of
https://github.com/postlight/mercury-parser
synced 2024-11-18 21:28:22 +00:00
60a6861e18
Big undertaking to support Mercury in the browser. Builds are working and all tests are passing both for web and node builds. Most code is closely shared.
1 line
316 KiB
Plaintext
1 line
316 KiB
Plaintext
{"version":3,"file":null,"sources":["../src/utils/dom/constants.js","../src/utils/dom/brs-to-ps.js","../src/utils/dom/paragraphize.js","../src/utils/dom/convert-to-paragraphs.js","../src/utils/dom/convert-node-to.js","../src/utils/dom/clean-images.js","../src/utils/dom/strip-junk-tags.js","../src/utils/dom/clean-attributes.js","../src/extractors/generic/content/scoring/constants.js","../src/extractors/generic/content/scoring/get-weight.js","../src/extractors/generic/content/scoring/get-score.js","../src/extractors/generic/content/scoring/score-commas.js","../src/extractors/generic/content/scoring/score-length.js","../src/extractors/generic/content/scoring/score-paragraph.js","../src/extractors/generic/content/scoring/set-score.js","../src/extractors/generic/content/scoring/add-score.js","../src/extractors/generic/content/scoring/add-to-parent.js","../src/extractors/generic/content/scoring/get-or-init-score.js","../src/extractors/generic/content/scoring/score-node.js","../src/extractors/generic/content/scoring/score-content.js","../src/utils/text/normalize-spaces.js","../src/utils/text/extract-from-url.js","../src/utils/text/constants.js","../src/utils/text/article-base-url.js","../src/utils/text/has-sentence-end.js","../src/extractors/generic/content/scoring/merge-siblings.js","../src/extractors/generic/content/scoring/index.js","../src/utils/dom/clean-tags.js","../src/utils/dom/make-links-absolute.js","../src/utils/dom/link-density.js","../src/utils/dom/extract-from-selectors.js","../src/utils/dom/strip-tags.js","../src/utils/dom/within-comment.js","../src/utils/dom/node-is-sufficient.js","../src/utils/dom/get-attrs.js","../src/utils/dom/set-attr.js","../src/utils/dom/set-attrs.js","../src/utils/dom/index.js","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":["// Spacer images to be removed\nexport const SPACER_RE = new RegExp('trans|transparent|spacer|blank', 'i');\n\n// The class we will use to mark elements we want to keep\n// but would normally remove\nexport const KEEP_CLASS = 'mercury-parser-keep';\n\nexport const KEEP_SELECTORS = [\n 'iframe[src^=\"https://www.youtube.com\"]',\n 'iframe[src^=\"http://www.youtube.com\"]',\n 'iframe[src^=\"https://player.vimeo\"]',\n 'iframe[src^=\"http://player.vimeo\"]',\n];\n\n// A list of tags to strip from the output if we encounter them.\nexport const STRIP_OUTPUT_TAGS = [\n 'title',\n 'script',\n 'noscript',\n 'link',\n 'style',\n 'hr',\n 'embed',\n 'iframe',\n 'object',\n];\n\n// cleanAttributes\nexport const REMOVE_ATTRS = ['style', 'align'];\nexport const REMOVE_ATTR_SELECTORS = REMOVE_ATTRS.map(selector => `[${selector}]`);\nexport const REMOVE_ATTR_LIST = REMOVE_ATTRS.join(',');\nexport const WHITELIST_ATTRS = ['src', 'srcset', 'href', 'class', 'id', 'alt'];\nexport const WHITELIST_ATTRS_RE = new RegExp(`^(${WHITELIST_ATTRS.join('|')})$`, 'i');\n\n// removeEmpty\nexport const REMOVE_EMPTY_TAGS = ['p'];\nexport const REMOVE_EMPTY_SELECTORS = REMOVE_EMPTY_TAGS.map(tag => `${tag}:empty`).join(',');\n\n// cleanTags\nexport const CLEAN_CONDITIONALLY_TAGS = ['ul', 'ol', 'table', 'div', 'button', 'form'].join(',');\n\n// cleanHeaders\nconst HEADER_TAGS = ['h2', 'h3', 'h4', 'h5', 'h6'];\nexport const 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.\nexport const UNLIKELY_CANDIDATES_BLACKLIST = [\n 'ad-break',\n 'adbox',\n 'advert',\n 'addthis',\n 'agegate',\n 'aux',\n 'blogger-labels',\n 'combx',\n 'comment',\n 'conversation',\n 'disqus',\n 'entry-unrelated',\n 'extra',\n 'foot',\n // 'form', // This is too generic, has too many false positives\n 'header',\n 'hidden',\n 'loader',\n 'login', // Note: This can hit 'blogindex'.\n 'menu',\n 'meta',\n 'nav',\n 'outbrain',\n 'pager',\n 'pagination',\n 'predicta', // readwriteweb inline ad box\n 'presence_control_external', // lifehacker.com container full of false positives\n 'popup',\n 'printfriendly',\n 'related',\n 'remove',\n 'remark',\n 'rss',\n 'share',\n 'shoutbox',\n 'sidebar',\n 'sociable',\n 'sponsor',\n 'taboola',\n 'tools',\n];\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.\nexport const UNLIKELY_CANDIDATES_WHITELIST = [\n 'and',\n 'article',\n 'body',\n 'blogindex',\n 'column',\n 'content',\n 'entry-content-asset',\n 'format', // misuse of form\n 'hfeed',\n 'hentry',\n 'hatom',\n 'main',\n 'page',\n 'posts',\n 'shadow',\n];\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.\nexport const DIV_TO_P_BLOCK_TAGS = [\n 'a',\n 'blockquote',\n 'dl',\n 'div',\n 'img',\n 'p',\n 'pre',\n 'table',\n].join(',');\n\n// A list of tags that should be ignored when trying to find the top candidate\n// for a document.\nexport const NON_TOP_CANDIDATE_TAGS = [\n 'br',\n 'b',\n 'i',\n 'label',\n 'hr',\n 'area',\n 'base',\n 'basefont',\n 'input',\n 'img',\n 'link',\n 'meta',\n];\n\nexport const NON_TOP_CANDIDATE_TAGS_RE =\n new RegExp(`^(${NON_TOP_CANDIDATE_TAGS.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\nexport const HNEWS_CONTENT_SELECTORS = [\n ['.hentry', '.entry-content'],\n ['entry', '.entry-content'],\n ['.entry', '.entry_content'],\n ['.post', '.postbody'],\n ['.post', '.post_body'],\n ['.post', '.post-body'],\n];\n\nexport const PHOTO_HINTS = [\n 'figure',\n 'photo',\n 'image',\n 'caption',\n];\nexport const 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?\nexport const POSITIVE_SCORE_HINTS = [\n 'article',\n 'articlecontent',\n 'instapaper_body',\n 'blog',\n 'body',\n 'content',\n 'entry-content-asset',\n 'entry',\n 'hentry',\n 'main',\n 'Normal',\n 'page',\n 'pagination',\n 'permalink',\n 'post',\n 'story',\n 'text',\n '[-_]copy', // usatoday\n '\\\\Bcopy',\n];\n\n// The above list, joined into a matching regular expression\nexport const POSITIVE_SCORE_RE = new RegExp(POSITIVE_SCORE_HINTS.join('|'), 'i');\n\n// Readability publisher-specific guidelines\nexport const READABILITY_ASSET = 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?\nexport const NEGATIVE_SCORE_HINTS = [\n 'adbox',\n 'advert',\n 'author',\n 'bio',\n 'bookmark',\n 'bottom',\n 'byline',\n 'clear',\n 'com-',\n 'combx',\n 'comment',\n 'comment\\\\B',\n 'contact',\n 'copy',\n 'credit',\n 'crumb',\n 'date',\n 'deck',\n 'excerpt',\n 'featured', // tnr.com has a featured_content which throws us off\n 'foot',\n 'footer',\n 'footnote',\n 'graf',\n 'head',\n 'info',\n 'infotext', // newscientist.com copyright\n 'instapaper_ignore',\n 'jump',\n 'linebreak',\n 'link',\n 'masthead',\n 'media',\n 'meta',\n 'modal',\n 'outbrain', // slate.com junk\n 'promo',\n 'pr_', // autoblog - press release\n 'related',\n 'respond',\n 'roundcontent', // lifehacker restricted content warning\n 'scroll',\n 'secondary',\n 'share',\n 'shopping',\n 'shoutbox',\n 'side',\n 'sidebar',\n 'sponsor',\n 'stamp',\n 'sub',\n 'summary',\n 'tags',\n 'tools',\n 'widget',\n];\n// The above list, joined into a matching regular expression\nexport const 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.\nexport const IS_WP_SELECTOR = 'meta[name=generator][value^=WordPress]';\n\n// Match a digit. Pretty clear.\nexport const DIGIT_RE = new RegExp('[0-9]');\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.\nexport const EXTRANEOUS_LINK_HINTS = [\n 'print',\n 'archive',\n 'comment',\n 'discuss',\n 'e-mail',\n 'email',\n 'share',\n 'reply',\n 'all',\n 'login',\n 'sign',\n 'single',\n 'adx',\n 'entry-unrelated',\n];\nexport const 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\nexport const PAGE_RE = new RegExp('pag(e|ing|inat)', '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.\n// export const NEXT_LINK_TEXT_RE = new RegExp('(next|weiter|continue|>([^\\|]|$)|»([^\\|]|$))', 'i');\nexport const NEXT_LINK_TEXT_RE = /(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.\nexport const CAP_LINK_TEXT_RE = new RegExp('(first|last|end)', 'i');\n\n// Match any link text/classname/id that looks like it means the previous\n// page.\nexport const PREV_LINK_TEXT_RE = new RegExp('(prev|earl|old|new|<|«)', 'i');\n\n// Match 2 or more consecutive <br> tags\nexport const BR_TAGS_RE = new RegExp('(<br[^>]*>[ \\n\\r\\t]*){2,}', 'i');\n\n// Match 1 BR tag.\nexport const BR_TAG_RE = new RegExp('<br[^>]*>', 'i');\n\n// A list of all of the block level tags known in HTML5 and below. Taken from\n// http://bit.ly/qneNIT\nexport const BLOCK_LEVEL_TAGS = [\n 'article',\n 'aside',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'col',\n 'colgroup',\n 'dd',\n 'div',\n 'dl',\n 'dt',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'li',\n 'map',\n 'object',\n 'ol',\n 'output',\n 'p',\n 'pre',\n 'progress',\n 'section',\n 'table',\n 'tbody',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n 'video',\n];\nexport const 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.\nconst candidatesBlacklist = UNLIKELY_CANDIDATES_BLACKLIST.join('|');\nexport const CANDIDATES_BLACKLIST = new RegExp(candidatesBlacklist, 'i');\n\nconst candidatesWhitelist = UNLIKELY_CANDIDATES_WHITELIST.join('|');\nexport const CANDIDATES_WHITELIST = new RegExp(candidatesWhitelist, 'i');\n\nexport const UNLIKELY_RE = new RegExp(`!(${candidatesWhitelist})|(${candidatesBlacklist})`, 'i');\n\nexport const PARAGRAPH_SCORE_TAGS = new RegExp('^(p|li|span|pre)$', 'i');\nexport const CHILD_CONTENT_TAGS = new RegExp('^(td|blockquote|ol|ul|dl)$', 'i');\nexport const BAD_TAGS = new RegExp('^(address|form)$', 'i');\n\nexport const HTML_OR_BODY_RE = new RegExp('^(html|body)$', 'i');\n","import { paragraphize } from './index';\n\n// ## NOTES:\n// Another good candidate for refactoring/optimizing.\n// Very imperative code, I don't love it. - AP\n\n// Given cheerio object, convert consecutive <br /> tags into\n// <p /> tags instead.\n//\n// :param $: A cheerio object\n\nexport default function brsToPs($) {\n let collapsing = false;\n $('br').each((index, element) => {\n const $element = $(element);\n const nextElement = $element.next().get(0);\n\n if (nextElement && nextElement.tagName.toLowerCase() === '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","import { BLOCK_LEVEL_TAGS_RE } from './constants';\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\nexport default function paragraphize(node, $, br = false) {\n const $node = $(node);\n\n if (br) {\n let sibling = node.nextSibling;\n const 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 const 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","import { brsToPs, convertNodeTo } from 'utils/dom';\n\nimport { DIV_TO_P_BLOCK_TAGS } from './constants';\n\nfunction convertDivs($) {\n $('div').each((index, div) => {\n const $div = $(div);\n const 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((index, span) => {\n const $span = $(span);\n const 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\nexport default function convertToParagraphs($) {\n $ = brsToPs($);\n $ = convertDivs($);\n $ = convertSpans($);\n\n return $;\n}\n","import { getAttrs } from 'utils/dom';\n\nexport default function convertNodeTo($node, $, tag = 'p') {\n const node = $node.get(0);\n if (!node) {\n return $;\n }\n const attrs = getAttrs(node) || {};\n // console.log(attrs)\n\n const attribString = Reflect.ownKeys(attrs)\n .map(key => `${key}=${attrs[key]}`)\n .join(' ');\n let html;\n\n if ($.browser) {\n // In the browser, the contents of noscript tags aren't rendered, therefore\n // transforms on the noscript tag (commonly used for lazy-loading) don't work\n // as expected. This test case handles that\n html = node.tagName.toLowerCase() === 'noscript' ? $node.text() : $node.html();\n } else {\n html = $node.contents();\n }\n $node.replaceWith(\n `<${tag} ${attribString}>${html}</${tag}>`\n );\n return $;\n}\n","import { SPACER_RE } from './constants';\n\nfunction cleanForHeight($img, $) {\n const height = parseInt($img.attr('height'), 10);\n const 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\nexport default function cleanImages($article, $) {\n $article.find('img').each((index, img) => {\n const $img = $(img);\n\n cleanForHeight($img, $);\n removeSpacers($img, $);\n });\n\n return $;\n}\n","import {\n STRIP_OUTPUT_TAGS,\n KEEP_CLASS,\n} from './constants';\n\nexport default function stripJunkTags(article, $, tags = []) {\n if (tags.length === 0) {\n tags = STRIP_OUTPUT_TAGS;\n }\n\n // Remove matching elements, but ignore\n // any element with a class of mercury-parser-keep\n $(tags.join(','), article).not(`.${KEEP_CLASS}`).remove();\n\n // Remove the mercury-parser-keep class from result\n $(`.${KEEP_CLASS}`, article).removeClass(KEEP_CLASS);\n\n return $;\n}\n","import {\n getAttrs,\n setAttrs,\n} from 'utils/dom';\n\nimport { WHITELIST_ATTRS_RE } from './constants';\n\nfunction removeAllButWhitelist($article) {\n $article.find('*').each((index, node) => {\n const attrs = getAttrs(node);\n\n setAttrs(node, Reflect.ownKeys(attrs).reduce((acc, attr) => {\n if (WHITELIST_ATTRS_RE.test(attr)) {\n return { ...acc, [attr]: attrs[attr] };\n }\n\n return acc;\n }, {}));\n });\n\n return $article;\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\nexport default function cleanAttributes($article) {\n // Grabbing the parent because at this point\n // $article will be wrapped in a div which will\n // have a score set on it.\n return removeAllButWhitelist(\n $article.parent().length ?\n $article.parent() : $article\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.\nexport const UNLIKELY_CANDIDATES_BLACKLIST = [\n 'ad-break',\n 'adbox',\n 'advert',\n 'addthis',\n 'agegate',\n 'aux',\n 'blogger-labels',\n 'combx',\n 'comment',\n 'conversation',\n 'disqus',\n 'entry-unrelated',\n 'extra',\n 'foot',\n 'form',\n 'header',\n 'hidden',\n 'loader',\n 'login', // Note: This can hit 'blogindex'.\n 'menu',\n 'meta',\n 'nav',\n 'pager',\n 'pagination',\n 'predicta', // readwriteweb inline ad box\n 'presence_control_external', // lifehacker.com container full of false positives\n 'popup',\n 'printfriendly',\n 'related',\n 'remove',\n 'remark',\n 'rss',\n 'share',\n 'shoutbox',\n 'sidebar',\n 'sociable',\n 'sponsor',\n 'tools',\n];\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.\nexport const UNLIKELY_CANDIDATES_WHITELIST = [\n 'and',\n 'article',\n 'body',\n 'blogindex',\n 'column',\n 'content',\n 'entry-content-asset',\n 'format', // misuse of form\n 'hfeed',\n 'hentry',\n 'hatom',\n 'main',\n 'page',\n 'posts',\n 'shadow',\n];\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.\nexport const DIV_TO_P_BLOCK_TAGS = [\n 'a',\n 'blockquote',\n 'dl',\n 'div',\n 'img',\n 'p',\n 'pre',\n 'table',\n].join(',');\n\n// A list of tags that should be ignored when trying to find the top candidate\n// for a document.\nexport const NON_TOP_CANDIDATE_TAGS = [\n 'br',\n 'b',\n 'i',\n 'label',\n 'hr',\n 'area',\n 'base',\n 'basefont',\n 'input',\n 'img',\n 'link',\n 'meta',\n];\n\nexport const NON_TOP_CANDIDATE_TAGS_RE =\n new RegExp(`^(${NON_TOP_CANDIDATE_TAGS.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\nexport const HNEWS_CONTENT_SELECTORS = [\n ['.hentry', '.entry-content'],\n ['entry', '.entry-content'],\n ['.entry', '.entry_content'],\n ['.post', '.postbody'],\n ['.post', '.post_body'],\n ['.post', '.post-body'],\n];\n\nexport const PHOTO_HINTS = [\n 'figure',\n 'photo',\n 'image',\n 'caption',\n];\nexport const 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?\nexport const POSITIVE_SCORE_HINTS = [\n 'article',\n 'articlecontent',\n 'instapaper_body',\n 'blog',\n 'body',\n 'content',\n 'entry-content-asset',\n 'entry',\n 'hentry',\n 'main',\n 'Normal',\n 'page',\n 'pagination',\n 'permalink',\n 'post',\n 'story',\n 'text',\n '[-_]copy', // usatoday\n '\\\\Bcopy',\n];\n\n// The above list, joined into a matching regular expression\nexport const POSITIVE_SCORE_RE = new RegExp(POSITIVE_SCORE_HINTS.join('|'), 'i');\n\n// Readability publisher-specific guidelines\nexport const READABILITY_ASSET = 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?\nexport const NEGATIVE_SCORE_HINTS = [\n 'adbox',\n 'advert',\n 'author',\n 'bio',\n 'bookmark',\n 'bottom',\n 'byline',\n 'clear',\n 'com-',\n 'combx',\n 'comment',\n 'comment\\\\B',\n 'contact',\n 'copy',\n 'credit',\n 'crumb',\n 'date',\n 'deck',\n 'excerpt',\n 'featured', // tnr.com has a featured_content which throws us off\n 'foot',\n 'footer',\n 'footnote',\n 'graf',\n 'head',\n 'info',\n 'infotext', // newscientist.com copyright\n 'instapaper_ignore',\n 'jump',\n 'linebreak',\n 'link',\n 'masthead',\n 'media',\n 'meta',\n 'modal',\n 'outbrain', // slate.com junk\n 'promo',\n 'pr_', // autoblog - press release\n 'related',\n 'respond',\n 'roundcontent', // lifehacker restricted content warning\n 'scroll',\n 'secondary',\n 'share',\n 'shopping',\n 'shoutbox',\n 'side',\n 'sidebar',\n 'sponsor',\n 'stamp',\n 'sub',\n 'summary',\n 'tags',\n 'tools',\n 'widget',\n];\n// The above list, joined into a matching regular expression\nexport const NEGATIVE_SCORE_RE = new RegExp(NEGATIVE_SCORE_HINTS.join('|'), 'i');\n\n// Match a digit. Pretty clear.\nexport const DIGIT_RE = new RegExp('[0-9]');\n\n// Match 2 or more consecutive <br> tags\nexport const BR_TAGS_RE = new RegExp('(<br[^>]*>[ \\n\\r\\t]*){2,}', 'i');\n\n// Match 1 BR tag.\nexport const BR_TAG_RE = new RegExp('<br[^>]*>', 'i');\n\n// A list of all of the block level tags known in HTML5 and below. Taken from\n// http://bit.ly/qneNIT\nexport const BLOCK_LEVEL_TAGS = [\n 'article',\n 'aside',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'col',\n 'colgroup',\n 'dd',\n 'div',\n 'dl',\n 'dt',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'li',\n 'map',\n 'object',\n 'ol',\n 'output',\n 'p',\n 'pre',\n 'progress',\n 'section',\n 'table',\n 'tbody',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n 'video',\n];\nexport const 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.\nconst candidatesBlacklist = UNLIKELY_CANDIDATES_BLACKLIST.join('|');\nexport const CANDIDATES_BLACKLIST = new RegExp(candidatesBlacklist, 'i');\n\nconst candidatesWhitelist = UNLIKELY_CANDIDATES_WHITELIST.join('|');\nexport const CANDIDATES_WHITELIST = new RegExp(candidatesWhitelist, 'i');\n\nexport const UNLIKELY_RE = new RegExp(`!(${candidatesWhitelist})|(${candidatesBlacklist})`, 'i');\n\nexport const PARAGRAPH_SCORE_TAGS = new RegExp('^(p|li|span|pre)$', 'i');\nexport const CHILD_CONTENT_TAGS = new RegExp('^(td|blockquote|ol|ul|dl)$', 'i');\nexport const BAD_TAGS = new RegExp('^(address|form)$', 'i');\n\nexport const HTML_OR_BODY_RE = new RegExp('^(html|body)$', 'i');\n","import {\n NEGATIVE_SCORE_RE,\n POSITIVE_SCORE_RE,\n PHOTO_HINTS_RE,\n READABILITY_ASSET,\n} from './constants';\n\n// Get the score of a node based on its className and id.\nexport default function getWeight(node) {\n const classes = node.attr('class');\n const id = node.attr('id');\n let score = 0;\n\n if (id) {\n // if id exists, try to score on both positive and negative\n if (POSITIVE_SCORE_RE.test(id)) {\n score += 25;\n }\n if (NEGATIVE_SCORE_RE.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.test(classes)) {\n score += 25;\n }\n if (NEGATIVE_SCORE_RE.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.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.test(classes)) {\n score += 25;\n }\n }\n\n return score;\n}\n","// returns the score of a node based on\n// the node's score attribute\n// returns null if no score set\nexport default function getScore($node) {\n // console.log(\"NODE\", $node, $node.attr('score'))\n return parseFloat($node.attr('score')) || null;\n}\n","// return 1 for every comma in text\nexport default function scoreCommas(text) {\n return (text.match(/,/g) || []).length;\n}\n","const idkRe = new RegExp('^(p|pre)$', 'i');\n\nexport default function scoreLength(textLength, tagName = 'p') {\n const chunks = textLength / 50;\n\n if (chunks > 0) {\n let lengthBonus;\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","import {\n scoreCommas,\n scoreLength,\n} from './index';\n\n// Score a paragraph using various methods. Things like number of\n// commas, etc. Higher is better.\nexport default function scoreParagraph(node) {\n let score = 1;\n const text = node.text().trim();\n const 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","export default function setScore($node, $, score) {\n $node.attr('score', score);\n return $node;\n}\n","import {\n getOrInitScore,\n setScore,\n} from './index';\n\nexport default function addScore($node, $, amount) {\n try {\n const score = getOrInitScore($node, $) + amount;\n setScore($node, $, score);\n } catch (e) {\n // Ignoring; error occurs in scoreNode\n }\n\n return $node;\n}\n","import { addScore } from './index';\n\n// Adds 1/4 of a child's score to its parent\nexport default function addToParent(node, $, score) {\n const parent = node.parent();\n if (parent) {\n addScore(parent, $, score * 0.25);\n }\n\n return node;\n}\n","import {\n getScore,\n scoreNode,\n getWeight,\n addToParent,\n} from './index';\n\n// gets and returns the score if it exists\n// if not, initializes a score based on\n// the node's tag type\nexport default function getOrInitScore($node, $, weightNodes = true) {\n let 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","import { scoreParagraph } from './index';\nimport {\n PARAGRAPH_SCORE_TAGS,\n CHILD_CONTENT_TAGS,\n BAD_TAGS,\n} from './constants';\n\n// Score an individual node. Has some smarts for paragraphs, otherwise\n// just scores based on tag.\nexport default function scoreNode($node) {\n const { tagName } = $node.get(0);\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 if (PARAGRAPH_SCORE_TAGS.test(tagName)) {\n return scoreParagraph($node);\n } else if (tagName.toLowerCase() === 'div') {\n return 5;\n } else if (CHILD_CONTENT_TAGS.test(tagName)) {\n return 3;\n } else if (BAD_TAGS.test(tagName)) {\n return -3;\n } else if (tagName.toLowerCase() === 'th') {\n return -5;\n }\n\n return 0;\n}\n","import { convertNodeTo } from 'utils/dom';\n\nimport { HNEWS_CONTENT_SELECTORS } from './constants';\nimport {\n scoreNode,\n setScore,\n getOrInitScore,\n addScore,\n} from './index';\n\nfunction convertSpans($node, $) {\n if ($node.get(0)) {\n const { tagName } = $node.get(0);\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($node, $);\n addScore($node, $, score);\n }\n}\n\nfunction scorePs($, weightNodes) {\n $('p, pre').not('[score]').each((index, node) => {\n // The raw score for this paragraph, before we add any parent/child\n // scores.\n let $node = $(node);\n $node = setScore($node, $, getOrInitScore($node, $, weightNodes));\n\n const $parent = $node.parent();\n const 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\nexport default function scoreContent($, weightNodes = true) {\n // First, look for special hNews based selectors and give them a big\n // boost, if they exist\n HNEWS_CONTENT_SELECTORS.forEach(([parentSelector, childSelector]) => {\n $(`${parentSelector} ${childSelector}`).each((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","const NORMALIZE_RE = /\\s{2,}/g;\n\nexport default function normalizeSpaces(text) {\n return text.replace(NORMALIZE_RE, ' ').trim();\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.\nexport default function extractFromUrl(url, regexList) {\n const matchRe = regexList.find(re => re.test(url));\n // const matchRe = null\n if (matchRe) {\n return matchRe.exec(url)[1];\n }\n\n return null;\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\nexport const PAGE_IN_HREF_RE = new RegExp('(page|paging|(p(a|g|ag)?(e|enum|ewanted|ing|ination)))?(=|/)([0-9]{1,3})', 'i');\n\nexport const HAS_ALPHA_RE = /[a-z]/i;\n\nexport const IS_ALPHA_RE = /^[a-z]+$/i;\nexport const IS_DIGIT_RE = /^[0-9]+$/i;\n","import URL from 'url';\n\nimport {\n HAS_ALPHA_RE,\n IS_ALPHA_RE,\n IS_DIGIT_RE,\n PAGE_IN_HREF_RE,\n} from './constants';\n\nfunction isGoodSegment(segment, index, firstSegmentHasLetters) {\n let 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.\nexport default function articleBaseUrl(url, parsed) {\n const parsedUrl = parsed || URL.parse(url);\n const { protocol, host, path } = parsedUrl;\n\n let firstSegmentHasLetters = false;\n const cleanedSegments = path.split('/')\n .reverse()\n .reduce((acc, rawSegment, index) => {\n let segment = rawSegment;\n\n // Split off and save anything that looks like a file type.\n if (segment.includes('.')) {\n const [possibleSegment, fileExt] = segment.split('.');\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","// Given a string, return True if it appears to have an ending sentence\n// within it, false otherwise.\nconst SENTENCE_END_RE = new RegExp('.( |$)');\nexport default function hasSentenceEnd(text) {\n return SENTENCE_END_RE.test(text);\n}\n","import {\n textLength,\n linkDensity,\n} from 'utils/dom';\nimport { hasSentenceEnd } from 'utils/text';\n\nimport { NON_TOP_CANDIDATE_TAGS_RE } from './constants';\nimport { getScore } from './index';\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\nexport default function mergeSiblings($candidate, topScore, $) {\n if (!$candidate.parent().length) {\n return $candidate;\n }\n\n const siblingScoreThreshold = Math.max(10, topScore * 0.25);\n const wrappingDiv = $('<div></div>');\n\n $candidate.parent().children().each((index, sibling) => {\n const $sibling = $(sibling);\n // Ignore tags like BR, HR, etc\n if (NON_TOP_CANDIDATE_TAGS_RE.test(sibling.tagName)) {\n return null;\n }\n\n const siblingScore = getScore($sibling);\n if (siblingScore) {\n if ($sibling.get(0) === $candidate.get(0)) {\n wrappingDiv.append($sibling);\n } else {\n let contentBonus = 0;\n const 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 const newScore = siblingScore + contentBonus;\n\n if (newScore >= siblingScoreThreshold) {\n return wrappingDiv.append($sibling);\n } else if (sibling.tagName === 'p') {\n const siblingContent = $sibling.text();\n const siblingContentLength = textLength(siblingContent);\n\n if (siblingContentLength > 80 && density < 0.25) {\n return wrappingDiv.append($sibling);\n } else if (siblingContentLength <= 80 && density === 0 &&\n hasSentenceEnd(siblingContent)) {\n return wrappingDiv.append($sibling);\n }\n }\n }\n }\n\n return null;\n });\n\n if (wrappingDiv.children().length === 1 &&\n wrappingDiv.children().first().get(0) === $candidate.get(0)) {\n return $candidate;\n }\n\n return wrappingDiv;\n}\n","// Scoring\nexport { default as getWeight } from './get-weight';\nexport { default as getScore } from './get-score';\nexport { default as scoreCommas } from './score-commas';\nexport { default as scoreLength } from './score-length';\nexport { default as scoreParagraph } from './score-paragraph';\nexport { default as setScore } from './set-score';\nexport { default as addScore } from './add-score';\nexport { default as addToParent } from './add-to-parent';\nexport { default as getOrInitScore } from './get-or-init-score';\nexport { default as scoreNode } from './score-node';\nexport { default as scoreContent } from './score-content';\nexport { default as findTopCandidate } from './find-top-candidate';\n","import {\n getScore,\n setScore,\n getOrInitScore,\n scoreCommas,\n} from 'extractors/generic/content/scoring';\n\nimport { CLEAN_CONDITIONALLY_TAGS } from './constants';\nimport { normalizeSpaces } from '../text';\nimport { linkDensity } from './index';\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 const content = normalizeSpaces($node.text());\n\n if (scoreCommas(content) < 10) {\n const pCount = $('p', $node).length;\n const 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 const contentLength = content.length;\n const 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 const 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 const tagName = $node.get(0).tagName.toLowerCase();\n const nodeIsList = tagName === 'ol' || tagName === 'ul';\n if (nodeIsList) {\n const previousNode = $node.prev();\n if (previousNode && normalizeSpaces(previousNode.text()).slice(-1) === ':') {\n return;\n }\n }\n\n $node.remove();\n return;\n }\n\n const 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.\nexport default function cleanTags($article, $) {\n $(CLEAN_CONDITIONALLY_TAGS, $article).each((index, node) => {\n const $node = $(node);\n let 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","/* eslint-disable */\nimport URL from 'url';\n\nimport {\n getAttrs,\n setAttr,\n} from 'utils/dom';\n\nfunction absolutize($, rootUrl, attr, $content) {\n $(`[${attr}]`, $content).each((_, node) => {\n const attrs = getAttrs(node);\n const url = attrs[attr];\n\n if (url) {\n const absoluteUrl = URL.resolve(rootUrl, url);\n setAttr(node, attr, absoluteUrl);\n }\n });\n}\n\nexport default function makeLinksAbsolute($content, $, url) {\n ['href', 'src'].forEach(attr => absolutize($, url, attr, $content));\n\n return $content;\n}\n","export function textLength(text) {\n return text.trim()\n .replace(/\\s+/g, ' ')\n .length;\n}\n\n// Determines what percentage of the text\n// in a node is link text\n// Takes a node, returns a float\nexport function linkDensity($node) {\n const totalTextLength = textLength($node.text());\n\n const linkText = $node.find('a').text();\n const 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","import { withinComment } from 'utils/dom';\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.\nexport default function extractFromSelectors(\n $,\n selectors,\n maxChildren = 1,\n textOnly = true\n) {\n for (const selector of selectors) {\n const 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 const $node = $(nodes[0]);\n\n if (isGoodNode($node, maxChildren)) {\n let content;\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\n return null;\n}\n","// strips all tags from a string of text\nexport default function stripTags(text, $) {\n // Wrapping text in html element prevents errors when text\n // has no html\n const cleanText = $(`<span>${text}</span>`).text();\n return cleanText === '' ? text : cleanText;\n}\n","import { getAttrs } from 'utils/dom';\n\nexport default function withinComment($node) {\n const parents = $node.parents().toArray();\n const commentParent = parents.find((parent) => {\n const attrs = getAttrs(parent);\n const { class: nodeClass, id } = attrs;\n const classAndId = `${nodeClass} ${id}`;\n return classAndId.includes('comment');\n });\n\n return commentParent !== undefined;\n}\n","// Given a node, determine if it's article-like enough to return\n// param: node (a cheerio node)\n// return: boolean\n\nexport default function nodeIsSufficient($node) {\n return $node.text().trim().length >= 100;\n}\n","export default function getAttrs(node) {\n const { attribs, attributes } = node;\n\n if (!attribs && attributes) {\n const attrs = Reflect.ownKeys(attributes).reduce((acc, index) => {\n const attr = attributes[index];\n\n if (!attr.name || !attr.value) return acc;\n\n acc[attr.name] = attr.value;\n return acc;\n }, {});\n return attrs;\n }\n\n return attribs;\n}\n","export default function setAttr(node, attr, val) {\n if (node.attribs) {\n node.attribs[attr] = val;\n } else if (node.attributes) {\n node.setAttribute(attr, val);\n }\n\n return node;\n}\n","/* eslint-disable */\nexport default function setAttrs(node, attrs) {\n if (node.attribs) {\n node.attribs = attrs;\n } else if (node.attributes) {\n while(node.attributes.length > 0)\n node.removeAttribute(node.attributes[0].name);\n\n Reflect.ownKeys(attrs).forEach(key => {\n node.setAttribute(key, attrs[key]);\n })\n }\n\n return node;\n}\n","// DOM manipulation\nexport { default as stripUnlikelyCandidates } from './strip-unlikely-candidates';\nexport { default as brsToPs } from './brs-to-ps';\nexport { default as paragraphize } from './paragraphize';\nexport { default as convertToParagraphs } from './convert-to-paragraphs';\nexport { default as convertNodeTo } from './convert-node-to';\nexport { default as cleanImages } from './clean-images';\nexport { default as markToKeep } from './mark-to-keep';\nexport { default as stripJunkTags } from './strip-junk-tags';\nexport { default as cleanHOnes } from './clean-h-ones';\nexport { default as cleanAttributes } from './clean-attributes';\nexport { default as removeEmpty } from './remove-empty';\nexport { default as cleanTags } from './clean-tags';\nexport { default as cleanHeaders } from './clean-headers';\nexport { default as rewriteTopLevel } from './rewrite-top-level';\nexport { default as makeLinksAbsolute } from './make-links-absolute';\nexport { textLength, linkDensity } from './link-density';\nexport { default as extractFromMeta } from './extract-from-meta';\nexport { default as extractFromSelectors } from './extract-from-selectors';\nexport { default as stripTags } from './strip-tags';\nexport { default as withinComment } from './within-comment';\nexport { default as nodeIsSufficient } from './node-is-sufficient';\nexport { default as isWordpress } from './is-wordpress';\nexport { default as getAttrs } from './get-attrs';\nexport { default as setAttr } from './set-attr';\nexport { default as setAttrs } from './set-attrs';\n","'use strict';\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar _regeneratorRuntime = _interopDefault(require('babel-runtime/regenerator'));\nvar _extends = _interopDefault(require('babel-runtime/helpers/extends'));\nvar _asyncToGenerator = _interopDefault(require('babel-runtime/helpers/asyncToGenerator'));\nvar URL = _interopDefault(require('url'));\nvar cheerio = _interopDefault(require('cheerio'));\nvar _Promise = _interopDefault(require('babel-runtime/core-js/promise'));\nvar request = _interopDefault(require('request'));\nvar _Reflect$ownKeys = _interopDefault(require('babel-runtime/core-js/reflect/own-keys'));\nvar _toConsumableArray = _interopDefault(require('babel-runtime/helpers/toConsumableArray'));\nvar _defineProperty = _interopDefault(require('babel-runtime/helpers/defineProperty'));\nvar _slicedToArray = _interopDefault(require('babel-runtime/helpers/slicedToArray'));\nvar _typeof = _interopDefault(require('babel-runtime/helpers/typeof'));\nvar _getIterator = _interopDefault(require('babel-runtime/core-js/get-iterator'));\nvar _Object$keys = _interopDefault(require('babel-runtime/core-js/object/keys'));\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 _Array$from = _interopDefault(require('babel-runtime/core-js/array/from'));\nvar ellipsize = _interopDefault(require('ellipsize'));\n\nvar _marked = [range].map(_regeneratorRuntime.mark);\n\nfunction range() {\n var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;\n var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 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\n// Turn the global proxy on or off\n// Proxying is not currently enabled in Python source\n// so not implementing logic in port.\n\nfunction get(options) {\n // eslint-disable-line\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 ? arguments[1] : false;\n\n // Check if we got a valid status code\n // This isn't great, but I'm requiring a statusMessage to be set\n // before short circuiting b/c nock doesn't set it in tests\n // statusMessage only not set in nock response, in which case\n // I check statusCode, which is currently only 200 for OK responses\n // in tests\n if (response.statusMessage && response.statusMessage !== 'OK' || response.statusCode !== 200) {\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 contentType = _response$headers['content-type'],\n 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// Grabs the last two pieces of the URL and joins them back together\n// This is to get the 'livejournal.com' from 'erotictrains.livejournal.com'\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$1 = (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', {\n body: body,\n response: response\n });\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\n// Spacer images to be removed\nvar SPACER_RE = new RegExp('trans|transparent|spacer|blank', 'i');\n\n// The class we will use to mark elements we want to keep\n// but would normally remove\nvar KEEP_CLASS = 'mercury-parser-keep';\n\nvar KEEP_SELECTORS = ['iframe[src^=\"https://www.youtube.com\"]', 'iframe[src^=\"http://www.youtube.com\"]', 'iframe[src^=\"https://player.vimeo\"]', 'iframe[src^=\"http://player.vimeo\"]'];\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', 'srcset', 'href', 'class', 'id', 'alt'];\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.\n\n\n\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\n\n\n\n\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// Readability publisher-specific guidelines\n\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// Match a digit. Pretty clear.\n\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.\n\n\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// 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.\n// export const NEXT_LINK_TEXT_RE = new RegExp('(next|weiter|continue|>([^\\|]|$)|»([^\\|]|$))', 'i');\n\n\n// Match any link text/classname/id that looks like it is an end link: things\n// like \"first\", \"last\", \"end\", etc.\n\n\n// Match any link text/classname/id that looks like it means the previous\n// page.\n\n\n// Match 2 or more consecutive <br> tags\n\n\n// Match 1 BR tag.\n\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// Given cheerio object, convert consecutive <br /> tags into\n// <p /> tags instead.\n//\n// :param $: A cheerio object\n\nfunction brsToPs$$1($) {\n var collapsing = false;\n $('br').each(function (index, element) {\n var $element = $(element);\n var nextElement = $element.next().get(0);\n\n if (nextElement && nextElement.tagName.toLowerCase() === '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 ? arguments[2] : false;\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$$1($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$$1($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$$1($) {\n $ = brsToPs$$1($);\n $ = convertDivs($);\n $ = convertSpans($);\n\n return $;\n}\n\nfunction convertNodeTo$$1($node, $) {\n var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'p';\n\n var node = $node.get(0);\n if (!node) {\n return $;\n }\n var attrs = getAttrs(node) || {};\n\n var attribString = _Reflect$ownKeys(attrs).map(function (key) {\n return key + '=' + attrs[key];\n }).join(' ');\n var html = void 0;\n\n if ($.browser) {\n // In the browser, the contents of noscript tags aren't rendered, therefore\n // transforms on the noscript tag (commonly used for lazy-loading) don't work\n // as expected. This test case handles that\n html = node.tagName.toLowerCase() === 'noscript' ? $node.text() : $node.html();\n } else {\n html = $node.contents();\n }\n $node.replaceWith('<' + tag + ' ' + attribString + '>' + html + '</' + 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 markToKeep(article, $, url) {\n var tags = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n\n if (tags.length === 0) {\n tags = KEEP_SELECTORS;\n }\n\n if (url) {\n var _URL$parse = URL.parse(url),\n protocol = _URL$parse.protocol,\n hostname = _URL$parse.hostname;\n\n tags = [].concat(_toConsumableArray(tags), ['iframe[src^=\"' + protocol + '//' + hostname + '\"]']);\n }\n\n $(tags.join(','), article).addClass(KEEP_CLASS);\n\n return $;\n}\n\nfunction stripJunkTags(article, $) {\n var tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n\n if (tags.length === 0) {\n tags = STRIP_OUTPUT_TAGS;\n }\n\n // Remove matching elements, but ignore\n // any element with a class of mercury-parser-keep\n $(tags.join(','), article).not('.' + KEEP_CLASS).remove();\n\n // Remove the mercury-parser-keep class from result\n $('.' + KEEP_CLASS, article).removeClass(KEEP_CLASS);\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$$1(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$$1($(node), $, 'h2');\n });\n }\n\n return $;\n}\n\nfunction removeAllButWhitelist($article) {\n $article.find('*').each(function (index, node) {\n var attrs = getAttrs(node);\n\n setAttrs(node, _Reflect$ownKeys(attrs).reduce(function (acc, attr) {\n if (WHITELIST_ATTRS_RE.test(attr)) {\n return _extends({}, acc, _defineProperty({}, attr, attrs[attr]));\n }\n\n return acc;\n }, {}));\n });\n\n return $article;\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$$1($article) {\n // Grabbing the parent because at this point\n // $article will be wrapped in a div which will\n // have a score set on it.\n return removeAllButWhitelist($article.parent().length ? $article.parent() : $article);\n}\n\nfunction removeEmpty($article, $) {\n $article.find('p').each(function (index, p) {\n var $p = $(p);\n if ($p.find('iframe, img').length === 0 && $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// Match a digit. Pretty clear.\n\n\n// Match 2 or more consecutive <br> tags\n\n\n// Match 1 BR tag.\n\n\n// A list of all of the block level tags known in HTML5 and below. Taken from\n// http://bit.ly/qneNIT\n\n\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('|');\n\n\nvar candidatesWhitelist$1 = UNLIKELY_CANDIDATES_WHITELIST$1.join('|');\n\n\n\n\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 // console.log(\"NODE\", $node, $node.attr('score'))\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 ? arguments[1] : 'p';\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$$1(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$$1($node, $, amount) {\n try {\n var score = getOrInitScore$$1($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$$1(node, $, score) {\n var parent = node.parent();\n if (parent) {\n addScore$$1(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$$1($node, $) {\n var weightNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n\n var score = getScore($node);\n\n if (score) {\n return score;\n }\n\n score = scoreNode$$1($node);\n\n if (weightNodes) {\n score += getWeight($node);\n }\n\n addToParent$$1($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$$1($node) {\n var _$node$get = $node.get(0),\n 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\n if (PARAGRAPH_SCORE_TAGS$1.test(tagName)) {\n return scoreParagraph$$1($node);\n } else if (tagName.toLowerCase() === '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.toLowerCase() === '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 tagName = _$node$get.tagName;\n\n if (tagName === 'span') {\n // convert spans to divs\n convertNodeTo$$1($node, $, 'div');\n }\n }\n}\n\nfunction addScoreTo($node, $, score) {\n if ($node) {\n convertSpans$1($node, $);\n addScore$$1($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$$1($node, $, weightNodes));\n\n var $parent = $node.parent();\n var rawScore = scoreNode$$1($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$$1($) {\n var weightNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\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 parentSelector = _ref2[0],\n childSelector = _ref2[1];\n\n $(parentSelector + ' ' + childSelector).each(function (index, node) {\n addScore$$1($(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 // const matchRe = null\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 host = parsedUrl.host,\n 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 _segment$split2 = _slicedToArray(_segment$split, 2),\n possibleSegment = _segment$split2[0],\n 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\nfunction excerptContent(content) {\n var words = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;\n\n return content.trim().split(/\\s+/).slice(0, words).join(' ');\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.get(0) === $candidate.get(0)) {\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 if (wrappingDiv.children().length === 1 && wrappingDiv.children().first().get(0) === $candidate.get(0)) {\n return $candidate;\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$$1($) {\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\n// Scoring\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.toLowerCase();\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$$1($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$$1($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$$1(article, $) {\n // I'm not using context here because\n // it's problematic when converting the\n // top-level/root node - AP\n $ = convertNodeTo$$1($('html'), $, 'div');\n $ = convertNodeTo$$1($('body'), $, 'div');\n\n return $;\n}\n\n/* eslint-disable */\nfunction absolutize($, rootUrl, attr, $content) {\n $('[' + attr + ']', $content).each(function (_, node) {\n var attrs = getAttrs(node);\n var url = attrs[attr];\n\n if (url) {\n var absoluteUrl = URL.resolve(rootUrl, url);\n setAttr(node, attr, absoluteUrl);\n }\n });\n}\n\nfunction makeLinksAbsolute$$1($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$$1($, metaNames, cachedNames) {\n var cleanTags$$1 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;\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$$1) {\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 = _getIterator(foundNames), _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$$1($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$$1($, selectors) {\n var maxChildren = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;\n var textOnly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = _getIterator(selectors), _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$$1($node) {\n var parents = $node.parents().toArray();\n var commentParent = parents.find(function (parent) {\n var attrs = getAttrs(parent);\n var nodeClass = attrs.class,\n id = attrs.id;\n\n var classAndId = nodeClass + ' ' + 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\nfunction getAttrs(node) {\n var attribs = node.attribs,\n attributes = node.attributes;\n\n\n if (!attribs && attributes) {\n var attrs = _Reflect$ownKeys(attributes).reduce(function (acc, index) {\n var attr = attributes[index];\n\n acc[attr.name] = attr.value;\n return acc;\n }, {});\n return attrs;\n }\n\n return attribs;\n}\n\nfunction setAttr(node, attr, val) {\n if (node.attribs) {\n node.attribs[attr] = val;\n } else if (node.attributes) {\n node.setAttribute(attr, val);\n }\n\n return node;\n}\n\n/* eslint-disable */\nfunction setAttrs(node, attrs) {\n if (node.attribs) {\n node.attribs = attrs;\n } else if (node.attributes) {\n while (node.attributes.length > 0) {\n node.removeAttribute(node.attributes[0].name);\n }_Reflect$ownKeys(attrs).forEach(function (key) {\n node.setAttribute(key, attrs[key]);\n });\n }\n\n return node;\n}\n\n// DOM manipulation\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 var attrs = getAttrs(img);\n\n _Reflect$ownKeys(attrs).forEach(function (attr) {\n var value = attrs[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 $('*').first().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$1(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 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 ($('*').first().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 merge = function merge(extractor, domains) {\n return domains.reduce(function (acc, domain) {\n acc[domain] = extractor;\n return acc;\n }, {});\n};\n\nfunction mergeSupportedDomains(extractor) {\n return extractor.supportedDomains ? merge(extractor, [extractor.domain].concat(_toConsumableArray(extractor.supportedDomains))) : merge(extractor, [extractor.domain]);\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: ['.post h2.title']\n },\n\n date_published: {\n selectors: ['span.publishdate']\n }\n};\n\nvar NYMagExtractor = {\n domain: 'nymag.com',\n content: {\n // Order by most likely. Extractor will stop on first occurrence\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 if ($.browser) {\n var $children = $($node.text());\n\n if ($children.length === 1 && $children.get(0) !== undefined && $children.get(0).tagName.toLowerCase() === 'img') {\n return 'figure';\n }\n } else {\n var _$children = $node.children();\n if (_$children.length === 1 && _$children.get(0).tagName === 'img') {\n return 'figure';\n }\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]', 'datetime'], 'time.article-timestamp']\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]', 'data-time-ms']]\n }\n\n};\n\nvar NYTimesExtractor = {\n domain: 'www.nytimes.com',\n\n title: {\n selectors: ['.g-headline', 'h1.headline']\n },\n\n author: {\n selectors: [['meta[name=\"author\"]', 'value'], '.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\n// Rename CustomExtractor\n// to fit your publication\nvar TheAtlanticExtractor = {\n domain: 'www.theatlantic.com',\n title: {\n selectors: ['h1.hed']\n },\n\n author: {\n selectors: ['article#article .article-cover-extra .metadata .byline a']\n },\n\n content: {\n selectors: ['.article-body'],\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 // 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 date_published: {\n selectors: [['time[itemProp=\"datePublished\"]', 'datetime']]\n },\n\n lead_image_url: null,\n\n dek: null,\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar NewYorkerExtractor = {\n domain: 'www.newyorker.com',\n title: {\n selectors: ['h1.title']\n },\n\n author: {\n selectors: ['.contributors']\n },\n\n content: {\n selectors: ['div#articleBody', 'div.articleBody'],\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 // 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 date_published: {\n selectors: [['meta[name=\"article:published_time\"]', 'value']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"og:description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar WiredExtractor = {\n domain: 'www.wired.com',\n title: {\n selectors: ['h1.post-title']\n },\n\n author: {\n selectors: ['a[rel=\"author\"]']\n },\n\n content: {\n selectors: ['article.content'],\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 // 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: ['.visually-hidden']\n },\n\n date_published: {\n selectors: [['meta[itemprop=\"datePublished\"]', 'value']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"og:description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar MSNExtractor = {\n domain: 'www.msn.com',\n title: {\n selectors: ['h1']\n },\n\n author: {\n selectors: ['span.authorname-txt']\n },\n\n content: {\n selectors: ['div.richtext'],\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 // 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: ['span.caption']\n },\n\n date_published: {\n selectors: ['span.time']\n },\n\n lead_image_url: {\n selectors: []\n },\n\n dek: {\n selectors: [['meta[name=\"description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar YahooExtractor = {\n domain: 'www.yahoo.com',\n title: {\n selectors: ['header.canvas-header']\n },\n\n author: {\n selectors: ['span.provider-name']\n },\n\n content: {\n selectors: [\n // enter content selectors\n '.content-canvas'],\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 // 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: ['.figure-caption']\n },\n\n date_published: {\n selectors: [['time.date[datetime]', 'datetime']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"og:description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar BuzzfeedExtractor = {\n domain: 'www.buzzfeed.com',\n title: {\n selectors: ['h1[id=\"post-title\"]']\n },\n\n author: {\n selectors: ['a[data-action=\"user/username\"]', 'byline__author']\n },\n\n content: {\n selectors: ['#buzz_sub_buzz'],\n\n defaultCleaner: false,\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 h2: 'b'\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: ['.instapaper_ignore', '.suplist_list_hide .buzz_superlist_item .buzz_superlist_number_inline', '.share-box']\n },\n\n date_published: {\n selectors: ['.buzz-datetime']\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar WikiaExtractor = {\n domain: 'fandom.wikia.com',\n title: {\n selectors: ['h1.entry-title']\n },\n\n author: {\n selectors: ['.author vcard', '.fn']\n },\n\n content: {\n selectors: ['.grid-content', '.entry-content'],\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 // 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 date_published: {\n selectors: [['meta[name=\"article:published_time\"]', 'value']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"og:description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar LittleThingsExtractor = {\n domain: 'www.littlethings.com',\n title: {\n selectors: ['h1.post-title']\n },\n\n author: {\n selectors: [['meta[name=\"author\"]', 'value']]\n },\n\n content: {\n selectors: [\n // enter content selectors\n '.mainContentIntro', '.content-wrapper'],\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 // 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 lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar PoliticoExtractor = {\n domain: 'www.politico.com',\n title: {\n selectors: [\n // enter title selectors\n ['meta[name=\"og:title\"]', 'value']]\n },\n\n author: {\n selectors: ['.story-main-content .byline .vcard']\n },\n\n content: {\n selectors: [\n // enter content selectors\n '.story-main-content', '.content-group', '.story-core', '.story-text'],\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 // 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: ['figcaption']\n },\n\n date_published: {\n selectors: [['.story-main-content .timestamp time[datetime]', 'datetime']]\n },\n\n lead_image_url: {\n selectors: [\n // enter lead_image_url selectors\n ['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"description\"]', 'value']]\n },\n\n next_page_url: null,\n\n excerpt: null\n};\n\nvar DeadspinExtractor = {\n domain: 'deadspin.com',\n\n supportedDomains: ['jezebel.com', 'lifehacker.com', 'kotaku.com', 'gizmodo.com', 'jalopnik.com', 'kinja.com'],\n\n title: {\n selectors: ['h1.headline']\n },\n\n author: {\n selectors: ['.author']\n },\n\n content: {\n selectors: ['.post-content', '.entry-content'],\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 'iframe.lazyload[data-recommend-id^=\"youtube://\"]': function iframeLazyloadDataRecommendIdYoutube($node) {\n var youtubeId = $node.attr('id').split('youtube-')[1];\n $node.attr('src', 'https://www.youtube.com/embed/' + youtubeId);\n }\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 date_published: {\n selectors: [['time.updated[datetime]', 'datetime']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [\n // enter selectors\n ]\n },\n\n next_page_url: {\n selectors: [\n // enter selectors\n ]\n },\n\n excerpt: {\n selectors: [\n // enter selectors\n ]\n }\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar BroadwayWorldExtractor = {\n domain: 'www.broadwayworld.com',\n title: {\n selectors: ['h1.article-title']\n },\n\n author: {\n selectors: ['span[itemprop=author]']\n },\n\n content: {\n selectors: ['div[itemprop=articlebody]'],\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 // 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 date_published: {\n selectors: [['meta[itemprop=datePublished]', 'value']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=\"og:description\"]', 'value']]\n },\n\n next_page_url: {\n selectors: [\n // enter selectors\n ]\n },\n\n excerpt: {\n selectors: [\n // enter selectors\n ]\n }\n};\n\n// Rename CustomExtractor\n// to fit your publication\n// (e.g., NYTimesExtractor)\nvar ApartmentTherapyExtractor = {\n domain: 'www.apartmenttherapy.com',\n title: {\n selectors: ['h1.headline']\n },\n\n author: {\n selectors: ['.PostByline__name']\n },\n\n content: {\n selectors: ['div.post__content'],\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 'div[data-render-react-id=\"images/LazyPicture\"]': function divDataRenderReactIdImagesLazyPicture($node, $) {\n var data = JSON.parse($node.attr('data-props'));\n var src = data.sources[0].src;\n\n var $img = $('<img />').attr('src', src);\n $node.replaceWith($img);\n }\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 date_published: {\n selectors: [['.PostByline__timestamp[datetime]', 'datetime']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [['meta[name=description]', 'value']]\n },\n\n next_page_url: {\n selectors: [\n // enter selectors\n ]\n },\n\n excerpt: {\n selectors: [\n // enter selectors\n ]\n }\n};\n\nvar MediumExtractor = {\n domain: 'medium.com',\n\n supportedDomains: ['trackchanges.postlight.com'],\n\n title: {\n selectors: ['h1']\n },\n\n author: {\n selectors: [['meta[name=\"author\"]', 'value']]\n },\n\n content: {\n selectors: ['.section-content'],\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 // Re-write lazy-loaded youtube videos\n iframe: function iframe($node) {\n var ytRe = /https:\\/\\/i.embed.ly\\/.+url=https:\\/\\/i\\.ytimg\\.com\\/vi\\/(\\w+)\\//;\n var thumb = decodeURIComponent($node.attr('data-thumbnail'));\n\n if (ytRe.test(thumb)) {\n var _thumb$match = thumb.match(ytRe),\n _thumb$match2 = _slicedToArray(_thumb$match, 2),\n _ = _thumb$match2[0],\n youtubeId = _thumb$match2[1]; // eslint-disable-line\n\n\n $node.attr('src', 'https://www.youtube.com/embed/' + youtubeId);\n var $parent = $node.parents('figure');\n $parent.prepend($node.clone());\n $node.remove();\n }\n }\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 date_published: {\n selectors: [['time[datetime]', 'datetime']]\n },\n\n lead_image_url: {\n selectors: [['meta[name=\"og:image\"]', 'value']]\n },\n\n dek: {\n selectors: [\n // enter selectors\n ]\n },\n\n next_page_url: {\n selectors: [\n // enter selectors\n ]\n },\n\n excerpt: {\n selectors: [\n // enter selectors\n ]\n }\n};\n\n\n\nvar CustomExtractors = Object.freeze({\n\tBloggerExtractor: BloggerExtractor,\n\tNYMagExtractor: NYMagExtractor,\n\tWikipediaExtractor: WikipediaExtractor,\n\tTwitterExtractor: TwitterExtractor,\n\tNYTimesExtractor: NYTimesExtractor,\n\tTheAtlanticExtractor: TheAtlanticExtractor,\n\tNewYorkerExtractor: NewYorkerExtractor,\n\tWiredExtractor: WiredExtractor,\n\tMSNExtractor: MSNExtractor,\n\tYahooExtractor: YahooExtractor,\n\tBuzzfeedExtractor: BuzzfeedExtractor,\n\tWikiaExtractor: WikiaExtractor,\n\tLittleThingsExtractor: LittleThingsExtractor,\n\tPoliticoExtractor: PoliticoExtractor,\n\tDeadspinExtractor: DeadspinExtractor,\n\tBroadwayWorldExtractor: BroadwayWorldExtractor,\n\tApartmentTherapyExtractor: ApartmentTherapyExtractor,\n\tMediumExtractor: MediumExtractor\n});\n\nvar Extractors = _Object$keys(CustomExtractors).reduce(function (acc, key) {\n var extractor = CustomExtractors[key];\n return _extends({}, acc, mergeSupportedDomains(extractor));\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// An ordered list of meta tag names that denote likely article deks.\n// From most distinct to least distinct.\n//\n// NOTE: There are currently no meta tags that seem to provide the right\n// content consistenty enough. Two options were:\n// - og:description\n// - dc.description\n// However, these tags often have SEO-specific junk in them that's not\n// header-worthy like a dek is. Excerpt material at best.\n\n\n// An ordered list of Selectors to find likely article deks. From\n// most explicit to least explicit.\n//\n// Should be more restrictive than not, as a failed dek can be pretty\n// detrimental to the aesthetics of an article.\n\n\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 excerpt = _ref.excerpt;\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 // Check that dek isn't the same as excerpt\n if (excerpt && excerptContent(excerpt, 10) === excerptContent(dek, 10)) 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 _ref$cleanConditional = _ref.cleanConditionally,\n cleanConditionally = _ref$cleanConditional === undefined ? true : _ref$cleanConditional,\n _ref$title = _ref.title,\n title = _ref$title === undefined ? '' : _ref$title,\n _ref$url = _ref.url,\n url = _ref$url === undefined ? '' : _ref$url,\n _ref$defaultCleaner = _ref.defaultCleaner,\n defaultCleaner = _ref$defaultCleaner === undefined ? true : _ref$defaultCleaner;\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$$1(article, $);\n\n // Drop small images and spacer images\n // Only do this is defaultCleaner is set to true;\n // this can sometimes be too aggressive.\n if (defaultCleaner) cleanImages(article, $);\n\n // Mark elements to keep that would normally be removed.\n // E.g., stripJunkTags will remove iframes, so we're going to mark\n // YouTube/Vimeo videos as elements we want to keep.\n markToKeep(article, $, url);\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$$1(article, $);\n\n // Clean headers\n cleanHeaders(article, $, title);\n\n // Make links absolute\n makeLinksAbsolute$$1(article, $, url);\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 // Also optionally running, since it can be overly aggressive.\n if (defaultCleaner) cleanTags$$1(article, $, cleanConditionally);\n\n // Remove empty paragraph nodes\n removeEmpty(article, $);\n\n // Remove unnecessary attributes\n cleanAttributes$$1(article, $);\n\n return article;\n}\n\nfunction cleanTitle$$1(title, _ref) {\n var url = _ref.url,\n $ = _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 _Reflect$ownKeys$redu2 = _slicedToArray(_Reflect$ownKeys$redu, 2),\n maxTerm = _Reflect$ownKeys$redu2[0],\n 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\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 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$$1\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 if (opts.stripUnlikelyCandidates) {\n $ = stripUnlikelyCandidates($);\n }\n\n $ = convertToParagraphs$$1($);\n $ = scoreContent$$1($, opts.weightNodes);\n var $topCandidate = findTopCandidate$$1($);\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 html = _ref.html,\n title = _ref.title,\n url = _ref.url,\n cheerio$$1 = _ref.cheerio;\n\n opts = _extends({}, this.defaultOpts, opts);\n\n $ = $ || cheerio$$1.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 = _getIterator(_Reflect$ownKeys(opts).filter(function (k) {\n return opts[k] === true;\n })), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n\n opts[key] = false;\n $ = cheerio$$1.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 url = _ref.url,\n 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$$1($, STRONG_TITLE_META_TAGS, metaCache);\n if (title) return cleanTitle$$1(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$$1($, STRONG_TITLE_SELECTORS);\n if (title) return cleanTitle$$1(title, { url: url, $: $ });\n\n // Third, check for weaker meta tags that may match.\n title = extractFromMeta$$1($, WEAK_TITLE_META_TAGS, metaCache);\n if (title) return cleanTitle$$1(title, { url: url, $: $ });\n\n // Last, look for weaker selector tags that may match.\n title = extractFromSelectors$$1($, WEAK_TITLE_SELECTORS);\n if (title) return cleanTitle$$1(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 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$$1($, 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$$1($, 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 = _getIterator(BYLINE_SELECTORS_RE), _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 url = _ref.url,\n 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$$1($, 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$$1($, 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\n\n// def extract_dek(self):\n// # First, check to see if we have a matching meta tag that we can make\n// # use of.\n// dek = self.extract_from_meta('dek', constants.DEK_META_TAGS)\n// if not dek:\n// # Second, look through our CSS/XPath selectors. This may return\n// # an HTML fragment.\n// dek = self.extract_from_selectors('dek',\n// constants.DEK_SELECTORS,\n// text_only=False)\n//\n// if dek:\n// # Make sure our dek isn't in the first few thousand characters\n// # of the content, otherwise it's just the start of the article\n// # and not a true dek.\n// content = self.extract_content()\n// content_chunk = normalize_spaces(strip_tags(content[:2000]))\n// dek_chunk = normalize_spaces(dek[:100]) # Already has no tags.\n//\n// # 80% or greater similarity means the dek was very similar to some\n// # of the starting content, so we skip it.\n// if fuzz.partial_ratio(content_chunk, dek_chunk) < 80:\n// return dek\n//\n// return None\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 content = _ref.content,\n metaCache = _ref.metaCache,\n html = _ref.html;\n\n var cleanUrl = void 0;\n if (!$.browser && $('head').length === 0) {\n $('*').first().prepend(html);\n }\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$$1($, 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 $content = $(content);\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 _Reflect$ownKeys$redu2 = _slicedToArray(_Reflect$ownKeys$redu, 2),\n topUrl = _Reflect$ownKeys$redu2[0],\n topScore = _Reflect$ownKeys$redu2[1];\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 = _getIterator(LEAD_IMAGE_URL_SELECTORS), _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\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\n// Match any phrase that looks like it could be page, or paging, or pagination\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 linkHost = _URL$parse.hostname;\n\n // Domain mismatch.\n\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 articleUrl = _ref.articleUrl,\n baseUrl = _ref.baseUrl,\n parsedUrl = _ref.parsedUrl,\n $ = _ref.$,\n _ref$previousUrls = _ref.previousUrls,\n 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 attrs = getAttrs(link);\n var href = removeAnchor(attrs.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/* eslint-disable */\n// Looks for and returns next page url\n// for multi-page articles\nvar GenericNextPageUrlExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$,\n url = _ref.url,\n parsedUrl = _ref.parsedUrl,\n _ref$previousUrls = _ref.previousUrls,\n 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 url = _ref.url,\n 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$$1($, 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 ? arguments[2] : 200;\n\n content = content.replace(/[\\s\\n]+/g, ' ').trim();\n return ellipsize(content, maxLength, { ellipse: '…' });\n}\n\nvar GenericExcerptExtractor = {\n extract: function extract(_ref) {\n var $ = _ref.$,\n content = _ref.content,\n metaCache = _ref.metaCache;\n\n var excerpt = extractFromMeta$$1($, 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 var $content = $('div').first();\n\n var text = normalizeSpaces($content.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 cheerio$$1 = options.cheerio,\n $ = options.$;\n\n\n if (html && !$) {\n var loaded = cheerio$$1.load(html);\n options.$ = loaded;\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 url = _url_and_domain.url,\n domain = _url_and_domain.domain;\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 hostname = _parsedUrl.hostname;\n\n var baseDomain = hostname.split('.').slice(-2).join('.');\n\n return Extractors[hostname] || Extractors[baseDomain] || GenericExtractor;\n}\n\n/* eslint-disable */\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$$1($(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$$1($(node), $, result);\n }\n });\n }\n });\n\n return $content;\n}\n\nfunction findMatchingSelector($, selectors) {\n return selectors.find(function (selector) {\n if (Array.isArray(selector)) {\n var _selector = _slicedToArray(selector, 2),\n s = _selector[0],\n attr = _selector[1];\n\n return $(s).length === 1 && $(s).attr(attr) && $(s).attr(attr).trim() !== '';\n }\n // debugger\n\n return $(selector).length === 1 && $(selector).text().trim() !== '';\n });\n}\n\nfunction select(opts) {\n var $ = opts.$,\n type = opts.type,\n extractionOpts = opts.extractionOpts,\n _opts$extractHtml = opts.extractHtml,\n 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 _extractionOpts$defau = extractionOpts.defaultCleaner,\n defaultCleaner = _extractionOpts$defau === undefined ? true : _extractionOpts$defau;\n\n\n var matchingSelector = findMatchingSelector($, selectors);\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 $content = Cleaners[type]($content, _extends({}, opts, { defaultCleaner: defaultCleaner }));\n\n return $.html($content);\n }\n\n var result = void 0;\n\n // if selector is an array (e.g., ['img', 'src']),\n // extract the attr\n if (Array.isArray(matchingSelector)) {\n var _matchingSelector = _slicedToArray(matchingSelector, 2),\n selector = _matchingSelector[0],\n attr = _matchingSelector[1];\n\n result = $(selector).attr(attr).trim();\n } else {\n result = $(matchingSelector).text().trim();\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 extractor = opts.extractor,\n _opts$fallback = opts.fallback,\n fallback = _opts$fallback === undefined ? true : _opts$fallback;\n\n\n var result = select(_extends({}, opts, { extractionOpts: extractor[type] }));\n\n // If custom parser succeeds, return the result\n if (result) {\n return result;\n }\n\n // If nothing matches the selector, and fallback is enabled,\n // run the Generic extraction\n if (fallback) return GenericExtractor[type](opts);\n\n return null;\n}\n\nvar RootExtractor = {\n extract: function extract() {\n var extractor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GenericExtractor;\n var opts = arguments[1];\n var _opts = opts,\n contentOnly = _opts.contentOnly,\n 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 excerpt = extractResult(_extends({}, opts, { type: 'excerpt', content: content }));\n var dek = extractResult(_extends({}, opts, { type: 'dek', content: content, excerpt: excerpt }));\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 _ref3 = extractResult(_extends({}, opts, { type: 'url_and_domain' })) || { url: null, domain: null },\n url = _ref3.url,\n domain = _ref3.domain;\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 html = _ref2.html,\n $ = _ref2.$,\n metaCache = _ref2.metaCache,\n result = _ref2.result,\n Extractor = _ref2.Extractor,\n title = _ref2.title,\n url = _ref2.url,\n cheerio$$1 = _ref2.cheerio;\n var pages, previousUrls, extractorOpts, nextPageResult, word_count;\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 cheerio: cheerio$$1\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 word_count = GenericExtractor.word_count({ content: '<div>' + result.content + '</div>' });\n return _context.abrupt('return', _extends({}, result, {\n total_pages: pages,\n pages_rendered: pages,\n word_count: word_count\n }));\n\n case 17:\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 _opts$fetchAllPages, fetchAllPages, _opts$fallback, fallback, 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 _opts$fetchAllPages = opts.fetchAllPages, fetchAllPages = _opts$fetchAllPages === undefined ? true : _opts$fetchAllPages, _opts$fallback = opts.fallback, fallback = _opts$fallback === undefined ? true : _opts$fallback;\n parsedUrl = URL.parse(url);\n\n if (validateUrl(parsedUrl)) {\n _context.next = 4;\n break;\n }\n\n return _context.abrupt('return', Errors.badUrl);\n\n case 4:\n Extractor = getExtractor(url, parsedUrl);\n // console.log(`Using extractor for ${Extractor.domain}`);\n\n _context.next = 7;\n return Resource.create(url, html, parsedUrl);\n\n case 7:\n $ = _context.sent;\n\n if (!$.error) {\n _context.next = 10;\n break;\n }\n\n return _context.abrupt('return', $);\n\n case 10:\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, {\n url: url,\n html: html,\n $: $,\n metaCache: metaCache,\n parsedUrl: parsedUrl,\n fallback: fallback,\n cheerio: cheerio\n });\n _result = result, title = _result.title, 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 = 20;\n break;\n }\n\n _context.next = 17;\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 cheerio: cheerio\n });\n\n case 17:\n result = _context.sent;\n _context.next = 21;\n break;\n\n case 20:\n result = _extends({}, result, {\n total_pages: 1,\n rendered_pages: 1\n });\n\n case 21:\n return _context.abrupt('return', result);\n\n case 22:\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, name) {\n return template`\n export const ${name} = {\n domain: '${hostname}',\n\n title: {\n selectors: [\n // enter title selectors\n ],\n },\n\n author: {\n selectors: [\n // enter author selectors\n ],\n },\n\n date_published: {\n selectors: [\n // enter selectors\n ],\n },\n\n dek: {\n selectors: [\n // enter selectors\n ],\n },\n\n lead_image_url: {\n selectors: [\n // enter 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 `;\n}\n","import template from './index';\n\nconst IGNORE = [\n 'url',\n 'domain',\n 'content',\n 'word_count',\n 'next_page_url',\n 'excerpt',\n 'direction',\n 'total_pages',\n 'rendered_pages',\n];\n\nfunction testFor(key, value, dir, file, url) {\n if (IGNORE.find(k => k === key)) return '';\n\n return template`\n it('returns the ${key}', async () => {\n // To pass this test, fill out the ${key} selector\n // in ${dir}/index.js.\n const html =\n fs.readFileSync('${file}');\n const articleUrl =\n '${url}';\n\n const { ${key} } =\n await Mercury.parse(articleUrl, html, { fallback: false });\n\n // Update these values with the expected values from\n // the article.\n assert.equal(${key}, ${value ? `\\`${value}\\`` : \"''\"})\n });\n `;\n}\n\nexport default function (file, url, dir, result, name) {\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 import { excerptContent } from 'utils/text';\n\n describe('${name}', () => {\n it('is selected properly', () => {\n // This test should be passing by default.\n // It sanity checks that the correct parser\n // is being selected for URLs from this domain\n const url =\n '${url}';\n const extractor = getExtractor(url);\n assert.equal(extractor.domain, URL.parse(url).hostname)\n })\n\n ${Reflect.ownKeys(result).map(k => testFor(k, result[k], dir, file, url)).join('\\n\\n')}\n\n it('returns the content', async () => {\n // To pass this test, fill out the content selector\n // in ${dir}/index.js.\n // You may also want to make use of the clean and transform\n // options.\n const html =\n fs.readFileSync('${file}');\n const url =\n '${url}';\n\n const { content } =\n await Mercury.parse(url, html, { fallback: false });\n\n const $ = cheerio.load(content || '');\n\n const first13 = excerptContent($('*').first().text(), 13)\n\n // Update these values with the expected values from\n // the article.\n assert.equal(first13, 'Add the first 13 words of the article here');\n });\n });\n `;\n}\n","/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable no-use-before-define */\n/* eslint-disable no-console */\nimport fs from 'fs';\nimport URL from 'url';\nimport inquirer from 'inquirer';\nimport ora from 'ora';\nimport { exec } from 'child_process';\n\nimport {\n stripJunkTags,\n makeLinksAbsolute,\n} from 'utils/dom';\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];\nlet spinner;\n\nfunction confirm(fn, args, msg, newParser) {\n spinner = ora({ text: msg });\n spinner.start();\n const result = fn(...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 confirmCreateDir(dir, msg) {\n if (!fs.existsSync(dir)) {\n confirm(fs.mkdirSync, [dir], msg);\n }\n}\n\nfunction getDir(url) {\n const { hostname } = URL.parse(url);\n return `./src/extractors/custom/${hostname}`;\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\ninquirer.prompt(questions).then((answers) => {\n scaffoldCustomParser(answers.website);\n});\n\nfunction generateScaffold(url, file, result) {\n const { hostname } = URL.parse(url);\n const extractor = extractorTemplate(hostname, extractorName(hostname));\n const extractorTest =\n extractorTestTemplate(\n file, url, getDir(url), result, extractorName(hostname)\n );\n\n fs.writeFileSync(`${getDir(url)}/index.js`, extractor);\n fs.writeFileSync(`${getDir(url)}/index.test.js`, extractorTest);\n fs.appendFileSync(\n './src/extractors/custom/index.js',\n exportString(url),\n );\n exec(`npm run lint-fix-quiet -- ${getDir(url)}/*.js`);\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 // fix http(s) relative links:\n makeLinksAbsolute($('*').first(), $, url);\n $('[src], [href]').each((index, node) => {\n const $node = $(node);\n const link = $node.attr('src');\n if (link && link.slice(0, 2) === '//') {\n $node.attr('src', `http:${link}`);\n }\n });\n const html = stripJunkTags($('*').first(), $, ['script']).html();\n\n fs.writeFileSync(file, html);\n\n Mercury.parse(url, html).then((result) => {\n if (newParser) {\n confirm(generateScaffold, [url, file, result], 'Generating parser and tests');\n console.log(`Your custom site extractor has been set up. To get started building it, run\n yarn watch:test -- ${hostname}\n -- OR --\n npm run watch:test -- ${hostname}`);\n } else {\n console.log(`\n It looks like you already have a custom parser for this url.\n The page you linked to has been added to ${file}. Copy and paste\n the following code to use that page in your tests:\n const html = fs.readFileSync('${file}');`);\n }\n });\n}\n\nfunction exportString(url) {\n const { hostname } = URL.parse(url);\n return `export * from './${hostname}';`;\n}\n\nfunction extractorName(hostname) {\n const name = hostname\n .split('.')\n .map(w => `${w.charAt(0).toUpperCase()}${w.slice(1)}`)\n .join('');\n return `${name}Extractor`;\n}\n"],"names":["SPACER_RE","RegExp","KEEP_CLASS","KEEP_SELECTORS","STRIP_OUTPUT_TAGS","REMOVE_ATTRS","REMOVE_ATTR_SELECTORS","map","selector","REMOVE_ATTR_LIST","join","WHITELIST_ATTRS","WHITELIST_ATTRS_RE","REMOVE_EMPTY_TAGS","REMOVE_EMPTY_SELECTORS","tag","CLEAN_CONDITIONALLY_TAGS","HEADER_TAGS","HEADER_TAG_LIST","UNLIKELY_CANDIDATES_BLACKLIST","UNLIKELY_CANDIDATES_WHITELIST","DIV_TO_P_BLOCK_TAGS","IS_WP_SELECTOR","BLOCK_LEVEL_TAGS","BLOCK_LEVEL_TAGS_RE","candidatesBlacklist","CANDIDATES_BLACKLIST","candidatesWhitelist","CANDIDATES_WHITELIST","brsToPs","$","collapsing","each","index","element","$element","nextElement","next","get","tagName","toLowerCase","remove","paragraphize","node","br","$node","sibling","nextSibling","p","test","appendTo","replaceWith","convertDivs","div","$div","convertable","children","length","convertSpans","span","$span","parents","convertNodeTo","attrs","getAttrs","attribString","key","html","browser","text","contents","cleanForHeight","$img","height","parseInt","attr","width","removeAttr","removeSpacers","stripJunkTags","article","tags","not","removeClass","removeAllButWhitelist","$article","find","reduce","acc","NON_TOP_CANDIDATE_TAGS","NON_TOP_CANDIDATE_TAGS_RE","HNEWS_CONTENT_SELECTORS","PHOTO_HINTS","PHOTO_HINTS_RE","POSITIVE_SCORE_HINTS","POSITIVE_SCORE_RE","READABILITY_ASSET","NEGATIVE_SCORE_HINTS","NEGATIVE_SCORE_RE","DIGIT_RE","BR_TAGS_RE","BR_TAG_RE","UNLIKELY_RE","PARAGRAPH_SCORE_TAGS","CHILD_CONTENT_TAGS","BAD_TAGS","HTML_OR_BODY_RE","getWeight","classes","id","score","getScore","parseFloat","scoreCommas","match","idkRe","scoreLength","textLength","chunks","lengthBonus","Math","min","max","scoreParagraph","trim","slice","setScore","addScore","amount","getOrInitScore","e","addToParent","parent","weightNodes","scoreNode","addScoreTo","scorePs","$parent","rawScore","NORMALIZE_RE","normalizeSpaces","replace","PAGE_IN_HREF_RE","HAS_ALPHA_RE","IS_ALPHA_RE","IS_DIGIT_RE","isGoodSegment","segment","firstSegmentHasLetters","goodSegment","SENTENCE_END_RE","hasSentenceEnd","mergeSiblings","$candidate","topScore","siblingScoreThreshold","wrappingDiv","$sibling","siblingScore","append","contentBonus","density","linkDensity","newScore","siblingContent","siblingContentLength","first","removeUnlessContent","weight","hasClass","content","pCount","inputCount","contentLength","imgCount","nodeIsList","previousNode","prev","scriptCount","absolutize","rootUrl","$content","_","url","absoluteUrl","URL","resolve","makeLinksAbsolute","forEach","totalTextLength","linkText","linkLength","isGoodNode","maxChildren","withinComment","stripTags","cleanText","toArray","commentParent","nodeClass","class","classAndId","includes","undefined","attribs","attributes","name","value","setAttr","val","setAttribute","setAttrs","removeAttribute","ex","_interopDefault","require$$20","require$$19","require$$18","require$$17","require$$16","require$$15","require$$14","require$$13","require$$12","require$$11","require$$10","require$$9","require$$8","require$$7","require$$6","require$$5","require$$4","require$$3","require$$2","require$$1","require$$0","range","_regeneratorRuntime","mark","arguments","wrap","_context","start","end","stop","_marked","_ref","hostname","badUrl","error","messages","BAD_CONTENT_TYPES","options","reject","request","err","response","body","statusMessage","statusCode","parseNon2xx","headers","contentType","_response$headers","BAD_CONTENT_TYPES_RE","MAX_CONTENT_LENGTH","_asyncToGenerator","parsedUrl","_ref3","parse","encodeURI","_extends","REQUEST_HEADERS","timeout","FETCH_TIMEOUT","encoding","jar","gzip","followAllRedirects","sent","validateResponse","abrupt","t0","Errors","_callee","_x2","_x3","apply","from","to","convertMetaProp","convertNodeTo$$1","brsToPs$$1","_Reflect$ownKeys","img","protocol","_URL$parse","concat","_toConsumableArray","addClass","$hOnes","_defineProperty","$p","NON_TOP_CANDIDATE_TAGS$1","PHOTO_HINTS$1","POSITIVE_SCORE_HINTS$1","NEGATIVE_SCORE_HINTS$1","UNLIKELY_CANDIDATES_BLACKLIST$1","UNLIKELY_CANDIDATES_WHITELIST$1","POSITIVE_SCORE_RE$1","NEGATIVE_SCORE_RE$1","PHOTO_HINTS_RE$1","READABILITY_ASSET$1","getOrInitScore$$1","addScore$$1","scoreNode$$1","addToParent$$1","_$node$get","PARAGRAPH_SCORE_TAGS$1","CHILD_CONTENT_TAGS$1","BAD_TAGS$1","convertSpans$1","HNEWS_CONTENT_SELECTORS$1","_slicedToArray","parentSelector","_ref2","childSelector","regexList","re","matchRe","exec","matches","pageNum","split","parsed","host","path","reverse","rawSegment","_segment$split2","_segment$split","possibleSegment","fileExt","push","cleanedSegments","words","NON_TOP_CANDIDATE_TAGS_RE$1","header","$header","prevAll","title","metaNames","cachedNames","filter","indexOf","_step","type","nodes","values","cleanTags$$1","metaValue","v","_getIterator","foundNames","_iteratorNormalCompletion","_iterator","done","_loop","_typeof","_ret","_didIteratorError","_iteratorError","return","withinComment$$1","selectors","textOnly","IS_LINK","IS_IMAGE","isComment","TAGS_TO_REMOVE","cleanComments","create","preparedResponse","validResponse","result","_this","generateDoc","cheerio","load","normalizeWhitespace","normalizeMetaTags","convertLazyLoadedImages","clean","extractor","domains","domain","supportedDomains","merge","transforms","noscript","author","date_published","h1","$children","_$children","dek","defaultCleaner","prepend","$tweetContainer","tweets","s","src","lead_image_url","next_page_url","excerpt","h2","youtubeId","JSON","data","sources","iframe","decodeURIComponent","ytRe","thumb","_thumb$match2","_thumb$match","clone","BloggerExtractor","NYMagExtractor","WikipediaExtractor","TwitterExtractor","NYTimesExtractor","TheAtlanticExtractor","NewYorkerExtractor","WiredExtractor","MSNExtractor","YahooExtractor","BuzzfeedExtractor","WikiaExtractor","LittleThingsExtractor","PoliticoExtractor","DeadspinExtractor","BroadwayWorldExtractor","ApartmentTherapyExtractor","MediumExtractor","_Object$keys","CustomExtractors","mergeSupportedDomains","months","timestamp1","timestamp2","allMonths","CLEAN_AUTHOR_RE","leadImageUrl","validUrl","isWebUri","excerptContent","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","_ref$cleanConditional","cleanConditionally","_ref$title","_ref$url","_ref$defaultCleaner","rewriteTopLevel$$1","cleanImages","markToKeep","cleanHOnes$$1","cleanHeaders","makeLinksAbsolute$$1","removeEmpty","cleanAttributes$$1","TITLE_SPLITTERS_RE","resolveSplitTitle","splitTitle","titleText","termCounts","_Reflect$ownKeys$redu2","_Reflect$ownKeys$redu","maxTerm","termCount","splitEnds","longestEnd","DOMAIN_ENDINGS_RE","wuzzy","levenshtein","startSlug","nakedDomain","startSlugRatio","endSlug","endSlugRatio","extractBreadcrumbTitle","newTitle","cleanDomainFromTitle","cleanAuthor","clean$1","cleanDek","cleanDatePublished","extractCleanNode","cleanTitle$$1","opts","stripUnlikelyCandidates","convertToParagraphs$$1","scoreContent$$1","findTopCandidate$$1","defaultOpts","extract","cheerio$$1","getContentNode","nodeIsSufficient","cleanAndReturnNode","k","extractBestNode","metaCache","extractFromMeta$$1","STRONG_TITLE_META_TAGS","extractFromSelectors$$1","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","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","_Array$from","makeSig$1","positiveMatch","PAGE_RE","parentData","negativeMatch","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","loaded","_url_and_domain","_parsedUrl","Extractors","baseDomain","GenericExtractor","$matches","Array","isArray","_selector","extractionOpts","_opts$extractHtml","extractHtml","_extractionOpts$defau","findMatchingSelector","matchingSelector","transformElements","cleanBySelectors","Cleaners","_matchingSelector","_opts$fallback","fallback","select","contentOnly","_opts","extractedTitle","extractResult","_content","Extractor","extractorOpts","nextPageResult","pages","RootExtractor","total_pages","pages_rendered","_x","fetchAllPages","_result","_opts$fetchAllPages","validateUrl","getExtractor","rendered_pages","fetchResource","_context2","_callee2","_this2","Mercury","insertValues","strings","part","idx","toString","bodyPattern","trailingWhitespace","template","compiled","indentLevel","line","IGNORE","testFor","dir","file","questions","spinner","confirm","fn","args","msg","newParser","ora","then","savePage","r","succeed","confirmCreateDir","fs","existsSync","mkdirSync","getDir","scaffoldCustomParser","inquirer","prompt","answers","website","generateScaffold","extractorTemplate","extractorName","extractorTest","extractorTestTemplate","writeFileSync","appendFileSync","exportString","filename","Date","getTime","log","w","charAt","toUpperCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA,AAAO,IAAMA,YAAY,IAAIC,MAAJ,CAAW,gCAAX,EAA6C,GAA7C,CAAlB;;;;AAIP,AAAO,IAAMC,aAAa,qBAAnB;;AAEP,AAAO,IAAMC,iBAAiB,CAC5B,wCAD4B,EAE5B,uCAF4B,EAG5B,qCAH4B,EAI5B,oCAJ4B,CAAvB;;;AAQP,AAAO,IAAMC,oBAAoB,CAC/B,OAD+B,EAE/B,QAF+B,EAG/B,UAH+B,EAI/B,MAJ+B,EAK/B,OAL+B,EAM/B,IAN+B,EAO/B,OAP+B,EAQ/B,QAR+B,EAS/B,QAT+B,CAA1B;;;AAaP,AAAO,IAAM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