commit: 0d72ff37a4c28c1a80b4b0f198c082cd8990ad73
parent: 4d5182ec1febb9d9963fce5825cb16a8f7e6e17d
Author: Stephen M. Pallen <smpallen99@yahoo.com>
Date: Mon, 22 Jan 2018 20:59:52 -0500
fix regression with phone and markdown
Diffstat:
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex
@@ -62,17 +62,18 @@ defmodule AutoLinker.Parser do
defp do_parse(text, %{phone: false} = opts), do: do_parse(text, Map.delete(opts, :phone))
defp do_parse(text, %{url: false} = opts), do: do_parse(text, Map.delete(opts, :url))
- defp do_parse(text, %{markdown: true} = opts) do
- text
- |> Builder.create_markdown_links(opts)
- |> do_parse(Map.delete(opts, :markdown))
- end
defp do_parse(text, %{phone: _} = opts) do
text
|> do_parse(false, opts, {"", "", :parsing}, &check_and_link_phone/3)
|> do_parse(Map.delete(opts, :phone))
end
+ defp do_parse(text, %{markdown: true} = opts) do
+ text
+ |> Builder.create_markdown_links(opts)
+ |> do_parse(Map.delete(opts, :markdown))
+ end
+
defp do_parse(text, %{url: _} = opts) do
if (exclude = Map.get(opts, :exclude_pattern, false)) && String.starts_with?(text, exclude) do
text
diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs
@@ -23,4 +23,10 @@ defmodule AutoLinkerTest do
"<a href='http://google.com'>google.com</a>"
end
+ test "phone number and markdown link" do
+ assert AutoLinker.link("888 888-8888 [ab](a.com)", phone: true, markdown: true) ==
+ "<a href=\"#\" class=\"phone-number\" data-phone=\"8888888888\">888 888-8888</a>" <>
+ " <a href='a.com' class='auto-linker' target='_blank' rel='noopener noreferrer'>ab</a>"
+ end
+
end