Sha256: 6f748c27882f9193cc9f0275b696191e08e5f79ccc08685a40d97514f5134843

Contents?: true

Size: 461 Bytes

Versions: 3

Compression:

Stored size: 461 Bytes

Contents

require 'wparser/parse'

module Inlines
  class Http < Parse
    # (?<![.,?\!]) 1.8.7では後読みが出来ない、どーするか。
    def self.parse text
      url_rex = %r! 
        \b
        (
          http:// [-a-z0-9]+(\.[-a-z0-9]+)*\.(com|edu|info|net) \b 
          (
            / [-a-z0-9_:\@&?=+,.\!/~*'%\$]*[^.,?\!]
          )?
        )
      !x

    @result = text.gsub(url_rex){|s| "<a href=\"#$1\">#$1</a>"}
    super
    end 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wparser-0.1.2 lib/wparser/inline/http.rb
wparser-0.1.1 lib/wparser/inline/http.rb
wparser-0.1.0 lib/wparser/inline/http.rb