Project

linkable

0.0
No commit activity in last 3 years
No release in over 3 years
Parsing libraries been getting outdated as the web evolve. Linkable takes a scalable approach supporting gTLDs, custom schemas and complex query parameters.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
~> 10.0
~> 3.1.0
 Project Readme

Linkable

Parsing libraries been getting outdated as the web evolve. Linkable takes a scalable approach supporting gTLDs, custom schemas and complex query parameters.

Usage

Require the library

require "linkable"

List all urls in a string

text = "Have you heard that github.com/zeeraw/linkable will detect your proprietary://special.snowflake.domain domain."
text.urls
# => [#<URI::Generic URL:github.com/zeeraw/linkable>, #<URI::Generic proprietary://special.snowflake.domain>]

Replace urls with link tags

"Follow me on twitter http://twitter.com/zeeraw".link
# => "Follow me on twitter <a href='http://twitter.com/zeeraw'>http://twitter.com/zeeraw</a>"

Replace urls manually

text = "Follow me on twitter http://twitter.com/zeeraw"
text.replace_urls { |url| "<a href=#{ url }> @#{ url.path[1..-1] }</a>" }
# => "Follow me on twitter <a href='http://twitter.com/zeeraw'>@zeeraw</a>"

Installation

Add this line to your project's Gemfile:

gem "linkable"

And then execute:

$ bundle

Or install it yourself as:

$ gem install linkable