htmlclipping 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/htmlclipping.rb CHANGED
@@ -33,16 +33,16 @@
33
33
  require 'iconv'
34
34
 
35
35
  class HtmlClipping
36
- Version = '0.1.3'
36
+ Version = '0.1.4'
37
37
 
38
38
  # html:: The HTML of the referring web page.
39
39
  # referred_uri:: The URI that is being referred to.
40
40
  # excerpt_limit:: The maximum size of the resulting clipping
41
41
  def initialize( html, referred_uri, excerpt_limit )
42
42
  @contents = html
43
- if @contents =~ %r{<meta.*text/html; charset=(.*?)('|")}i
43
+ if @contents =~ %r{<meta[^>]*charset=("|')?(.*?)('|")}i
44
44
  begin
45
- @converter = Iconv.new( 'UTF-8', $1 )
45
+ @converter = Iconv.new( 'utf8', $2 )
46
46
  rescue Errno::EINVAL
47
47
  # skip it
48
48
  end
data/lib/htmlclipping.rb~ CHANGED
@@ -33,15 +33,19 @@
33
33
  require 'iconv'
34
34
 
35
35
  class HtmlClipping
36
- Version = '0.1.2'
36
+ Version = '0.1.3'
37
37
 
38
38
  # html:: The HTML of the referring web page.
39
39
  # referred_uri:: The URI that is being referred to.
40
40
  # excerpt_limit:: The maximum size of the resulting clipping
41
41
  def initialize( html, referred_uri, excerpt_limit )
42
42
  @contents = html
43
- if @contents =~ %r{<meta.*text/html; charset=(.*?)('|")}i
44
- @converter = Iconv.new( 'UTF-8', $1 )
43
+ if @contents =~ %r{<meta[^>]*charset=("|')?(.*?)('|")}i
44
+ begin
45
+ @converter = Iconv.new( 'utf8', $2 )
46
+ rescue Errno::EINVAL
47
+ # skip it
48
+ end
45
49
  end
46
50
  @referred_uri = referred_uri
47
51
  @excerpt_limit = excerpt_limit
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.6
3
3
  specification_version: 1
4
4
  name: htmlclipping
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.3
7
- date: 2005-10-27
6
+ version: 0.1.4
7
+ date: 2005-11-04
8
8
  summary: HtmlClipping generates excerpts from an HTML page that has a link pointing to a particular URI.
9
9
  require_paths:
10
10
  - lib