diff --git a/src/htmlutil/utils.go b/src/htmlutil/utils.go
index fab1b25..df26445 100644
--- a/src/htmlutil/utils.go
+++ b/src/htmlutil/utils.go
@@ -22,7 +22,7 @@ func InnerHTML(node *html.Node) string {
func Attr(node *html.Node, key string) string {
for _, a := range node.Attr {
- if a.Key == key {
+ if strings.EqualFold(a.Key, key) {
return a.Val
}
}
diff --git a/src/reader/readability.go b/src/reader/readability.go
index 174e65c..a74a031 100644
--- a/src/reader/readability.go
+++ b/src/reader/readability.go
@@ -248,7 +248,7 @@ func scoreNode(s *goquery.Selection) *candidate {
c.score -= 5
}
- c.score += getClassWeight(s)
+ c.score += getClassWeight(s.Get(0))
return c
}
@@ -267,10 +267,10 @@ func getLinkDensity(s *goquery.Selection) float32 {
// Get an elements class/id weight. Uses regular expressions to tell if this
// element looks good or bad.
-func getClassWeight(s *goquery.Selection) float32 {
+func getClassWeight(node *html.Node) float32 {
weight := 0
- class, _ := s.Attr("class")
- id, _ := s.Attr("id")
+ class := htmlutil.Attr(node, "class")
+ id := htmlutil.Attr(node, "id")
if class != "" {
if negativeRegexp.MatchString(class) {