# Trimming elides markdown format

**URL:** https://meta.discourse.org/t/trimming-elides-markdown-format/226131
**Category:** Bug
**Created:** [May 4, 2022, 4:39pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131 "2022-05-04T16:39:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [May 4, 2022, 4:39pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/1 "2022-05-04T16:39:44Z")

</div>

We encounter an issue when email contain hyphens underlining a line, which markdown recognises as a heading. This is trimmed away by the trim algo. We have to always show the trimmed content since many people use our instance by email only.

# Steps to reproduce:

Basically in the Advanced Email test enter:

```plaintext
This is text before

Header
------

This is text after

```

Which in markdown would be rendered as:

> This is text before
> 
> ## Header
> 
> This is text after

The result is that the text before the header is removed and after is elided!

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/b/b/9bbd520fe557fe2252bbcd319c5ae3b4d4811baa.png)

Is there a way to adjust the trimming to not elide lines of hyphens that follows a line with the same number of characters? At least markdown seems to be able to deal with that.

–  
I’m on  
2.9.0.beta4  
([14f61c5784](https://github.com/discourse/discourse/commits/14f61c57847b6d0a861653e2f479947ad9b68962))

---

<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: [May 4, 2022, 4:40pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/2 "2022-05-04T16:40:45Z")

</div>

Have you tried disabling the setting `trim incoming emails` ?

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [May 4, 2022, 4:45pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/3 "2022-05-04T16:45:31Z")

</div>

Yes of course disabling the trimming does not elide the next 🙂  
However, the problem then comes when people reply to a very very long email thread via email and then all that thread is shown the web view. That is not nice. Hence I would like to re-enable the trimming!

---

<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: [May 4, 2022, 5:31pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/4 "2022-05-04T17:31:11Z")

</div>

So you want the trim feature enable but the `-----` signature removal feature? That’s tricky. Can users be told to use [ATX headings](https://spec.commonmark.org/0.30/#atx-headings) instead of [Setext headings](https://spec.commonmark.org/0.30/#setext-headings)?

---

<div class="post-metadata">

### Author: ![ThiefMaster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thiefmaster/32/120065_2.png) [@ThiefMaster](https://meta.discourse.org/u/ThiefMaster)
#### Post date: [May 5, 2022, 9:04am UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/5 "2022-05-05T09:04:15Z")

</div>

As the lead developer of the application that creates the emails @artur talks about: Yes, we could change it (or use `^^^^` instead of `----` in the “underline”), but this is technically not markdown but simply a text/plain email that’s formatted in a “nice” way for humans. And the “underlined” headings do look a bit nicer IMHO than using markdown-style `# something` headings

Anyway, don’t email signatures that are delimited with `--` usually have a blank line right before the `--` line? So maybe that could be taken into account when parsing emails?

---

<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: [May 5, 2022, 1:00pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/6 "2022-05-05T13:00:14Z")

</div>

> [@ThiefMaster](#):
>
> Anyway, don’t email signatures that are delimited with `--` usually have a blank line right before the `--` line? So maybe that could be taken into account when parsing emails?

I think thats handled here

> <https://github.com/discourse/email_reply_trimmer/blob/main/lib/email_reply_trimmer/delimiter_matcher.rb>

If you want to propose a PR we can take a look at it. It’s a tricky area, as regressions are very visible.

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [May 20, 2022, 1:45pm UTC](https://meta.discourse.org/t/trimming-elides-markdown-format/226131/7 "2022-05-20T13:45:10Z")

</div>

I just tested that using a mix of characters i.e. `-=-=-=-=` ~~does not~~ does get trimmed away.

Seems one should just use characters which are not in the delimiter list…
