Nested details are not rendered properly on emails

This issue is related to the discourse-details plugin @zogstrip

Steps to reproduce

  1. You might want to temporarily change the admin setting email time window mins to 1 minute so you don’t have to wait 10 minutes to get the email.

  2. Create a new topic with this content:

    [details="Click here"]
    Blah, blah
    [details="Click here as well"]
    Nested content
    [details="And here too"]
    More nested content
    More blah.

Expected Behavior

The email has the top-level details text and a link with the details.excerpt_details key as content: Click here <a href="...">(click for more details)</a>

Actual Behavior

The email has all the nested details texts and then the link: Click here Click here as well And here too <a href="...">(click for more details)</a>

This is problematic because if there is a top level details with a lot of nested ones, the output might look like this: