Skip to content

Instantly share code, notes, and snippets.

@chaupt
Created February 26, 2010 06:33
Show Gist options
  • Select an option

  • Save chaupt/315480 to your computer and use it in GitHub Desktop.

Select an option

Save chaupt/315480 to your computer and use it in GitHub Desktop.
# This fails with Nokogiri 1.4.1 (tested so far on Mac OS X 10.6.2 and EngineYard Cloud instances (custom GenToo?)
# The outer div gets stripped.
it "should handle html comments without removing outer divs" do
s = %|<!-- Some Comment -->
<div>
<div></div>
</div>
<!-- Another Comment -->|
fragment = Nokogiri::HTML.fragment(s)
fragment.to_s.should == s
end
# Results in:
#
# should handle html comments without removing outer divs
# expected: "<!-- Some Comment -->\n<div>\n<div></div>\n</div>\n<!-- Another Comment -->",
# got: "<!-- Some Comment -->\n<div></div>\n\n<!-- Another Comment -->" (using ==)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment