diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex index d16ea9f..89c1c62 100644 --- a/lib/auto_linker/parser.ex +++ b/lib/auto_linker/parser.ex @@ -180,6 +180,10 @@ defmodule AutoLinker.Parser do defp do_parse({"<" <> text, user_acc}, opts, {"", acc, :parsing}, handler), do: do_parse({text, user_acc}, opts, {"<", acc, {:open, 1}}, handler) + defp do_parse({"<" <> text, user_acc}, opts, {"", acc, {:html, level}}, handler) do + do_parse({text, user_acc}, opts, {"<", acc, {:open, level + 1}}, handler) + end + defp do_parse({">" <> text, user_acc}, opts, {buffer, acc, {:attrs, level}}, handler), do: do_parse( diff --git a/test/parser_test.exs b/test/parser_test.exs index 2bcf788..a5f0c29 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -95,6 +95,12 @@ defmodule AutoLinker.ParserTest do assert parse(text, class: false, rel: false, new_window: false) == expected end + test "links url inside nested html" do + text = "

google.com

" + expected = "

google.com

" + assert parse(text, class: false, rel: false, new_window: false) == expected + end + test "excludes html with specified class" do text = "```Check out
google.com
```" assert parse(text, exclude_patterns: ["```"]) == text