How to convert Markdown to Shun manuscript format

Notes about writing manuscripts in Markdown are after the conversion tutorials.

I love Markdown. I love it so much that I’ve adapted my whole workflow around it! From writing fiction podcast scripts to drafting blog posts, it’s just pure plain text, and I love it because it’s so portable and universal.

I wanted to write Markdown manuscripts and then convert them to Shun format industry standard documents. In short, I’ve figured out how to do it, but it’s a very involved process. If just opening up Word or otherwise works for you, do that. Seriously, don’t try to adopt this workflow unless you really, really, love writing in Markdown as much as I do.

Because I’m a Windows user, the below is going to be Windows focused.

I write all my stuff in Markdown and then convert it to other formats using Pandoc. This way, my work is very portable, and I don’t have to transfer every single Macro to new computers. Text files are much smaller than document files so they don’t take up space in my cloud drives.

Requirements.

The below, though, will definitely take some time to set up. It requires you knowing Markdown basics, being comfortable with using the command line and downloading things from the internet and installing programs, as well as working with styles and editing styles in Microsoft Word.

JAWS tutorials for Microsoft Office are here and NVDA tutorials for Word are here

For the command line, we’re going to use PowerShell for this because it’s more versatile.

If you’d rather use templates for Word instead, Shun made templates and I made modern versions of his templates for Word

Let’s get started!

Downloading Pandoc.

Download Pandoc for your operating system and install it.

After you install Pandoc, restart your computer. Now, you should be good to go.

Now, we’re going to split this up into two sections. A DIY template that you create, that you can use anywhere, and a preconfigured script someone else made. The DIY method is good for those that don’t want to rely on third party developers.

DIY manuscript conversion.

This method requires a lot of setting up, but it’s going to be worth it in the end. You will only need to set this up once. After you set it up, you can just make copies of your reference document.

This other tutorial has reference files for LibreOffice

First, get acquainted with Pandocs commands with this getting started page. All commands start with -Pandoc, and are usually one line for this tutorial.

The first thing we’re going to need to do is make a template. When exporting into a Word format, Pandoc references templates so it knows how to style your outputs.

It can’t reference any random template, though. It needs to reference a template based on its structure. This is why we need to make our own template.

Navigating to make your reference template.

In order for this to work, we need to make a Pandoc User Data directory folder. after the Pandoc installation.

Once Pandoc is installed,

Open up, Run, by pressing, Windows key plus R.

After the Run dialog opens, put this.

%APPDATA%

Press enter.

Press, Control, Shift, N, to make a new folder inside of this AppData folder. Call it Pandoc

Now, open up Powershell in this user data directory.

To get there with windows explorer, press, Alt D, Delta, then type, Powershell, all one word, and then hit enter.

After opening up powershell above or doing it first then navigate to where your Pandoc user data folder is or any directory where you want to store templates. To navigate to the Pandoc user data folder quickly, you’d do this,

CD $home\appdata\Roaming\pandoc

CD in command line speak means, change directory. If you have an external hard drive, you’d first enter that external hard drive by typing,

CD DRIVELETTER, where DRIVELETTER is the letter of your actual drive.

If you keep everything on your computer, you need to enter the full path after the, CD, command. For example, to get to the desktop, you could use,

CD C:/users\YourUSERNAME\Desktop

Alternatively, you can open up a powershell window at any location from Windows explorer.

To open powershell at any location, navigate to the folder you want to store your templates and manuscripts in. It works best if everything is in one folder, but we’ll worry about that later.

In the address bar, type,

Powershell

And hit enter. No spaces should be between power, and shell.

Now that powershell is open where you want to have it, Let’s make a reference document.

Making a reference document.

To make a reference document, you’d type,

pandoc -o reference.docx --print-default-data-file reference.docx

To make a LibreOffice reference document,

pandoc -o reference.odt --print-default-data-file reference.odt

