lib/read.js
function getClassWeight (node) {
  if (node === null || node.length === 0) {
    return 0
  }
  const name = node.get(0).name || ''
  const cls = node.attr('class') || ''
  const nid = node.attr('id') || ''
  let weight = 0

  // Schema.org/Article
  if (node.attr('itemprop') && /articleBody/.test(node.attr('itemprop'))) {
    weight += 50
  }
  // Nodes of type text
  if (node.attr('type') && node.attr('type') === 'text') {
    weight += 30
  }
  // Special cases
  if (name === 'article') {
    weight += 25
  }
  if (name === 'section') {
    weight += 10
  }
  if (name === 'header' || name === 'aside' || name === 'footer') {
    weight -= 25
  }
  if (cls === 'comments' && nid === 'comments') {
    weight -= 25
  }

  if (cls.search(regexps.negativeRe) !== -1) {
    weight -= 25
  }
  if (nid.search(regexps.negativeRe) !== -1) {
    weight -= 20
  }
  if (cls.search(regexps.positiveRe) !== -1) {
    weight += 25
  }
  if (nid.search(regexps.positiveRe) !== -1) {
    weight += 20
  }

  return weight
}
function getClassWeight (node) {
  if (node === null || node.length === 0) {
    return 0
  }
  const name = node.get(0).name || ''
  const cls = node.attr('class') || ''
  const nid = node.attr('id') || ''
  let weight = 0

  // Schema.org/Article
  if (node.attr('itemprop') && /articleBody/.test(node.attr('itemprop'))) {
    weight += 50
  }
  // Nodes of type text
  if (node.attr('type') && node.attr('type') === 'text') {
    weight += 30
  }
  // Special cases
  if (name === 'article') {
    weight += 25
  }
  if (name === 'section') {
    weight += 10
  }
  if (name === 'header' || name === 'aside' || name === 'footer') {
    weight -= 25
  }
  if (cls === 'comments' && nid === 'comments') {
    weight -= 25
  }

  if (cls.search(regexps.negativeRe) !== -1) {
    weight -= 25
  }
  if (nid.search(regexps.negativeRe) !== -1) {
    weight -= 20
  }
  if (cls.search(regexps.positiveRe) !== -1) {
    weight += 25
  }
  if (nid.search(regexps.positiveRe) !== -1) {
    weight += 20
  }

  return weight
}
function getClassWeight ( node ) { if ( node === null || node . length === 0 ) { return 0 } const name = node . get ( 0 ) . name || '' const cls = node . attr ( 'class' ) || '' const nid = node . attr ( 'id' ) || '' let weight = 0 // Schema.org/Article if ( node . attr ( 'itemprop' ) && / articleBody / . test ( node . attr ( 'itemprop' ) ) ) { weight += 50 } // Nodes of type text if ( node . attr ( 'type' ) && node . attr ( 'type' ) === 'text' ) { weight += 30 } // Special cases if ( name === 'article' ) { weight += 25 } if ( name === 'section' ) { weight += 10 } if ( name === 'header' || name === 'aside' || name === 'footer' ) { weight -= 25 } if ( cls === 'comments' && nid === 'comments' ) { weight -= 25 } if ( cls . search ( regexps . negativeRe ) !== - 1 ) { weight -= 25 } if ( nid . search ( regexps . negativeRe ) !== - 1 ) { weight -= 20 } if ( cls . search ( regexps . positiveRe ) !== - 1 ) { weight += 25 } if ( nid . search ( regexps . positiveRe ) !== - 1 ) { weight += 20 } return weight }
Node Weight is calculated based on className and ID of the node.
Node Weight is calculated based on className and ID of the node .