Browse Source

refactor(readability): minor code folding

jvoisin 9 months ago
parent
commit
2d24f5d04e
1 changed files with 4 additions and 7 deletions
  1. 4 7
      internal/reader/readability/readability.go

+ 4 - 7
internal/reader/readability/readability.go

@@ -153,8 +153,7 @@ func getArticle(topCandidate *candidate, candidates candidateList) string {
 			} else {
 				if linkDensity == 0 {
 					// It's a small selection, so .Text doesn't impact performances too much.
-					content := s.Text()
-					if containsSentence(content) {
+					if containsSentence(s.Text()) {
 						append = true
 					}
 				}
@@ -300,7 +299,7 @@ func scoreNode(s *goquery.Selection) *candidate {
 		return c
 	}
 
-	switch s.Get(0).DataAtom.String() {
+	switch s.Get(0).Data {
 	case "div":
 		c.score += 5
 	case "pre", "td", "blockquote", "img":
@@ -363,8 +362,7 @@ func transformMisusedDivsIntoParagraphs(document *goquery.Document) {
 		nodes := s.Children().Nodes
 
 		if len(nodes) == 0 {
-			node := s.Get(0)
-			node.Data = "p"
+			s.Nodes[0].Data = "p"
 			return
 		}
 
@@ -375,8 +373,7 @@ func transformMisusedDivsIntoParagraphs(document *goquery.Document) {
 				"table", "ul":
 				return
 			default:
-				currentNode := s.Get(0)
-				currentNode.Data = "p"
+				s.Nodes[0].Data = "p"
 			}
 		}
 	})