MCPcopy Create free account
hub / github.com/Tjatse/node-readability / initNode

Function initNode

lib/reader.js:651–696  ·  view source on GitHub ↗

* initialize the node with different bonus. * @param node the node element. * @return {*}

(node)

Source from the content-addressed store, hash-verified

649 * @return {*}
650 */
651function initNode(node){
652 var score = 0;
653 if (!node || node.length == 0) return score;
654
655 switch (node.get(0).name.toLowerCase()) {
656 case 'article':
657 score = 20;
658 break;
659 case 'section':
660 score = 15;
661 break;
662 case 'div':
663 score = 5;
664 break;
665
666 case 'pre':
667 case 'td':
668 case 'blockquote':
669 score = 3;
670 break;
671
672 case 'address':
673 case 'ul':
674 case 'ol':
675 case 'li':
676 case 'dl':
677 case 'dd':
678 case 'dt':
679 case 'form':
680 score = -3;
681 break;
682
683 case 'body':
684 case 'th':
685 case 'h1':
686 case 'h2':
687 case 'h3':
688 case 'h4':
689 case 'h5':
690 case 'h6':
691 score = -5;
692 break;
693 }
694
695 return score + getClassWeight(node);
696}

Callers 1

scoreNodeFunction · 0.85

Calls 1

getClassWeightFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…