Basic use of Markdown as primary writing format in Scrivener

I’ve finally worked out a workflow of writing in Scrivener, compiling to markdown, and then using Pandoc to covert markdown to docx and pdf. I really don’t know what I’d do without Scrivener’s flexibility in all this. Today I was trying to figure out how to ensure that text after an element (in my case it’s usually an equation) would not automatically indent. In LaTeX one can use “\noindent” for this, and Pandoc will pay attention to that when you ask Pandoc to convert from markdown to pdf. But it won’t pay attention to it when you ask it to convert from markdown to docx. So what to do? Well, Pandoc allows one to create a reference docx file for any conversion to docx. So, I created a new style in that reference doc called “Body Text 2” and I imposed a “no indent” rule on that style in the reference doc. Then I made a new section type in Scrivener called “Noindent”, and I placed all the text I wanted not to be indented after an equation into sections of that type. Finally, I used Scrivener’s compile pane to create two new section layouts, one that adds “\noindent” as a prefix to the Noindent section types, and one that adds a prefix and a suffix that Pandoc uses to impose the “Body Text 2” style when converting from Markdown to docx. This way, if I want to use Pandoc to convert markdown to pdf, I tell Scrivener to apply the “\noindent” prefix to the Noindent section types; if I want to use Pandoc to convert markdown to docx, I tell Scrivener to apply the custom style command instead.

Scrivener never ceases to amaze me.

6 Likes