lib/read.js
function getLinkDensity (node, $) {
  const links = node.find('a')
  const textLength = node.text().length
  let linkLength = 0

  links.each(function (index, elem) {
    const href = $(this).attr('href')
    if (!href || (href.length > 0 && href[0] === '#')) {
      return
    }
    linkLength += $(this).text().length
  })

  return linkLength / textLength || 0
}
function getLinkDensity (node, $) {
  const links = node.find('a')
  const textLength = node.text().length
  let linkLength = 0

  links.each(function (index, elem) {
    const href = $(this).attr('href')
    if (!href || (href.length > 0 && href[0] === '#')) {
      return
    }
    linkLength += $(this).text().length
  })

  return linkLength / textLength || 0
}
function getLinkDensity ( node , $ ) { const links = node . find ( 'a' ) const textLength = node . text ( ) . length let linkLength = 0 links . each ( function ( index , elem ) { const href = $ ( this ) . attr ( 'href' ) if ( ! href || ( href . length > 0 && href [ 0 ] === '#' ) ) { return } linkLength += $ ( this ) . text ( ) . length } ) return linkLength / textLength || 0 }
Get Link density of this node.
Total length of link text in this node divided by the total text of the node.
Relative links are not included.
Get Link density of this node . Total length of link text in this node divided by the total text of the node . Relative links are not included .