A Drafts Action needed

I’m looking for an action that generates an HTML preview of a Drafts document, with Markdown formatting correctly converted. This preview should then be shareable as rich text via, for example, iOS Mail. The resulting draft email must remain editable — and crucially, when a new line is inserted, it should create only a single line, not two.

At present, I’m finding this nearly impossible to achieve — perhaps it is. To reiterate: I want to write a document in Drafts using Markdown formatting, then send that document to an email app such as Mail, retaining proper formatting (bold, italic, bullets, etc.). I should then be able to edit the email, with line breaks behaving as expected — that is, adding a single line, not triggering a new paragraph.

Any help or suggestions from the Drafts Action Directory would be much appreciated.

Any of the preview actions should accomplish this, but the styling applied is based on that choice of action. Whenever style is not applied it will just end up using a default - which cross apps could vary.

What happens if you use one of the Copy as Rich Text actions? I don’t use Mail, but I would expect that it will keep any formatting it can manage - same for any other app that can accept rich text.

Not sure about his to be honest. Usually newline issues are people missing or adding spaces at the end of their Markdown, or not understanding how blank lines I Markdown collapse. This point sounds different, and sounds like it is down to how the receiving app has interpreted the input.

Without a specific example to test that is difficult for me to adrress, but I totally get you are looking for options otherd might have working. Other than direct mails to myself I don’t tend to use Drafts for emailing so I have no real world equivalent to draw on.

Maybe something above will be useful, but if not, could you share what you have tried and what the resulting issue/s was/were? It may be that tweaks or explanations can be shared that get you a step closer.

Start with the “Markdown Mail” section of the mail integration guide. That sound like basically what you want and works out of the box on iOS, and with the help of the Mail Assistant app on Mac (linked with example actions in this article:

Thank you for the suggestions. I’ll take a look. The issue is, I think, the way line spacing is handled after any markdown is converted to HTML for handing on to say Apple Mail and the way it then interprets the <“p”> or, if used <“div”> tags to determine spacing between paragraph blocks. At present, after pressing return to create a single line space, the code is interpreted as a double space. I think.

I’d need specific example text and outcomes to understand what you are saying about lines.

You can use a “Copy as HTML” action (there’s one in the default Markdown action group) to look at what the Markdown conversion does.

Per the spec, Markdown treats two consecutive line breaks as a paragraph, and wraps that block in <p></p> tags. This is pretty standard and looks more or less the same in the editor as in the HTML rendering.

The most common confusion (which @sylumer mentioned above) is about how to get a single line break that won’t wrap in the HTML, which is done by putting two spaces at the end of the line…but that sounds like the opposite of what you are describing.

I’ve now added an Action to the Directory which after some testing I believe gets as close to the result I’m after:

The significant thing is line and paragraph spacing.

According to my research, iOS Mail treats pasted HTML differently from text typed directly into the editor, especially when it comes to line breaks. Specifically:

When you press Return in iOS Mail, it inserts a new <“div”> or <“p”>, depending on context.

When you paste HTML with <“/p”> or <“/div”> tags, iOS Mail interprets that as a “new paragraph block”, meaning any subsequent Return key press inherits those styles and spacing — you can’t get single line spacing back easily.

Apparently, iOS Mail uses a content-editable field that converts pasted HTML into an internal format with invisible divs and brs, and once it detects a paragraph structure (<“p”>, especially), it stays in that mode until reset — and you have no control over it.

Hopefully this helps.

Interesting. To reiterate, you might be better off with the Markdown Mail actions mentioned in the Mail guide linked above – because those never go through the clipboard, they set the HTML directly in Mail and would not be subject to this formatting issue, and allow you to support Markdown formatting (bold, italics, lists, etc.) fully.

Well, that’s quite extraordinary. In all my searching of the Drafts Actions Directory I somehow never saw the various markdown mail options! I’ve been clearly overthinking this — I’ve now tried Markdown Mail and it’s precisely what I’ve been looking for. Importantly it takes my Drafts document, with its markdown formatting, opens a new email, in my default iOS Mail app, interpreting the formatting correctly, and allowing further editing within the newly created email, including the addition of new, single spaced lines.

How I missed this Action is very odd. I thought I was quite savvy with the Directory as I’ve been using Drafts for years (I do find searching for keywords a bit hit and miss sometimes — especially when using more than one keyword; maybe that was it?).

Anyway, we got there. Thanks so much for your help. The plaintext action I created I suppose might still be useful to someone!

2 Likes

Unless I’ve missed something, a drawback of Markdown Mail is that you can only easily use it for new messages, not for replies.