Strange behavior when an excerpt has links due to Topic list preview plugin

I’ve been noticing a strange behavior when an excerpt has links, be it to a #tag, an attachment, anything at all.

It can be seen on the first topic here:

The excerpt field is as follows (links redacted as ...):

Quer ganhar um Gloomhaven <a class=\"hashtag\" href=\"...\">#gloomhaven-jaws-of-the-lion</a> com apenas 10 reais? Entre nesse grupo e participe do sorteio! <a href=\"...\" rel=\"noopener nofollow ugc\">ht&hellip;</a>

The rendered topic-excerpt HTML is:

<a href="/t/sorteio-de-um-gloomhaven-jaws-of-the-lion/2237" class="topic-excerpt"> Quer ganhar um Gloomhaven </a><a class="hashtag" href="...">#gloomhaven-jaws-of-the-lion</a> com apenas 10 reais? Entre nesse grupo e participe do sorteio! <a href="..." rel="noopener nofollow ugc">ht…</a>

Considering <a>'s can’t be nested, this </a> right before the excerpt’s first <a> must be related to this change:

This causes the rest of the excerpt to be styled as part of the parent element (not .topic-excerpt).

In my linked example the list/topic-excerpt template is being used by the Topic List Previews plugin, but the same happens on pinned topics.

1 Like

It’s true that links shouldn’t be nested… but I think this is a specific issue with the Topic List Previews plugin? By default we strip links from excerpts, so they wouldn’t nest.

1 Like

I don’t know, what I noticed is that the excerpt field from the JSON payload doesn’t have links stripped out.

Plus, the Topic List Previews plugin author, @merefield, also had some issues with excerpts with links recently: Excerpts are being poisoned by onebox URL's on Post Rebuild

EDIT: You’re right @awesomerobot, this is a specific issue with the Topic List Previews. I just disabled it on my instance and the issue is gone, it looks like TLP is overriding the default excerpt serializer because now that I’ve disabled it, all links are stripped out from the JSON payload. I guess this is happening here, but I’m not sure.

This is not a Discourse bug, sorry for the confusion. Should I delete the original post, leave it here for posterity, what do you suggest?