After your reference document is created, open up your reference document in Word or LibreOffice Writer.

Editing styles in Microsoft Word.

Use this guide to edit the, first paragraph style, and the, body text style, styles so that the  line spacing is double, first line is indented 0.5 inches, and the font is 12 PT, Times New Roman.

The easiest way to edit the styles with a keyboard is to do the following.

After your reference document is open in word,

Press control+alt+shift+s to open the "Styles" toolbar. The styles you need to change are the, body text, and the first paragraph, styles.

if your cursor is on a style in the document, control+alt+shift+s to open the "Styles" toolbar should have you landing on that style in the styles toolbar.

Press the applications key, then hit enter on Modify or tab to the Modify button.

Once the Modify style dialog box is open, tab to the font ComboBox. Change it to Times New Roman. Change the size to size 12.

Tab until you hear, format menu button. Press enter, go down to paragraph, then press enter.

In this new dialog box, tab until you hear, special, ComboBox. Change the ComboBox to, first line.

When the ComboBox has been changed to first line, tab, and enter 0.5.

One more step! Now tab until you hear, line spacing. Change that to double.

Press okay, or apply, but pressing Okay is fine here. Press okay again to save and close out of the first style dialog box.

After editing the styles, save your edited reference document.

Editing styles in LibreOffice Writer.

I am a Word user more than a LibreOffice user but the below should be a decent guide on editing the style in the reference document.

To edit your LibreOffice styles for writer, do the following with the keyboard.

Learn about styles in Writer here. the important style types are the paragraph styles.

After your ODT reference file is created, open the reference file in LibreOffice Writer.

Press, Alt, P, Papa, to open the edit style dialog box.

At the top, you should see tabs. Pressing Control Tab to cycle through these should work but if it doesn’t work for you, shift tab until your screen reader focus lands on the tab row at the top.

Switch to the, indents and spacing, tab.

tab until you hear, First line: 0.00″

Change the numeral to 0.50. It should now say, First line: 0.50″

Tab until you hear, line spacing option pane ComboBox. Change it to double.

Apply the changes, and then save your reference document.

The font style and font size are already where they should be, but if you wanted to edit other styles to match your newly edited style, you can edit all styles by pressing F11.

If editing other styles, I’d change the, first line, style to match the edited paragraph style. If you don’t want to edit other styles, you can save the reference document and close LibreOffice.

After editing styles.

Now you just need to start converting because our modified reference document is in the User Data directory folder.

Now you have all files where you need them, we’re going to convert Markdown to Shun Manuscript format.

With your manuscript all in one text file or Markdown file, use the below command to convert your manuscript.

pandoc -s book.md --output KingettManuscript.docx

If your reference document is not in Pandoc User Data directory folder, then move it to the same folder as your book and use the command below.

pandoc -s ManuscriptName.md --reference-doc= refdoc.docx --output manuscript.docx

If you don’t want to specify a reference document every time, we need to make Pandoc use our modified reference template as the default template.

Changing default reference template for our DIY conversion.

Navigate to your Pandoc User Data directory folder.

In the address bar, type, powershell, and press enter.

next, we make our reference document.

pandoc -o reference.docx --print-default-data-file reference.docx

edit the styles like before, making sure to change the body text style, and the first paragraph style, to 12 PT font, Times New Roman, Double line spacing, with the first line indented 0.5 inches.

After all styles are edited, save and close your reference document.

Now, you won’t need to specify the reference document every time, so your command will look like this,

pandoc -s ManuscriptName.md --output manuscript.docx

Below, I’ll show you how to convert and merge multiple files with our modified reference template.

Merging multiple files with your DIY template.

The easiest way I’ve found of doing this is to put your custom reference document in the User data directory so that Pandoc uses the document every time it converts to Docx.

Navigate to where your Pandoc data directory.

In the address bar, type, powershell, and press enter.

next, we make our reference document.

pandoc -o reference.docx --print-default-data-file reference.docx

