README.md 2.36 KB
Newer Older
1 2
# AutoLinker

Stephen M. Pallen's avatar
Stephen M. Pallen committed
3
[![Build Status](https://travis-ci.org/smpallen99/auto_linker.png?branch=master)](https://travis-ci.org/smpallen99/auto_linker) [![Hex Version][hex-img]][hex] [![License][license-img]][license]
Stephen M. Pallen's avatar
Stephen M. Pallen committed
4

Stephen M. Pallen's avatar
Stephen M. Pallen committed
5 6
[hex-img]: https://img.shields.io/hexpm/v/auto_linker.svg
[hex]: https://hex.pm/packages/auto_linker
Stephen M. Pallen's avatar
Stephen M. Pallen committed
7 8 9
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg
[license]: http://opensource.org/licenses/MIT

Stephen M. Pallen's avatar
Stephen M. Pallen committed
10
AutoLinker is a basic package for turning website names, and phone numbers into links.
Stephen M. Pallen's avatar
Stephen M. Pallen committed
11 12 13 14

Use this package in your web view to convert web references into click-able links.

This is a very early version. Some of the described options are not yet functional.
15 16 17

## Installation

Stephen M. Pallen's avatar
Stephen M. Pallen committed
18
The package can be installed by adding `auto_linker` to your list of dependencies in `mix.exs`:
19 20 21

```elixir
def deps do
Stephen M. Pallen's avatar
Stephen M. Pallen committed
22
  [{:auto_linker, "~> 0.2"}]
23 24 25
end
```

Stephen M. Pallen's avatar
Stephen M. Pallen committed
26 27
## Usage

Stephen M. Pallen's avatar
Stephen M. Pallen committed
28 29
The following examples illustrate some examples on how to use the auto linker.

minibikini's avatar
minibikini committed
30
```iex
Stephen M. Pallen's avatar
Stephen M. Pallen committed
31 32 33 34 35 36 37 38
iex> AutoLinker.link("google.com")
"<a href='http://google.com' class='auto-linker' target='_blank' rel='noopener noreferrer'>google.com</a>"

iex> AutoLinker.link("google.com", new_window: false, rel: false)
"<a href='http://google.com' class='auto-linker'>google.com</a>"

iex> AutoLinker.link("google.com", new_window: false, rel: false, class: false)
"<a href='http://google.com'>google.com</a>"
Stephen M. Pallen's avatar
Stephen M. Pallen committed
39

minibikini's avatar
minibikini committed
40 41
iex> AutoLinker.link("call me at x9999", phone: true)
"call me at <a href=\"#\" class=\"phone-number\" data-phone=\"9999\">x9999</a>"
Stephen M. Pallen's avatar
Stephen M. Pallen committed
42

minibikini's avatar
minibikini committed
43 44
iex> AutoLinker.link("or at home on 555.555.5555", phone: true)
"or at home on <a href=\"#\" class=\"phone-number\" data-phone=\"5555555555\">555.555.5555</a>"
Stephen M. Pallen's avatar
Stephen M. Pallen committed
45

minibikini's avatar
minibikini committed
46 47
iex> AutoLinker.link(", work (555) 555-5555", phone: true)
", work <a href=\"#\" class=\"phone-number\" data-phone=\"5555555555\">(555) 555-5555</a>"
Stephen M. Pallen's avatar
Stephen M. Pallen committed
48

49 50
iex> AutoLinker.link("[Google Search](http://google.com)", markdown: true)
"<a href='http://google.com' class='auto-linker' target='_blank' rel='noopener noreferrer'>Google Search</a>"
minibikini's avatar
minibikini committed
51
```
52

Stephen M. Pallen's avatar
Stephen M. Pallen committed
53
See the [Docs](https://hexdocs.pm/auto_linker/) for more examples
Stephen M. Pallen's avatar
Stephen M. Pallen committed
54

Stephen M. Pallen's avatar
Stephen M. Pallen committed
55 56 57 58 59 60 61 62 63 64
## Configuration

By default, link parsing is enabled and phone parsing is disabled.

```elixir
# enable phone parsing, and disable link parsing
config :auto_linker, opts: [phone: true, url: false]
```


Stephen M. Pallen's avatar
Stephen M. Pallen committed
65 66 67 68 69
## License

`auto_linker` is Copyright (c) 2017 E-MetroTel

The source is released under the MIT License.
70

Stephen M. Pallen's avatar
Stephen M. Pallen committed
71
Check [LICENSE](LICENSE) for more information.