Merge branch 'fix-mentions' into 'master'

Fix mentions in compact html

See merge request pleroma/elixir-libraries/linkify!37
This commit is contained in:
lain 2021-03-02 14:54:32 +00:00
commit 5758b8d50c
2 changed files with 12 additions and 0 deletions

View file

@ -130,6 +130,11 @@ defmodule Linkify.Parser do
defp do_parse({"<" <> text, user_acc}, opts, {"", acc, :parsing}),
do: do_parse({text, user_acc}, opts, {"<", acc, {:open, 1}})
defp do_parse({"<" <> text, user_acc}, opts, {buffer, acc, :parsing}) do
{buffer, user_acc} = link(buffer, opts, user_acc)
do_parse({text, user_acc}, opts, {"", accumulate(acc, buffer, "<"), {:open, 1}})
end
defp do_parse({">" <> text, user_acc}, opts, {buffer, acc, {:attrs, _level}}),
do: do_parse({text, user_acc}, opts, {"", accumulate(acc, buffer, ">"), :parsing})

View file

@ -369,6 +369,13 @@ defmodule LinkifyTest do
"<p><strong>hello world</strong></p>\n<p><`em>another <a href=\"u/user__test\">@user__test</a> and <a href=\"u/user__test\">@user__test</a> <a href=\"http://google.com\">google.com</a> paragraph</em></p>\n"
assert Linkify.link(text, mention: true, mention_prefix: "u/") == expected
text = "<p>hi</p><p>@user @anotherUser</p>"
expected =
"<p>hi</p><p><a href=\"u/user\">@user</a> <a href=\"u/anotherUser\">@anotherUser</a></p>"
assert Linkify.link(text, mention: true, mention_prefix: "u/") == expected
end
test "mention @user@example.com" do