# Better rendering of hide-details-summary in emails

**URL:** https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056
**Category:** Bug
**Tags:** hide-details
**Created:** [June 6, 2017, 8:05pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056 "2017-06-06T20:05:26Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [June 6, 2017, 8:05pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/1 "2017-06-06T20:05:27Z")

</div>

I noticed that the summary part in `[details=Summary]This text will be hidden[/details]` is rendered as ordinary text in emails with nothing hinting at the hidden details.

This is what it looks online:  
 ![](https://global.discourse-cdn.com/meta/original/3X/e/6/e666f3b94fbbf09a8303f8ed6531257a50b1adc5.png)

And this is what it looks like in the email  
 ![](https://global.discourse-cdn.com/meta/original/3X/4/1/413fbf6dccfa6495479fea5a5d036d83aa84664b.png)

I think it would be great to somehow convey to email recipients that what they are seeing is only the summary of a larger chunk of text.

To start with, it would be good if the black triangle that is shown before the summary online would also be included in the email. In addition, it might even be good to add a link after the summary saying “Click here to see details online” which would open the post online with that particular detail segment expanded (if that is possible at all).

---

<div class="post-metadata">

### Author: ![rriemann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rriemann/32/115238_2.png) [@rriemann](https://meta.discourse.org/u/rriemann)
#### Post date: [July 4, 2017, 3:18pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/2 "2017-07-04T15:18:19Z")

</div>

I noticed the same issue. Note that in the plain text mail view, the text is collapsed.

I would suggest to refile this topic to #Contribute > Bug.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [July 28, 2017, 12:14am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/4 "2017-07-28T00:14:22Z")

</div>

> [@rriemann](#):
>
> I noticed the same issue. Note that in the plain text mail view, the text is collapsed.

I tried to reproduce this today on meta, and I don’t see that. In the plaintext view, I get the complete markdown source code:

```plaintext
[details=This is cool]
Or is it?
[/details]

```

And in the HTML view I get just the title part:

```html
<div style="padding-top:5px;"><p>
This is cool</p></div>

```

---

<div class="post-metadata">

### Author: ![rriemann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rriemann/32/115238_2.png) [@rriemann](https://meta.discourse.org/u/rriemann)
#### Post date: [July 28, 2017, 8:36am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/5 "2017-07-28T08:36:13Z")

</div>

Maybe I didn’t express cleary enough what I meant.

Authors of posts containing the _hide details_ feature assume that the reader will understand due to the interface design, that more information is available and can be unfolded. Often, the authors choose therefore to not point out that fact explicitly in the their text.

Unfortunately, a folded _hide details_ element does not look different than a paragraph in a text mail, which may confuse the reader and doesn’t meet the expectations of the post author, that assumes that readers can easily unfold the hidden details.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [July 29, 2017, 2:21am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/6 "2017-07-29T02:21:12Z")

</div>

Well, I’m fully in agreement that the HTML version is sub-optimal. I started looking for the cause of that but haven’t isolated it yet. I got as far as finding in user\_notifications\_helper.rb :

```plaintext
  def format_for_email(post, use_excerpt)
    html = use_excerpt ? post.excerpt : post.cooked
    PrettyText.format_for_email(html, post).html_safe
  end

```

And examined post.excerpt to see details aren’t being squashed there. So it’s probably PrettyText.format\_for\_email, but I haven’t gotten toreading-that-code/testing/proving that.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [July 30, 2017, 3:36am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/7 "2017-07-30T03:36:02Z")

</div>

Turns out it is so simple. That’s exactly what the details plugin is _trying to do_ with details in email: hide all the content.

If you want to put a little triangle before the summary title of a details, it’s this line:

> <https://github.com/discourse/discourse/blob/main/plugins/discourse-details/plugin.rb#L25>

And a replacement like this would do it:

```ruby
          details.replace("&#x25b6; " + summary)

```

(U+25B6 being the triangle used for a closed details line.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [July 30, 2017, 4:50am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/8 "2017-07-30T04:50:57Z")

</div>

Sure, feel free to submit a PR on that!

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [July 30, 2017, 5:03am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/9 "2017-07-30T05:03:34Z")

</div>

I have no doubt it would be accepted, but I’m not sure that’s enough. Even @tophee in the first post considered the triangle the bare minimum.

What happens to the poor mailing-list-mode reader? Content is forever hidden if they prefer the HTML?

I surmise this stuff is filtered from email, because email agents don’t have the smarts to handle these. Is there an alternative presentation that makes sense?

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [July 30, 2017, 8:24am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/10 "2017-07-30T08:24:20Z")

</div>

> [@elijah](#):
>
> I surmise this stuff is filtered from email, because email agents don’t have the smarts to handle these.

What exactly do you mean by “this stuff”? If you mean the triangle, I guess it should be displayed properly if it’s not an image but a character.

> [@elijah](#):
>
> I have no doubt it would be accepted, but I’m not sure that’s enough.

The next better version would be to also add some text after the summary indicating that there is more, like:

40 Minutes: 5 presentations (visit topic for more details)

Yet another improvement would be to make that text a link to the topic.

Given the discourse philosophy, I’d actually say this would be enough for ordinary users. For users with mailinglist mode on, I’d suggest that the full details are included in a smaller font size.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [July 30, 2017, 5:51pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/11 "2017-07-30T17:51:35Z")

</div>

> [@tophee](#):
>
> What exactly do you mean by “this stuff”?

A `div` that gets shown / hidden by clicking on another `div`.

> [@tophee](#):
>
> 40 Minutes: 5 presentations (visit topic for more details)

This I like, but I’m unsure how to tell from the plugin if it is a regular email or a mailing list email.

Which leaves:

> [@tophee](#):
>
> For users with mailinglist mode on, I’d suggest that the full details are included in a smaller font size.

Anyone have other suggestions?

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [April 18, 2018, 2:21am UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/12 "2018-04-18T02:21:29Z")

</div>

Just bumped into this. not a huge deal, I think we’ll just advise people using the `[details]` block about this as a known issue unless someone has a better idea.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 15, 2019, 9:18pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/13 "2019-05-15T21:18:13Z")

</div>

@nbianca can you add to your list to add a link “(click for more details)” next to the summary in emails instead of just removing the content of the `[details]` tag?

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [May 24, 2019, 3:58pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/14 "2019-05-24T15:58:13Z")

</div>

Sure, here it is:

[https://github.com/discourse/discourse/pull/7597](https://github.com/discourse/discourse/pull/7597)

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [June 6, 2019, 12:24pm UTC](https://meta.discourse.org/t/better-rendering-of-hide-details-summary-in-emails/64056/15 "2019-06-06T12:24:35Z")

</div>


