Linebreaks in posts created via email in from Gmail


(Dave McClure) #1

A few users on our site primarily use email to post. And I’ve noticed recently that the posts often end up with linebreaks in strange places.

I recently replied to a post here by email and saw the same issue.

I looked at the text/plain content of the email source, and sure enough, there are line breaks there, but that isn’t how I typed the message.

Should we be using the html instead? Or is there a setting in Gmail to cause the text/plain content to be formatted without line breaks?

I could turn off the “treat line breaks as line breaks” markdown setting, but I have a feeling that would just move the problem somewhere else…

/cc @techAPJ


(Jeff Atwood) #2

This is basically unfixable because email. I will leave the understanding of why this is, as an exercise for the reader :slight_smile:


(Dave McClure) #3

I have this vague recollection of this not being an issue before… False memory?


(Dave McClure) #4

Adding these links here for my own benefit:

Perhaps the older HTML parsing worked better in certain scenarios?

I need to dig deeper into those topics, but I wonder if having an option to use the HTML payload if it’s available would help in my case…


(Jeff Atwood) #5

No, it just creates different problems that are extremely pernicious in different ways.


(Matt Parker) #6

At Pivotal, we’ve moved from our internal discussion site from Quandora to Discourse. Quandora didn’t have this issue, which is why we feel this pain perhaps more acutely than others.


(Tobias Eigen) #7

There are many topics on this on meta. I came across one today that seems to be related to this decision. We used to see HTML in posts sent by email and now only see markdown. I think it’s better to only see markdown, though the cost sometimes seems high.

Especially non-technical people struggle with understanding markdown and why their emails don’t look right. I’ve gotten used to explaining it and can live with it, but would love to see some sort of compromise found that “just works”.


(Jeff Atwood) #8

No such compromise exists, unfortunately. All tradeoffs.


(Sam Saffron) #9

If you must you could move to traditional markdown linebreaks, there is a site setting for that. This means that

this
text

would look like this:

this text

And if you wanted to add a line break you would have to either add a <br> at the end of your line or a double space

Long term after we do the new markdown library move we could look at a setting for enabling traditional markdown for incoming mail.


(Dave McClure) #10

Since the “cooking” of markdown to HTML is done as a separate process from parsing email, I am assuming it’s lower hanging (sour?) fruit to add a setting to use the HTML instead of the plain text.

We have a relatively controlled environment as a closed instance with everyone using the same email provider (and most likely the same email client, though perhaps there are some people using Gmail as an IMAP or POP3 server with Outlook :scream:).

Would a site setting to switch to using the HTML contet be accepted as a PR (with the understanding there are tradeoffs)?

Or would we be off in plugin-land if we want to try that?


(Sam Saffron) #11

I am open to a site setting, with a big warning next to it. The problem with HTML is that it will look like a trainwreck when you try to edit it in Discourse.


(Dave McClure) #12

Email reply includes inline styles with "incoming email prefer html" site setting on
(Claus Strasburger) #13

Sorry to dig this up, but this issue is pretty annoying for us, as it happens not just with Gmail.
I would rather not use the HTML versions, because there are so many people sending mails with wildly varying settings and weird markup.

Is enabling classic markdown linebreak mode only for mail-posts still an option?
Where would I start in implementing it?


(Dave McClure) #14

Recently, @zogstrip added a feature that converts the HTML to markdown if you have the “prefer HTML” setting on:

Not what you’re asking for, but may be worth trying out.


(Claus Strasburger) #15

I think I mostly got it:
GitHub - cfstras/discourse at markdown-linebreaks-email
Before I do any more tinkering, can I get some thoughts whether this would make for a pull request @sam? Modifications needed (I know I’m missing i18n strings).
SiteSetting, yes/no, if yes, default?


(Jeff Atwood) #16

There’s no way to get this to work without preferring HTML. It is literally impossible.


(Claus Strasburger) #17

I know. Most of my users instinctively write classic linebreak markdown when composing html, so I would prefer a setting “classic_markdown_linebreaks_for_email” (TBD: name) over parsing and cleaning HTML.