Skip to content

Commit

Permalink
Ditch attempts at cleaning content
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Dec 9, 2015
1 parent fa8b673 commit 12a46a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/html/proofer/checks/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def run

# tags embedded in scripts are used in templating languages: http://git.io/vOovv
next if @validation_opts[:ignore_script_embeds] && message =~ SCRIPT_EMBEDS_MSG
next if message =~ /htmlParseEntityRef: expecting ';'/

add_issue(message, line)
end
Expand Down
25 changes: 13 additions & 12 deletions lib/html/proofer/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def create_nokogiri(path)
content = path
end

Nokogiri::HTML(clean_content(content))
Nokogiri::HTML(content)
end
module_function :create_nokogiri

Expand All @@ -31,17 +31,18 @@ def swap(href, replacement)
# address a problem with Nokogiri's parsing URL entities
# problem from http://git.io/vBYU1
# solution from http://git.io/vBYUi
def clean_content(string)
matches = string.scan(%r{https?://([^>]+)}i)

matches.flatten.each do |url|
escaped_url = url.gsub(/&(?!amp;)/, '&')
escaped_url = escaped_url.gsub(%r{/}, '/')
string.gsub!(url, escaped_url)
end
string
end
module_function :clean_content
# UPDATE: Not worth my time to figure out why this is happening.
# def clean_content(string)
# matches = string.scan(%r{https?://([^>]+)}i)
#
# matches.flatten.each do |url|
# escaped_url = url.gsub(/&(?!amp;)/, '&')
# escaped_url = escaped_url.gsub(%r{/}, '/')
# string.gsub!(url, escaped_url)
# end
# string
# end
# module_function :clean_content
end
end
end

0 comments on commit 12a46a2

Please sign in to comment.