Scrivomatic
A writing workflow using Scrivener's style system + Pandoc for output…
Install / Use
/learn @iandol/ScrivomaticREADME
[!TIP] For Scrivener ⇨ Quarto see the forum post here, and download the Scrivener template. Another Scrivener+Quarto template can be found here: ScrivQ. I also developed a Scrivener ⇨ Typst workflow: Typst.scriv.zip and forum post. All these workflows use the same base Scrivener features, style rules + section types to generate custom markup and post-processing run via Scrivener's compiler...
Scrivomatic: Scrivener & Pandoc{omatic}
TL;DR (simple summary)
I outline a process to combine two powerful writing tools: Scrivener and Pandoc. Scrivener excels in organizing written work, while Pandoc effortlessly converts text into numerous formats. Although Scrivener supports MultiMarkDown (MMD), using Pandoc provides additional benefits and is easily installed. I also employ a Pandoc manager, Pandocomatic, for flexible management of Pandoc settings directly within Scrivener's binder.
- Installation: Install the latest
pandocandpandocomaticcommand-line tools. For PDFs you need Typst / LaTeX / Prince or other PDF engine installed. - Setup Pandoc Recipes: Create one or more
pandocomatic"recipes" that define how Pandoc will process your documents. - Scrivener Front Matter: In Scrivener, create a front-matter document with necessary settings and specify the recipes you want to use. Compile via the Scrivener MultiMarkDown option (which also supports Pandoc).
- Automatic Processing: Scrivener's post-processor will automatically trigger
pandocomaticduring post-processing, creating the final desired outputs (e.g., PDF, HTML, DOCX, TXT).
Sample Workflow: To demonstrate the complete workflow, I've created a self-contained Scrivener project. This workflow simultaneously compiles to PDF / HTML / DOCX / TXT from the same Scrivener text (see samples here), illustrating the versatility of the system. Additionally, I provide a Scrivomatic.scrivtemplate for a more comprehensive workflow implementation.
Further Reading: To better understand the outlined workflow, I recommend reading at least sections §21 (Post-Processing) and §24 (Scripting) of the Scrivener user manual.
Table of Contents
- Simple Summary
- General Introduction
- The Writing Workflow in Scrivener
- Compiling in Scrivener via Pandoc
scrivomaticCompile Helper- More Writing Tips
- Troubleshooting
Introduction
Scrivener (macOS / Windows) is a versatile writing tool that handles both the structural organization and constructive process of writing, allowing users to manage text, ideas, figures, and reference materials in one place without worrying about the final presentation. This is achieved through a process called compiling, where users can choose output formats and select contents with great flexibility. Although Scrivener uses rich text internally, it seamlessly integrates with plain text markdown for more structured and flexible documents. Advantages of compiling via markdown include:
- Automatically converts binder headings into semantic heading levels (properly nested Headings 1-6).
- Styles figures and figure captions appropriately.
- Semantically styles block quotes, code blocks (with syntax highlighting), and various inline styles.
- Parses mathematical equations for many output formats.
- Generates multiple outputs (PDF, LaTeX, DOCX, PPTX, ODT, EPub3, HTML, etc.) simultaneously from a single compile and can trigger further tools to automate workflows.
- Allows using Microsoft Word/LibreOffice files for page setup and custom styles without post-processing.
- For academics, Pandoc generates a full bibliography using thousands of available publication styles (CSL files).
- For technical writers, you can add semantic custom block and span structures (e.g., warning or info boxes), indexes and arbitrarily complex modifications using Pandoc filters.
- For LaTeX users, provides flexibility using rich templates and metadata.
- For PDF generation without using LaTeX, Typst and PrinceXML are recommended small and fast PDF generators.
Time savings during collaborative editing: Regular compiling saves time, especially when collaborating with others.
Simplifying Pandoc settings: Due to Pandoc's extensive flexibility, managing its settings can be complex. To simplify this, "template" tools like pandoc --ddefaults or Pandocomatic organize settings into recipes. For each document output, the template specifies all options in Scrivener's front-matter or a separate configuration file. Pandocomatic templates also allow running pre- and post-processors for more complex workflows (e.g., automating the transfer of an HTML file to a web server after Scrivener compiles). To use Pandocomatic templates with Scrivener, specify their name in the front-matter or metadata, and all settings are automated when Pandoc is run.
[!TIP] In Pandoc V2.8+, you can create "sets" of Pandoc options: see some examples here. I still prefer
pandocomatic(described below) as we can use metadata, processor scripts and gain more control, but the defaults system will be great for others who want a simpler setup. Remember: the workflow I use is just one of many ways of using Pandoc and Scrivener together…
Requirements
Apart from Scrivener (V3.x minimum required for this workflow), you should install Pandoc and Pandocomatic. This requires a small amount of typing into the macOS terminal. You can install pandoc directly, but IMO it is better to use Homebrew to install pandoc, as it can help keep everything up to date (pandoc receives regular automatic updates via homebrew). So first, follow the instructions to install Homebrew (info for the security conscious):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
And then install pandoc using the brew command in the terminal (you can also add pandoc-crossref to the brew command if you want to use it):
brew install pandoc
If you already installed pandoc manually, but want to use brew from now on, then you can use brew link --overwrite ... instead of brew install ....
Getting Pandocomatic installed.
You use Ruby's gem command to install pandocomatic. If you are using macOS 10.15 or later and the built-in Ruby, you must put sudo at the start of the commands (i.e. use sudo gem install pandocomatic, if you've used brew or rbenv to install Ruby, then no sudo is required):
gem install paru pandocomatic
macOS Mojave and earlier users: the latest versions of Pandocomatic are not compatible with the ancient version of Ruby in macOS Mojave and earlier (macOS Catalina is OK), and so you need to install a newer version of Ruby first. Read Installing Ruby for more details!
To keep both Pandoc and Pandocomatic up-to-date, you can run the update commands like so every week or so (paru is used by pandocomatic and is by the same author, it gets auto-installed when pandocomatic is installed):
gem update paru pandocomatic; brew update; brew upgrade
Remember if you use the built-in Ruby, you must add sudo to all gem commands...
Configuration
The most important folder for this workflow is the Pandoc data directory: since Pandoc V2.7 it is $HOME/.local/share/pandoc ($HOME is your user directory, for example /Users/johndoe/; previous to V2.7 the folder was found at $HOME/.pandoc). Though not required, it is recommended to organise all your templates, filters an
