diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index a8bcf57..38eca8c 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -128,13 +128,8 @@ defmodule Linkify.Parser do do_parse({text, user_acc}, opts, {"<", acc, {:open, level + 1}}) end - defp do_parse({">" <> text, user_acc}, opts, {buffer, acc, {:attrs, level}}), - do: - do_parse( - {text, user_acc}, - opts, - {"", accumulate(acc, buffer, ">"), {:html, level}} - ) + defp do_parse({">" <> text, user_acc}, opts, {buffer, acc, {:attrs, _level}}), + do: do_parse({text, user_acc}, opts, {"", accumulate(acc, buffer, ">"), :parsing}) defp do_parse({<> <> text, user_acc}, opts, {"", acc, {:attrs, level}}) do do_parse({text, user_acc}, opts, {"", accumulate(acc, <>), {:attrs, level}}) @@ -194,7 +189,11 @@ defmodule Linkify.Parser do do: do_parse({text, user_acc}, opts, {buffer <> <>, acc, state}) def check_and_link(:url, buffer, opts, _user_acc) do - str = strip_parens(buffer) + str = + buffer + |> String.split("<") + |> List.first() + |> strip_parens() if url?(str, opts) do case @match_url |> Regex.run(str, capture: [:url]) |> hd() do diff --git a/test/parser_test.exs b/test/parser_test.exs index 8aa7ed6..718be90 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -155,6 +155,20 @@ defmodule Linkify.ParserTest do assert parse(text, class: false, rel: false) == expected end + test "html links inside html" do + text = ~s(

google.com

) + assert parse(text) == text + + text = ~s(google.com) + assert parse(text) == text + + text = ~s(

google.com

) + assert parse(text) == text + + text = ~s(
  • google.com
  • ) + assert parse(text) == text + end + test "do not link parens" do text = " foo (https://example.com/path/folder/), bar"