Skip to content

Commit

Permalink
Removing hpricot
Browse files Browse the repository at this point in the history
  • Loading branch information
LightGuard committed Feb 27, 2013
1 parent d9467cb commit ba4eaf5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion awestruct.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ spec = Gem::Specification.new do |s|
s.requirements << "Any markup languages you are using and it's dependencies"
s.requirements << "If LESS is used, or some other fixes within tilt, it is required to use Bundler and the :git ref for the tilt gem"

s.add_dependency 'hpricot', '~> 0.8.6'
s.add_dependency 'nokogiri', '~> 1.5.6'
s.add_dependency 'tilt', '~> 1.3.3'
s.add_dependency 'compass', '~> 0.12.1'
Expand Down
16 changes: 9 additions & 7 deletions lib/awestruct/context_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'hpricot'
require 'nokogiri'

module Awestruct
module ContextHelper
Expand Down Expand Up @@ -38,22 +38,24 @@ def summarize(text, numwords=20, ellipsis='...')
end

def fully_qualify_urls(base_url, text)
doc = Hpricot( text )
doc = Nokogiri::HTML.fragment( text )

doc.search( "//a" ).each do |a|
doc.css( "a" ).each do |a|
a['href'] = fix_url( base_url, a['href'] ) if a['href']
end
doc.search( "//link" ).each do |link|
doc.css( "link" ).each do |link|
link['href'] = fix_url( base_url, link['href'] )
end
doc.search( "//img" ).each do |img|
doc.css( "img" ).each do |img|
img['src'] = fix_url( base_url, img['src'] )
end

# TODO: Double check if this is true with Nokogiri
# Hpricot::Doc#to_s output encoding is not necessarily the same as the encoding of text
if RUBY_VERSION.start_with? '1.8'
doc.to_s
doc.to_xhtml
else
doc.to_s.tap do |d|
doc.to_xhtml.tap do |d|
d.force_encoding(text.encoding) if d.encoding != text.encoding
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/awestruct/handlers/restructuredtext_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'awestruct/handlers/interpolation_handler'
require 'awestruct/handlers/layout_handler'

require 'hpricot'
require 'nokogiri'

module Awestruct
module Handlers
Expand Down Expand Up @@ -54,7 +54,7 @@ def rendered_content(context, with_layouts=true)
"--no-doc-title",
" --initial-header-level=#{hl}" ].join(' '),
content )
content = Hpricot( doc ).at( '/html/body/div[@class="document"]' ).inner_html.strip
content = Nokogiri::HTML.fragment( doc ).at( '/html/body/div[@class="document"]' ).inner_html.strip
content = content.gsub( "\r", '' )
rescue => e
puts e
Expand Down

0 comments on commit ba4eaf5

Please sign in to comment.