Commit 94193ca5 authored by minibikini's avatar minibikini 😷

Merge branch 'fix/link-text' into 'master'

Fix link text

See merge request pleroma/auto_linker!6
parents 8e9de09c c77b2c0e
Pipeline #8273 passed with stages
in 58 seconds
...@@ -6,15 +6,15 @@ defmodule AutoLinker.Builder do ...@@ -6,15 +6,15 @@ defmodule AutoLinker.Builder do
@doc """ @doc """
Create a link. Create a link.
""" """
def create_link(url, opts) do def create_link(text, opts) do
url = add_scheme(url) url = add_scheme(text)
[] []
|> build_attrs(url, opts, :rel) |> build_attrs(url, opts, :rel)
|> build_attrs(url, opts, :target) |> build_attrs(url, opts, :target)
|> build_attrs(url, opts, :class) |> build_attrs(url, opts, :class)
|> build_attrs(url, opts, :href) |> build_attrs(url, opts, :href)
|> format_url(url, opts) |> format_url(text, opts)
end end
def create_markdown_links(text, opts) do def create_markdown_links(text, opts) do
...@@ -59,7 +59,7 @@ defmodule AutoLinker.Builder do ...@@ -59,7 +59,7 @@ defmodule AutoLinker.Builder do
|> truncate(Map.get(opts, :truncate, false)) |> truncate(Map.get(opts, :truncate, false))
attrs = format_attrs(attrs) attrs = format_attrs(attrs)
"<a #{attrs}>" <> url <> "</a>" "<a #{attrs}>#{url}</a>"
end end
defp format_attrs(attrs) do defp format_attrs(attrs) do
...@@ -93,9 +93,7 @@ defmodule AutoLinker.Builder do ...@@ -93,9 +93,7 @@ defmodule AutoLinker.Builder do
defp strip_prefix(url, _), do: url defp strip_prefix(url, _), do: url
def create_phone_link([], buffer, _) do def create_phone_link([], buffer, _), do: buffer
buffer
end
def create_phone_link([h | t], buffer, opts) do def create_phone_link([h | t], buffer, opts) do
create_phone_link(t, format_phone_link(h, buffer, opts), opts) create_phone_link(t, format_phone_link(h, buffer, opts), opts)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment