项目作者: crystal-community

项目描述 :
:link: Auto link for Crystal
高级语言: Crystal
项目地址: git://github.com/crystal-community/autolink.cr.git
创建时间: 2017-07-28T17:47:29Z
项目社区:https://github.com/crystal-community/autolink.cr

开源协议:MIT License

下载


:link: Autolink Build Status

Autolink.cr is a Crystal shard that automatically turns URLs into links.

Example:

  1. auto_link("Welcome to my profile https://github.com/hugoabonizio")
  2. # => Welcome to my profile <a href="https://github.com/hugoabonizio">https://github.com/hugoabonizio</a>

Installation

Add this to your application’s shard.yml:

  1. dependencies:
  2. autolink:
  3. github: crystal-community/autolink.cr

Usage

  1. require "autolink"
  2. include Autolink
  3. auto_link("My blog: http://www.myblog.com/", html: {"class" => "menu", "target" => "_blank"})
  4. # => My blog: <a href="http://www.myblog.com/" class="menu" target="_blank">http://www.myblog.com/</a>

Without providing any HTML options autolink.cr will just wrap the URL with <a> tag.

  1. Autolink.auto_link("Welcome to my new blog at http://www.myblog.com/")
  2. # => Welcome to my new blog at <a href="http://www.myblog.com/">http://www.myblog.com/</a>

Custom tag attributes

The <a> tag can receive custom attributes.

  1. Autolink.auto_link("My blog: http://www.myblog.com/", html: {"class" => "menu", "target" => "_blank"})
  2. # => My blog: <a href="http://www.myblog.com/" class="menu" target="_blank">http://www.myblog.com/</a>

Contributing

  1. Fork it ( https://github.com/crystal-community/autolink.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am ‘Add some feature’)
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

This project is a port to Crystal of rails_autolink Ruby gem. Thanks to all its contributors.