Skip to content

Commit

Permalink
Merge pull request #72 from vinc/fix-undefined-variable
Browse files Browse the repository at this point in the history
Fix undefined local variable 'name'
  • Loading branch information
cantino committed Apr 17, 2014
2 parents 2671eba + 90e874e commit 48eefad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/readability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def clean_conditionally(node, candidates, selector)
content_length = el.text.strip.length # Count the text length excluding any surrounding whitespace
link_density = get_link_density(el)

reason = clean_conditionally_reason?(counts, content_length, options, weight, link_density)
reason = clean_conditionally_reason?(name, counts, content_length, options, weight, link_density)
if reason
debug("Conditionally cleaned #{name}##{el[:id]}.#{el[:class]} with weight #{weight} and content score #{content_score} because it has #{reason}.")
el.remove
Expand All @@ -464,7 +464,7 @@ def clean_conditionally(node, candidates, selector)
end
end

def clean_conditionally_reason?(counts, content_length, options, weight, link_density)
def clean_conditionally_reason?(name, counts, content_length, options, weight, link_density)
if counts["img"] > counts["p"]
"too many images"
elsif counts["li"] > counts["p"] && name != "ul" && name != "ol"
Expand Down
9 changes: 9 additions & 0 deletions spec/readability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,13 @@

end
end

describe "clean_conditionally_reason?" do
let (:list_fixture) { "<div><p>test</p>#{'<li></li>' * 102}" }

it "does not raise error" do
@doc = Readability::Document.new(list_fixture)
expect { @doc.content }.to_not raise_error
end
end
end

0 comments on commit 48eefad

Please sign in to comment.