https://github.com/krepflap/ex_autolink
Elixir library for generating html hyperlinks from text
https://github.com/krepflap/ex_autolink
elixir
Last synced: 4 months ago
JSON representation
Elixir library for generating html hyperlinks from text
- Host: GitHub
- URL: https://github.com/krepflap/ex_autolink
- Owner: krepflap
- License: mit
- Created: 2019-06-16T10:49:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T07:15:37.000Z (almost 7 years ago)
- Last Synced: 2025-11-22T11:24:08.902Z (7 months ago)
- Topics: elixir
- Language: Elixir
- Homepage: https://hex.pm/packages/ex_autolink
- Size: 19.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ExAutolink
Basic conversion of http(s) links in text to html hyperlinks.
## Features
* Convert `http://` and `https://` links to html hyperlinks (`` tags)
* You can pass in entire blocks of text containing multiple links
* Pass in any extra custom attributes you want
* Respects punctuation in text so links don't break
Anti-features:
* Doesn't sanitize HTML in your text input. See
[html_sanitize_ex](https://github.com/rrrene/html_sanitize_ex)
if you don't control the input
## Installation
The package can be installed by adding `ex_autolink` to your list of
dependencies in `mix.exs`:
```elixir
def deps do
[
{:ex_autolink, "~> 0.2.0"}
]
end
```
## Usage
```elixir
iex> ExAutolink.link("https://elixir-lang.org")
"https://elixir-lang.org"
iex> ExAutolink.link("Go here: https://elixir-lang.org/.")
"Go here: https://elixir-lang.org/."
iex> ExAutolink.link("https://ja.wikipedia.org/wiki/Elixir_(プログラミング言語)")
"https://ja.wikipedia.org/wiki/Elixir_(プログラミング言語)"
iex> ExAutolink.link("https://elixir-lang.org!", args: %{class: "myclass active", rel: "nofollow noreferrer"})
"https://elixir-lang.org!"
```
## License
MIT.