Evernote and Markdown -- Trouble adding New Line for each append

Challenge: when I run my drafts action that appends to an existing evernote the text would get rid of any new lines. I’ve fixed that to a degree by running the following script before the evernote action happens.

// Original script
var lines = draft.content.split(‘\n’);
draft.content = lines.join(’ \n’);

the issue happens when there is more than one new line in the draft. it deletes it.
Also (and the main reason for this post) is that I’d like to have a 2 new lines added for each time the draft is run. So I added this to the script

Blockquote

> + ' \n\n'

// Newest version (adding \n is not working to space out the drafts appended to Evernote)
var lines = draft.content.split(‘\n’);
draft.content = lines.join(’ \n’) + ’ \n\n’;

How can I setup drafts so that I can use markdown for formatting and insert 2 new lines after each append?

Markdown consolidates multiple consecutive new lines.

Have you tried using the standard approach of using two spaces followed by a new line to force consecutive newlines to be interpreted as non-empty lines?

Here’s the relevant reference in the Markdown specification that describes this approach:

https://daringfireball.net/projects/markdown/syntax#p

Sylumer, Thank you for your post.

I did try it in my script originally, but it didn’t work.
I should have put this in my previous post: (with 2 spaces before each \n)

// Newest version (adding \n is not working to space out the drafts appended to Evernote)
var lines = draft.content.split(’\n’);
draft.content = lines.join(’ \n’) + ’ \n \n’;
it strips out the extra lines (even within the content)

When I change it to a period, the spacing is more what I expect (but with extra periods of course)

// Newest version (adding \n is not working to space out the drafts appended to Evernote)
var lines = draft.content.split(’\n’);
draft.content = lines.join(’ \n’) + ’ .\n .\n’;

Also,
If I have a draft that reads:

List of things
first thing
second thing
third thing

A Different List of things
first thing
second thing
third thing

it doesn’t show the space between the two lists.

I had asked the drafts team (I think a year ago) and I think they said I could use text output in the evernote action, but I don’t want to give up bulleted lists or bold formatting.

It used to work, in the past. I’m not sure what has changed… it wasn’t my code.

Has anyone solved this?

I had a quick go at a basic solution. Seems to work for the content you shared above when I tested it.

Under the hood, Evernote stores things in HTML (well, technically “ENML”, but it’s their variant of HTML).

Without your whole action, I’m left to make guesses, but I assume you have a script where you are pre-processing your content, then an Evernote action step that appends to a note, configure to use “Markdown” as the content type?

You probably just need to review your Markdown > HTML output to make sure you get what you want…because HTML does not care about whitespace, you do have to force line feeds or other block level elements.

If you are making a list, I recommend you use Markdown list formatting, which will become a bullet point list in Evernote.

If you put two line feeds in a row in Markdown, you will end up with <p> tags wrapping the block. Evernote treats these as a paragraph block, and separates the paragraphs, but not a full two lines, just because of the way the app style to their text.