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

**URL:** https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241
**Category:** Support
**Created:** [November 25, 2020, 3:10am UTC](https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241 "2020-11-25T03:10:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [November 25, 2020, 3:10am UTC](https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241/1 "2020-11-25T03:10:30Z")

</div>

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: [https://forum.comparajogos.com.br/tag/gloomhaven](https://forum.comparajogos.com.br/tag/gloomhaven)

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:  
[https://github.com/discourse/discourse/commit/84e2915e71ed576560f83d21fc055bb7c8bdb007](https://github.com/discourse/discourse/commit/84e2915e71ed576560f83d21fc055bb7c8bdb007)

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.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [November 25, 2020, 4:06am UTC](https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241/2 "2020-11-25T04:06:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [November 25, 2020, 4:15am UTC](https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241/3 "2020-11-25T04:15:05Z")

</div>

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](https://meta.discourse.org/t/excerpts-are-being-poisoned-by-onebox-urls-on-post-rebuild/166372)

**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](https://github.com/paviliondev/discourse-topic-previews/blob/6ece3527294734b85947e74afad8e03387f1d982/serializers/topic_list_item_edits_mixin.rb#L4), 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?

Thanks.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 25, 2020, 9:41pm UTC](https://meta.discourse.org/t/strange-behavior-when-an-excerpt-has-links-due-to-topic-list-preview-plugin/171241/4 "2020-11-25T21:41:17Z")

</div>


