diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex index 9e4941f..d16ea9f 100644 --- a/lib/auto_linker/parser.ex +++ b/lib/auto_linker/parser.ex @@ -162,9 +162,21 @@ defmodule AutoLinker.Parser do defp do_parse({" text, user_acc}, opts, {buffer, acc, :parsing}, handler), do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> " text, user_acc}, opts, {buffer, acc, :parsing}, handler), + do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> " text, user_acc}, opts, {buffer, acc, :parsing}, handler), + do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> "" <> text, user_acc}, opts, {buffer, acc, :skip}, handler), do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> "", :parsing}, handler) + defp do_parse({"" <> text, user_acc}, opts, {buffer, acc, :skip}, handler), + do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> "", :parsing}, handler) + + defp do_parse({"" <> text, user_acc}, opts, {buffer, acc, :skip}, handler), + do: do_parse({text, user_acc}, opts, {"", acc <> buffer <> "", :parsing}, handler) + defp do_parse({"<" <> text, user_acc}, opts, {"", acc, :parsing}, handler), do: do_parse({text, user_acc}, opts, {"<", acc, {:open, 1}}, handler) diff --git a/test/parser_test.exs b/test/parser_test.exs index 4e23ff0..2bcf788 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -69,6 +69,17 @@ defmodule AutoLinker.ParserTest do assert parse(text) == text end + test "does not link inside `
` and ``" do
+      text = "
google.com
" + assert parse(text) == text + + text = "google.com" + assert parse(text) == text + + text = "
google.com
" + assert parse(text) == text + end + test "links url inside html" do text = "
google.com
"