edit the styles like before, making sure to change the body text style, and the first paragraph style, to 12 PT font, Times New Roman, Double line spacing, with the first line indented 0.5 inches.

After all styles are edited, save and close your reference document.

Now you can merge multiple files without having to specify a reference document every time.

If you want to split your chapters up into separate files, you need to specify each input file name, in order, so that it will merge all the files into one document.

Let’s say you have a folder called Book. Inside of that folder, you have text files.

Make sure you specify each text file in the command. For example,

pandoc -s -o Book.docx ch1.md ch2.md ch3.md ch4.md ch5.md

Converting multiple files into Markdown.

Just in case you wanted to convert a directory of Docx files to Markdown, use the below command after navigating to the directory containing the files in power shell.

gci -r -i *.docx |foreach{$md=$.directoryname+"\"+$.basename+".md";pandoc -f docx --wrap=none -s $_.name -o $md}

The above will make Markdown versions of your Docx files. It won’t merge all of them though, only make an MD version of your Docx files in the folder.

Now, onto a script that will do all this for you!

Using a script.

This Pandoc script will do all the hard work for you!

First, download the latest script from this page.

To download the script, expand the, code, button, then click download as zip or download Master.

Extract the folder to a folder where you’ll remember it.

Open up powershell and then navigate to this folder, the unzipped script folder.

Alternatively, you can navigate there using Windows Explorer. Navigate to the folder and then type, powershell, in the address bar.

Inside this folder, you can make folders called work, or BookDraft, all one word, or anything you want. The simplest thing to do is just use the test folder to store your manuscripts and short stories.

Inside the test folder, you’ll find a short folder and long folder.

Go into each folder, open up each first MD file in notepad, and edit the YAML data at the top. You’ll only need to do this once. Change all contact information to your own contact information.

After you change your contact information and delete the sample text below the YAML data, save the documents and then close the files after deleting all the sample text below the YAML data.

Now, all you need is the below commands. You can even split your book up into separate documents and merge them all with one command.

All of the below commands will output your output files to your desktop.

To convert single files, you’d use the command below, making sure to tell Pandoc where your manuscript file is.

If you wrote everything in one long file, use the below command, replacing name’s as needed.

.\bin\md2short.ps1 -overwrite -modern -output $env:USERPROFILE/Desktop/Book.docx './test/long/Book.md'

If you created a short story, use the below command, replacing name’s as needed.

.\bin\md2short.ps1 -overwrite -modern -output $env:USERPROFILE/Desktop/ShortStory.docx './test/short/story.md'

With this script, you can merge all files in a folder in order. When saving files to a folder, or renaming files, make sure to save the files with sequential numbers. Like this,

001 intro.

002 Start.

003 END.

The important thing is to have the numbers at the beginning the same length, and make sure they are in sequential order.

After all chapters have name’s in sequential order, use the below code.

.\bin\md2long.ps1 -overwrite -modern -output $env:USERPROFILE/Desktop/Book.docx './test/long/*.md'

Some notes about writing manuscripts in Markdown.

Your chapters are going to be headings, so, if you want to make a new chapter heading, you’d just write, either of the below depending on your preference.

If you want to make all chapters a heading level 1, use one #

If you want chapters to be heading level 2, use two ##

For example, if you wanted all chapters to be level 1 headings, you’d write,

Chapter 1.

If you wanted all chapters to be heading 2, you would write it like this,

chapter 1.

To automatically convert "dumb" quotes into "smart" quotes, as well as turning fake em-dashes — the kind made with two hyphens — into real em-dashes (—), and turning three periods (…) into ellipse, add the below to any of the above commands for outputting books and other documents,

--smart

I hope this helped someone! It can take a lot to set up, but when you do get it set up, you can just write in plain text, and convert it to a beautiful, formatted, document in seconds!

Thanks for reading! Comments are disabled so Send me an email about this post.