Skip to content

Commit 2d24f5d

Browse files
jvoisinfguillot
authored andcommitted
refactor(readability): minor code folding
1 parent 20825a9 commit 2d24f5d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

internal/reader/readability/readability.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ func getArticle(topCandidate *candidate, candidates candidateList) string {
153153
} else {
154154
if linkDensity == 0 {
155155
// It's a small selection, so .Text doesn't impact performances too much.
156-
content := s.Text()
157-
if containsSentence(content) {
156+
if containsSentence(s.Text()) {
158157
append = true
159158
}
160159
}
@@ -300,7 +299,7 @@ func scoreNode(s *goquery.Selection) *candidate {
300299
return c
301300
}
302301

303-
switch s.Get(0).DataAtom.String() {
302+
switch s.Get(0).Data {
304303
case "div":
305304
c.score += 5
306305
case "pre", "td", "blockquote", "img":
@@ -363,8 +362,7 @@ func transformMisusedDivsIntoParagraphs(document *goquery.Document) {
363362
nodes := s.Children().Nodes
364363

365364
if len(nodes) == 0 {
366-
node := s.Get(0)
367-
node.Data = "p"
365+
s.Nodes[0].Data = "p"
368366
return
369367
}
370368

@@ -375,8 +373,7 @@ func transformMisusedDivsIntoParagraphs(document *goquery.Document) {
375373
"table", "ul":
376374
return
377375
default:
378-
currentNode := s.Get(0)
379-
currentNode.Data = "p"
376+
s.Nodes[0].Data = "p"
380377
}
381378
}
382379
})

0 commit comments

Comments
 (0)