Skip to content

Instantly share code, notes, and snippets.

@gunn
Created November 8, 2010 11:39
Show Gist options
  • Save gunn/667620 to your computer and use it in GitHub Desktop.
Save gunn/667620 to your computer and use it in GitHub Desktop.
Nokogiri can be used to fix html
require "rubygems"
require 'nokogiri'
doc = Nokogiri::HTML.parse(<<-eohtml)
<html>
<head>
<title>Hello World</title>
<body>
<h1>This is an awesome document</h1>
<p>
I am a paragraph
<a href="http://google.ca">I am a link</a>
<table><tr><td>table content!
</body>
eohtml
valid_html = doc.to_s
puts valid_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment