How to convert Markdown to Shun manuscript format
Crossposted from How to convert Markdown to Shun manuscript format
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 centric.
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.
The below, though, will definitely take some time to set up. It requires you being comfortable with using the command line and downloading things from the internet and installing programs.
For the command line, we’re going to use PowerShell for this because it’s more versatile.
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.
The below will convert your manuscript into Docx format. Everyone I know uses Docx so I haven’t figured out templates in LibreOffice yet.
This 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 template, though. It needs to reference a template based on its structure. This is why we need to make our own template.
Making your own Pandoc reference template.
After opening up powershell, navigate to where your Pandoc installation is or any directory where you want to store templates. To navigate to a directory, you’d do something like this,
CD C:/users\YourUSERNAME\downloads
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 refdoc.docx --print-default-data-file reference.docx
To make a LibreOffice reference document,
pandoc -o refdoc.odt --print-default-data-file reference.odt
I don’t know how to edit styles in LibreOffice so the following is going to be for Microsoft Word users.
After your reference document is created, open up your reference document in 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.
After editing the styles, save your edited reference document.
Move, or copy, the edited reference document to the same folder as your manuscript.
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 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 where your Pandoc is installed.
In the address bar, type, powershell, and press enter.
next, we make our reference document.
pandoc -o custom-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 data directory so that Pandoc uses the document every time it converts to Docx.
Navigate to where your Pandoc is installed.
In the address bar, type, powershell, and press enter.
next, we make our reference document.
pandoc -o custom-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, 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.
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,
\# Chapter 1
Or,
\## chapter two.
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!
from Robert Kingett https://sightlessscribbles.micro.blog/
Thanks for reading! Subscribe to updates so you don't miss stuff!