Merge branch 'master' of git.pleroma.social:pleroma/elixir-libraries/linkify
This commit is contained in:
commit
97aed818e2
2 changed files with 12 additions and 0 deletions
|
@ -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})
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue