Scrivener markdown exports without blank lines between paragraphs

Markdown uses a blank line as paragraph separators. Some dialects will force a new paragraph if a line ends with a period and two spaces.

Scriverner does not do this. Something exported or compiled as markdown, has each paragraph starting as a new line, with no blank line between. Most applications and forums that accept markdown input will treat this as a single paragraph.

Is there a way to have scrivener export or compile well formed markdown?

***

Error 2

Items that are italic in the text are not surrounded by asterisks in the output.

E.g.
Dateline 2 Feb 1967

should in markdown become

*Dateline 2 Feb 1967*

I haven’t check if it does the right thing for bold and bold italic.

It seems to handle bullets properly.

***

Workaround for blank lines problem:

For each exported or compiled markdown file:
select all text
pbpaste | pbpaste | awk {'printf “%s\n\n”, $0 '} | pbcopy

Then paste into the destination.

an alternate route with less mousing

awk {'printf “%s\n\n”, $0 '} filename.md | pbcopy

This is for mac.

I would have a look at this post, and probably more specifically the numbered checklist following, “If you want to give it a quick try…”, but the rest might be enlightening as well. I say that because it sounds like you are approaching Scrivener as a Markdown generator rather than a tool for writing with Markdown. To be fair it can generate a fair bit, but it does approach things from the fundamental concept of writing with Markdown first, and providing generation where it is convenient, second. Refer to Chapter 21, maybe starting at §21.4, where the core design philosophy is described. The following sections cover intended generation.

The method described in the linked post is a much better way of spacing paragraphs automatically, especially if stuff other than normal paragraphs are styled. For example, you wouldn’t want a code block to be double-spaced within it, or a Markdown table, or the YAML metadata block at the top of the file. Using a Replacement to replace one newline with two, or something even after compiling such as with awk, could very well damage interpretation of areas of the output document.

For each exported or compiled markdown file…

So to reiterate, I would very much consider doing such a step on the original text, so that you’re starting from the right place (well formed already) instead of trying to build systems to accommodate not doing so. The text editor supports regex (although for a simple thing like this you can use Opt-Return to insert newlines and run a simple duplication search and replace).

Lastly, do search the forum, and in particular the Scrivener > Markdown & LaTeX category. You will probably find most questions you might have discussions, such as: Does Scrivener convert italics & other special fonts?

1 Like