Open dionlarson opened 4 years ago
Let me know what y'all think. I can write a test to enforce a markdown solution or add the necessary code.
I would say that the letter in the .md files should be copy/pastable directly to an email and sent as is. That would mean that requiring 2 spaces for a line break is bad. I see the problem as being the markdownify
not wuite doing what we want, so we should fix it there. I'm trying to find a solution now...
Here's a solution with some kinda ugly code, but the output HTML is correct semantically. What's more, this also actually may solve a problem we haven't run into yet, where someone inadvertently uses markdown syntax in the body of their letter, and the markdownify
filter we are using formats it. This mare-metal solution does a bit less magic, and may be more predictable. It would break people using Siteleaf though I think...
Another reason against making the email body have weird rules such as 2 spaces is then those two weird spaces are going to show up everywhere else, such as where we use page.body
at https://github.com/defund12/defund12.org/blob/c59fb01054194d5dde25769d283dc35b63252826/_layouts/email.html#L34.
I think we're getting hung up, thinking that the email body is markdown, but it's not markdown, it's just plain text. We shouldn't be running it through the markdownify
filter to display it as HTML in the first place. We should instead be phrasing the problem as "how do we convert plaintext to a nice format to display on the web?" Additionally, preferably then if someone selects, copies, and pastes the rendered HTML then it should give the same thing as page.body
.
OK I made a PR that fixes it I think. It looks nearly identical and functions as we want.
This PR (#1370) makes two decisions outside the scope of this issue.
The email template is markdown. Remember, emails are being submitted in markdown, and rendered through a markdown processor. It's WYSIWYG in Github. These emails bodies are written in markdown even if people don't use it's features. It's just that defund12.org doesn't have much support for sending HTML (rendered markdown) emails yet.
Emails can be plaintext or HTML. We already are sending HTML emails on Android to support Gmail app (<br>
necessary).
Currently, we convert to HTML when displaying, but send text raw as plaintext. These should be the same, but I'm not sure I agree with a "emails are always plaintext" approach.
Another reason against making the email body have weird rules such as 2 spaces is then those two weird spaces are going to show up everywhere else, such as where we use page.body at
This is not an issue if we process the body
the same at every copy point (mailto:
, copyToClipboard
, webpage).
I can't fully answer this because I'm not certain how much time it saves. I do feel like it adds another variable to maintaining the email templates though and we should remove it to simplify things.
The email template is markdown. Remember, emails are being submitted in markdown, and rendered through a markdown processor.
I see what you're saying, if people wanted to then they could use the MD features when writing their github issues. But people aren't using those features as far as I can tell, they are just writing plaintext. They either don't know about the markdown feature, assume it won't work in an email, or they have prewritten the letter somewhere else and are copy-pasting. If we did want people to use markdown, we could advertise "Hey you can use markdown, check out those formatting buttons at the top!", but I think we still would have another issue:
This is not an issue if we process the
body
the same at every copy point (mailto:
,copyToClipboard
, webpage).
If we use markdown as the email syntax and HTML as the output then we can never have all three methods (mailto:
, C2C
button, select webpage and copy-paste) give the same results: mailto:
links don't work with sending HTML in the body. So you can only get plaintext that way. Also, I don't think we want to give the user HTML when they click the C2C
button, because then if you paste that anywhere (gmail, textedit, google doc) you just get HTML tags, not something nicely formatted. I think we need to give plaintext that way. If you select the HTML and copy paste, then that way you do get something nicely formatted, but then it's inconsistent with the other two methods...
I was thinking we should prioritize compatibility, consistency, and simplicity over nice formatting, and that markdown->HTML is awesome for looking nice but fails the other three criteria, whereas plaintext wins those 3.
Am I missing something here, a way to make markdown->HTML compatible, consistent, and simple? Or are there other criteria I'm not thinking of?
mailto:
HTML/Rich Text supportiOS Mail and Android Gmail (default mail clients on most of these phones) support basic HTML (at least <br>
, <i>
, <b>
I believe). You need <br>
tags to get Gmail on Android to have new lines. Further testing would be required.
~If neither support HTML links currently, then I'm fully in support of enforcing plaintext email bodies.~
Getting rich text support on copy might actually be easier than rich text mailto:
support on mobile!
mailto:
links%0a
but no <br>
%0a
AND <br>
<br>
but no %0a
<ul>
, <br>
but no %0a
I'm pleasantly surprised to find both major mobile OS + default email clients work with <a>
tags! I think this is a huge win for our templates going forward. We may even be able to find some ways to detect presence of compatible desktop clients.
Ok, on a cursory look over of your solutions markdown->HTML looks promising. I'll play around to confirm and then may try to implement something, though I may not get to it for another 24 hours. If someone else wants to hop in and try it please do!
I tried the mailto:
links above on my Android phone and they worked beautifully! But now I'm trying them on Chrome on OSX, opening them in both gmail the Apple Mail app, and I'm getting Testing,<br>1,<br><b>2</b>,<br><i>3</i>,<br><br><a href="https://defund12.org">Link</a><br><br><ul><li>Item 1</li><li>Item 2</li></ul>
. Any ideas on we should do about this? Try to detect the user's OS and give them different links? In which case, what content should I be getting on OSX Chrome?
@bingbongle @skullface @minicreative it might be good to get your opinions in here too.
In which case, what content should I be getting on OSX Chrome?
I think the best option would just be page.body | escape
? Which wouldn't be terrible, but it is not consistent.
Bug report
In rendered markdown email templates (HTML), new lines are handled differently than in email
mailto:
links (plaintext).Most submitted templates have a single new line for each line of the signature.
Single new line
renders
Markdown based solution: enforce one of the styles below
Single new line with two spaces at end of first line (this is "correct")
note: first line below is
Best,
.renders
Double new line
renders
Code based solution
See solution 1 here. Markdown based solution also from this post.