0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Automatically replace mentions, hashtags, urls and emails with links for multiple services (twitter, instagram, facebook, ...)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.7.2
 Project Readme

auto-linker

Automatically replace mentions, hashtags, urls and emails with links for multiple services (twitter, instagram, facebook, ...)

Gem Version

Installation

gem install auto-linker

Quick Start

require 'auto-linker'

# Replaces handles, hashtags, url and emails with clickable links.
# Replace using the Instagram base config
Autolinker.parse(text, Autolinker::Config::INSTAGRAM)

# Replace using the Twitter base config
Autolinker.parse(text, Autolinker::Config::TWITTER)

Example

# Input text
text = '@flehoux This is a sample #autolinker www.lehoux.me'

# Usage
Autolinker.parse(text, Autolinker::Config::INSTAGRAM)

# Outputted result
=> "<a href="https://instagram.com/flehoux" class="linked-url handle" target="_blank">@flehoux</a> This is a sample <a href="https://instagram.com/explore/tags/autolinker" class="linked-url hashtag" target="_blank">#autolinker</a> <a href="http://www.lehoux.me" class="linked-url url" target="_blank">www.lehoux.me</a>"

Custom Configuration

It's possible to overwrite the default_config attributes by passing a hash as the third parameter

Autolinker.parse(text, Autolinker::Config::INSTAGRAM, {
  :handle_class => "instagram-url handle",
  :hashtag_class  => "instagram-url hashtag"
})

Available Attributes

  • :handle_class (String)
  • :hashtag_class (String)
  • :url_class (String)
  • :handle_url_base (String)
  • :hashtag_url_base (String)
  • :target (String)