From e5c035a0cef8e1f390a31a7b87fde4ae1bc10e44 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 24 Dec 2020 21:18:25 -0600 Subject: [PATCH] Fix mentions in compact html --- lib/linkify/parser.ex | 5 +++++ test/linkify_test.exs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index 325b69c..5d41d88 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -123,6 +123,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}) diff --git a/test/linkify_test.exs b/test/linkify_test.exs index 64489c1..9834d76 100644 --- a/test/linkify_test.exs +++ b/test/linkify_test.exs @@ -369,6 +369,13 @@ defmodule LinkifyTest do "

hello world

\n

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

\n" assert Linkify.link(text, mention: true, mention_prefix: "u/") == expected + + text = "

hi

@user @anotherUser

" + + expected = + "

hi

@user @anotherUser

" + + assert Linkify.link(text, mention: true, mention_prefix: "u/") == expected end test "mention @user@example.com" do