diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex index 149f00d..9e4941f 100644 --- a/lib/auto_linker/parser.ex +++ b/lib/auto_linker/parser.ex @@ -204,19 +204,8 @@ defmodule AutoLinker.Parser do handler ) - defp do_parse( - {<>, user_acc}, - opts, - {buffer, acc, {:open, level}}, - handler - ) - when char in [" ", "\r", "\n"] do - do_parse( - {text, user_acc}, - opts, - {"", acc <> buffer <> char, {:attrs, level}}, - handler - ) + defp do_parse({text, user_acc}, opts, {buffer, acc, {:open, level}}, handler) do + do_parse({text, user_acc}, opts, {"", acc <> buffer, {:attrs, level}}, handler) end # default cases where state is not important diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs index e6706fa..46be2fd 100644 --- a/test/auto_linker_test.exs +++ b/test/auto_linker_test.exs @@ -144,6 +144,22 @@ defmodule AutoLinkerTest do ) == expected end + test "mentions inside html tags" do + text = + "

hello world

\n

<`em>another @user__test and @user__test google.com paragraph

\n" + + expected = + "

hello world

\n

<`em>another @user__test and @user__test google.com paragraph

\n" + + assert AutoLinker.link(text, + mention: true, + mention_prefix: "u/", + class: false, + rel: false, + new_window: false + ) == expected + end + test "metion @user@example.com" do text = "hey @user@example.com" diff --git a/test/parser_test.exs b/test/parser_test.exs index 66bfb97..b977169 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -70,6 +70,19 @@ defmodule AutoLinker.ParserTest do end test "links url inside html" do + text = "
google.com
" + + expected = "
google.com
" + + assert parse(text, class: false, rel: false, new_window: false) == expected + + text = "Check out
google.com
" + + expected = + "Check out
google.com
" + + assert parse(text, class: false, rel: false, new_window: false) == expected + end text = "Check out
google.com
" expected =