MMD -> RTF formatting problems

Okay, I’m hooked. I’m working on a fairly large project in Scrivener, and I just tried doing an Export Draft using the MMD -> RTF filter.

The output is legible but is not exactly what I was expecting. It’s obviously going through the MMD filter, because lists and italics and such are formatted correctly in the RTF document. Here’s what’s wrong:

  • I’m getting a line break between paragraphs, and paragraphs are unindented. The Formatting tab is indicating indented paragraphs, and I’m not even sure where I would specify inter-paragraph space. (I don’t want any.)

  • The titles are centered, even though I have “Center” unchecked for Text Titles. (I’m not using any containers or folders, but those are unchecked, too.)

Any idea what’s up? This isn’t a big deal now, but it’s going to become a pain when I get closer to a final draft.


If this helps, I just tried exporting MMD->HTML, and the titles are still centered. Am I just a bad guy if I like left-aligned titles? :slight_smile:

My first export of a screenplay draft lost all the formatting I could see in Scrivener. So on the second export, I went to the export options panel and, under the Formatting button, unchecked the “Override text formatting…” box at the top. That time, the RTF export came out exactly as it looked in Scrivener.

Nope, that made it worse–I want my fonts and formatting to change on export, but I want them to change in the way I asked for.

Do you know much CSS? I ask because everything that you see in XHTML and RTF exports is governed by a simple bit of CSS which is set in a rudimentary fashion by Scrivener, based on your export formatting preferences.

So, you can get in the ballpark just by setting up Scrivener’s export options (in the formatting tab) correctly. Note, this only does rudimentary settings. Font size and so on. If you want to do something more complex, like indent and such, you’ll need to tweak the CSS.

For example, this would remove the space and add a first line indent to all paragraphs not following a title, among other aesthetic changes more suitable for print:

h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p {
	text-indent: 0;
p {
	font-family: "Times New Roman", Times, serif;
	font-size: 10pt;
	line-height: 1.4em;
	margin: 0;
	width: 35em;
	text-indent: 2em;
	text-align: justify;

There are definitely some other things that you would want to do if you intend to print this RTF out, as opposed to just viewing it on screen.

Yes, I do know some CSS, but I didn’t realize it could be used to style for RTF output as well as HTML. Where is the stylesheet that governs the RTF output? And the fact that the MMD -> RTF export doesn’t honor the “don’t center titles” setting feels like a bug, doesn’t it?

I should say that anything exported via MMD is determined by the XHTML you are using - things such as “Center Titles” only affect the non-MMD export. I know this isn’t exactly explicit at the moment, but I do think that this is best as it allows ultimate flexibility with MMD export… Fletcher and Amber are more qualified to answer this question, methinks - though mamster, it is very good to have you on board. :slight_smile:

Yes. The RTF exporter is actually just a “freebie” provided by the OS X text system. There is a command line utility that converts XHTML to RTF. It is thus, extremely limited in what it can do, layout wise. You are constricted by the HTML limits. No page breaks, et cetera. The chain basically looks like this:

Scrivener assembles all of your Draft documents into a single MultiMarkdown file, adding header syntax to emulate the Binder layout (and it does a few other things like modifying the CSS). This is passed to the MMD Perl script which creates an XHTML file. From there, if you specified RTF, it runs another command line to convert to RTF. So anything you see in the HTML is what you’ll get (roughly) in the RTF. LaTeX is all different, since it has its own style guidelines, but it does start with the XHTML file, purely from a structural standpoint.

By the way, the titles are currently centred with the CSS, so that can be fixed, too. I uploaded a little example that will create a reasonably decent looking printout from a web browser. The CSS part of it is compatible with MMD’s output. (1.11 KB)

Amber, I couldn’t get that file to unzip. In any case, I’m happy to edit the CSS myself. If I want to make permanent changes, is there a stylesheet inside the Scrivener bundle that I need to edit?


In all of this I forgot to mention how one goes about overriding Scrivener’s default MMD stylesheet. In the File menu, go to MultiMarkdown Settings. You will see a display that lets you add and edit MMD meta-data fields. You’ll want to add a field called “XHTML Header” (capitalisation is important, I think). In the content area is where you put your stylesheet. There are a few things to be careful of; there are some rules that must be followed.

  1. There can be no empty lines in the stylesheet.
  2. Each selector must be on a line of its own. So use .blah { a; b; c } format.
  3. There can be no tabs in front of the lines.
  4. It appears that quotes get messed up in the current version of MMD, so you might want to avoid them.

So as an example, using the stylesheet from the download:

<style type="text/css" media="screen"> body { font-family: Times New Roman, Times, serif; margin: 1in; } h1 { margin-bottom: 3em; } h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p { text-indent: 0; } p { font-size: 10pt; line-height: 1.4em; margin: 0; width: 35em; text-indent: 2em; text-align: justify; } a.footnote { text-decoration: none; color: black; font-size: 7pt; padding-left: .3em; vertical-align: top; } div.footnotes { font-size: 8pt; margin-top: 3em; width: 35em; } div.footnotes ol { margin-top: .5em; } div.footnotes hr { border: 1px solid #aaa; } </style>

Note, this does not address annotations, but if you wanted to add a style for that, it assigns annotations to the class, .annotation. Colour gets applied on an individual basis, based on the colour you used in Scrivener. So if you do nothing they will still appear as comments.

Once this is all set up, you’ll be able to export straight to RTF and it will look “roughly” like you meant it to. The converter is not perfect, and some things that CSS can do – RTF cannot.

Odd. I just tried it and it does not work using the built-in thing, but Stuff-it manages to extract it. I wonder if the forum is “sanitising” zip uploads and in doing so, slightly messing them up? Oh well, like you say, you’ve got it under control. I mostly just uploaded it for anyone who comes along in the future.

This is great, Amber–exactly what I needed to know. I’m going to play with it right now. Thanks!

Excellent. And by the way, these MMD settings (and thus the stylesheet override) are project specific. So if you find a style you wish to retain, I recommend creating a template with everything set up the way you like it. In the future, you can just use that as a starting point for your projects.

Next question. Exporting to RTF doesn’t seem to maintain styles; e.g., what comes out as an H1 header in HTML is just formatted text when I open the RTF file in Word. Is there any way around this? Perhaps a different XHTML to RTF converter?

There are no such things as styles in RTF, so whenever converting to that format you will lose nearly every bit of structure, no matter what you start with. Depending upon what word processor you use, you might have better luck importing an XHTML export. If you must stick with RTF, I would recommend searching around in the forum for some RTF tricks. Others who are using the standard non-MMD Scrivener interface have come up against the same issues, and there are some ways to get around it – though from what I recall, none that are quick.

That would certainly explain it, Amber.

The project I’m working on is definitely going to have to end up in Word at some point, although I’m not sure exactly when. Once I end up in Word, I want the headers to be styled, for obvious reasons. (I guess there’s probably a way to do this with search and replace, but that scares me.)

Do you know of a word processor that imports XHTML? I thought Word did, but I couldn’t get it to load as anything other than text.

To answer my own question, it looks like Word will import the HTML if I monkey with the header to make it think that Word generated it. This may end up causing more headaches than it’s worth, but it’s worth a shot.