Rich text to Markdown frustrations

It would be really helpful if Scrivener could come with a minimal template focused on producing Markdown. If anyone has put one together, I’d appreciate pointers.

I’ve certainly given that some thought, but one of the problems with that idea is that there are perhaps two, maybe three, modes of thought in how one can use Scrivener to produce Markdown text.

The route youj’re taking, in fact, is not one that I would often recommend to anyone using Scrivener as a Markdown writing platform. It’s more the sort of thing I would recommend someone try, who has already written a book using formatting, and wants to see the kind of quality they can get with minimal investment (maybe they aren’t happy with the default ePub for example, and want to see Pandoc’s). It’s a limited way of working, one that requires more work to get it working right, at least in my opinion.

Plus, there’s the whole preferential thing of whether using formatting is the best approach to begin with. I’d never abide having to use formatting to produce Markdown, because to me the whole point of using Markdown is to use Markdown. I might use formatting here and there to avoid excessively labour-intensive aspects of it, like tables, image management, footnote numbering and things like that—but to I choose Markdown because genuinely like writing with it, and the bulk conversion way you are coming at this penalises that way of writing by automatically escaping any punctuation mark that Markdown would use. There are ways around that, but it adds overhead to a degree I wouldn’t tolerate. Having to use a special style for “raw markup” every time I want to bold some text defeats the seamlessness and ease with which Markdown is intended as a writing interface.

So that’s something to think about, and maybe given how you wrote this post, maybe you’re already on that path. It sounds like you’ve turned off the global converter and are now starting to put together what we refer to as a hybrid writing approach, where you can mix Markdown and formatting together as you please. To what extent you mix it is entirely up to you, which is the nice thing about this second (or I would say primary) mode of usage.

In short, Scrivener’s design was always built around the notion that those using it as a Markdown writing platform would be using Markdown, not doing everything the can to avoid it. So looking at the feature set from that perspective will help it make more sense. You’re supposed to be able to copy and paste and .md file into the editor and do nothing further to “convert” or “import” into Scrivener. You could, if you wanted to, but you’re not supposed to have to. And by extension you could write in Scrivener using not a single bit a formatting, just pure Markdown (I often do in the very early phases, so that I can more easily integrate Scrivener with Markdown editors to do the actual first-run drafting).

If you want to dive in a bit further into this topic, this is a good place to start.

By default, the Blank template supports two heading levels. It’s not at all clear how to add more.

Do you mean headings in the text itself? I’ve always let the outline drive that, since you can enable Titles for a Section Layout and Scrivener will work out the heading depth for you based on the indent level. It’s much easier to keep things organised by heading in the binder, in my opinion, then having to scroll around in long documents looking for divisions.

But what you’re looking for is the Format ▸ Paragraph ▸ HTML Header Level submenu, which should be saved into the style as a type of formatting. To be clear though, that only works with the global conversion checkbox. If you’re handling things more by hand, then stick with the Prefix fields in the Styles compile format option pane.

Unfortunately there’s no way I can find to customize how “No Style” text gets exported, so I need to create a “Body” style and apply that to all the regular text and make sure I don’t leave any text with “No Style”.

The main question I would have there is what are you needing from ordinary paragraphs that isn’t addressed by how ordinary paragraphs work in Markdown (nothing special, just text separated by an empty line)? Well, the answer to your question is essentially the same as rich text compiling: enable the switch for the Section Layout that prints text to override formatting, and then apply the style you want to the sample text.

To answer one particular way in which this can be of use, I sometimes use a “Definition List” section layout, where each entry in the binder is a glossary term, and each paragraph is meant to be a definition, and thus should be prefixed with a : . So I have a compile style for Definition Paragraphs, which inserts that prefix, and for this Section Layout, it converts “No Style” text to this style, whilst printing the binder item at the top, producing this effect:

Binder Title
: First paragraph.
: Second paragraph...

As for code blocks (and a few other special formatting handlers), I don’t have anything to add to what @kewms pointed you to. These are not hard-coded, though some of the Compile Formats do indeed have some reasonable mappings between stock styles. All of that will need tuning if you make your own styles or build your own Formats from scratch.

Indeed I do not use the tab-generating code block helper that Scrivener provides, either, as I prefer fence quote style in almost all things. You don’t have to delete the stock Style though, just remove the binding in the MMD/Pandoc Options pane, and then add your fence blocks or whatever to Styles. Plus, that gives you the opportunity to have kinds of code blocks, like Ruby Code, or HTML Code, and then your compile style prints:

```html
<p>Text assigned to this style.</p>
```

On that note in particular, I would generally recommending treating the “Basic MultiMarkdown” and “Basic Pandoc” compile Formats as your “New Format” to duplicate from, instead of the stock + button or duplicating from “Default”. The actual software defaults are not good for Markdown users. The “Basic” format variants have much more setup, some reasonable defaults, and good examples for what you can do with styles.

Anyway, hopefully some of these examples highlight how Scrivener can be used to aid in Markdown generation; to be tuned so that it lets you write with Markdown where you want to, as much as you want, while also augmenting what you write and inserting additional markup, making things more convenient when working at a large scale.

1 Like