I’m doing more and more writing in Scrivener, including blog posts, and I use Markdown for formatting. Working on a longer post, I had to find a way to integrate tables nicely and still get Markdown output. Luckily, I’ve found a workflow that works.
Scrivener is a very competent, though initially rather confusing, software that enables you to write a longer text in a more organic fashion. By providing a binder of content, you can write your text in small snippets in any order, organize it freely and later glue it together the way you prefer.
This is massively useful for fiction writers who often juggle parallel plot lines and character development. But it’s also great for non-fictional writing and it allows me to focus on the writing, while at the same time have a good overview of the general structure. As a result, it has a deserved following among those who deal with text on a professional basis. Or anyone who’s tired of scrolling a lot to find that specific paragraph.
The post I was working on has a number of tables. I’d originally designed these using Scrivener’s built-in table editor. The table editor is a recent addition and it’s rather immature but workable. But it turns out that Scrivener is unable to convert its own tables into anything but HTML or RTF. I prefer writing in Markdown, which is a simple way to format your document using simple characters like asterisks and brackets. As a result, the text is portable between systems and is considered “plain”, unlike “rich” which is what text with bold, italics and other formatting is called.
At this point I had already written the rest of the document in Markdown. As Scrivener cannot use different exporters for different piece of the text, it meant I had to make my tables in Markdown too. Luckily, this is possible. Scrivener supports MultiMarkdown which is an extension of the original syntax. Tables take a lot of counting pipe characters but they’re doable. And it can be simplified considerably using this workflow.
Here’s how you do it
- Create your tables in a spreadsheet such as Excel or Numbers (or LibreOffice). Once the data is nicely laid out, highlight all the cells you need and copy (Ctrl/Cmd+C) them.
- Head over to this page and paste what you just copied. Your spreadsheet application will have put a tab separated copy of your sheet in the clipboard.
- Select “MultiMarkdown” as “Style” and click “Create Table”.
- Copy the MultiMarkdown-styled table, go back to Scrivener and paste your newly created table into your document.
To preview the table you can use Mou, a Markdown capable editor. I use a combination of Mou and Marked to see the actual HTML/rich text output of my writing. Marked generates a preview of Markdown text and can also detect changes in files and supports Scrivener. Until Scrivener has its own built-in panel for previewing rendered MultiMarkdown, Marked is a nice helper.
Note that the output from the table generator may require some manual editing. I’ve noticed that trailing borders in MultiMarkdown syntax aren’t accepted by all MultiMarkdown to HTML renderers so if your table won’t work and it looks something like this:
| Col1 | Col2 | NumCol | |-----------------------------------|------------|--------| | Value 1 | Value 2 | 123 | | This is a row with only one cell | | | | This row is testing html entities | Te<br />st | 45 | |-----------------------------------|------------|--------|
Then just remove that last line, like so:
| Col1 | Col2 | NumCol | |-----------------------------------|------------|--------| | Value 1 | Value 2 | 123 | | This is a row with only one cell | | | | This row is testing html entities | Te<br />st | 45 |
And you should be seeing this instead:
|Value 1||Value 2||123|
|This is a row with only one cell|
|This row is testing html entities||Te|
Let me know how it works. And if you find ways to improve this workflow even more, please let me know in the comments.