RESOLVED - Compiling and Transformation Issues with Paragraph Spacing

Alright, here’s the thing. When I write, my preferred style is to use indented paragraphs with single carriage-return spacing between them.

However, the group that I’m working with absolutely insists on sharing through a private wiki (MediaWiki).

Now, I do have Pandoc (which can convert Markdown to MediaWiki Markup), and I am using Scrivener 3, so there should be no real issue…

…Except that I cannot get the compiler to convert my indented, single-return paragraphs into plain-text, not-indented, double-return paragraphs.

I can do a brute-force method by manually putting in a Replacement to the tune of ¶ → ¶¶, but this tends to put in a lot of extra carriage returns in places I don’t want them to be, and then I have to go into the resulting document to remove the extras before converting it to MediaWiki Markup with Pandoc.

Any help would be greatly appreciated.

Okay, now I feel kinda like Po the Kung Fu Panda when told Shifu would not have taught him the Wuxi Finger Hold, and he goes, “Nope…I figured it out!”

That said, I’ll share what I learned here in case someone else has a similar problem.

As mentioned before, I need to use MediaWiki’s Markup code. And while some of my fellow collaborators have been using MediaWiki for years and can practically use that Markup code in their sleep, I’m nowhere nearly as proficient. It can take me hours to go through a story submission and get everything properly coded.

Unfortunately, Scrivener doesn’t have an output option for that, but it does have an output option for Basic Pandoc, and Pandoc can convert that into MediWiki Markup. Unfortunately, if you’re compiling something that does not have an empty line break between your paragraphs, Pandoc does not fix this, and you wind up with just a wall of text in MediaWiki. So instead, we have to do this on Scrivener’s side of the operation.

Basically, you want to use Scrivener’s “Styles” to make things happen here. What’s neat about Styles is that you can have a style render text in a specific format in the editor pane, but when your project is compiled, the settings you have in your compiler will render your text like that instead.

HOWEVER… When compiling into a format such as MultiMarkdown or Basic Pandoc, you can set specific markdown code to be used with a specific Style.

Nifty, eh? Let’s get started then.

First, we’re gonna want to create a new paragraph style. Simply format some text in the editor pane to however you prefer and make sure your caret stays on that field of text. Next, go into the following menus: “Format” → “Style” and then select “New Style From Selection” (should be at the top of that sub-menu).

You’ll have to name this style. I simply named mine “Body” as it is what I’ll be using for my main bodies of text.

You may also wish to assign it a hot-key, as there seems to be no way to set a default “Style” (default formatting, yes, but not with a style). This can be done by bringing up the Style Panel (From the Menu, “Format” → “Style” and select “Styles Panel” or use the hot-key, Win+Alt+S)

From the Styles Panel, you’ll want to Right-Click on the Style you made just a moment ago, popping up a context menu. Go down to “Change Keyboard Shortcut” and a submenu will pop up, displaying a series of preset shortcuts. Unfortunately, you can’t change these, but you can reassign them as you wish. Don’t worry if it says that a preset is already assigned to something else. It’s just letting you know it’s in use, and selecting that preset hotkey will remove it from whatever Style it was assigned to, and reassign it to your new Style.

Next, fire up the Compiler.

Now, if you’re currently using one of Scrivener’s default formats for compiling, you’re gonna need to change it up. But Scrivener won’t let you change any of the defaults here. No worries, though. If you double-click the current format setting you wish to use, a dialogue box will pop up, saying pretty much what I just said above, but it then gives you the option to make a copy of the default format settings, and then edit them.

Choose that option.

A new window will pop up showing the various options. Folks who’ve used Scrivener 1 in the past should find this familiar, as this is pretty much the original compiler settings window, only now with a few more tweaks.

You’ll want to go to “Styles” in the left-side pane and then look for the Style you made earlier. If it’s not listed, no worries. You just have to add it in here. To the far right side of the window, there should be a plus sign, minus sign, and a help button. Click the plus sign to add a Style. It will drop down a familiar looking menu that has all the styles, including the one you made.

Select that Style, and it will now be available to use for compiling.

Now, here’s the tricky part. You need a carriage return. You can get one simply by opening Notepad, and then hitting the Enter/Return key once.

To misquote Sean Connery as Captain Marco Ramius, “Get me a return, Vasily. One return only, please.”

Next, you’re going to highlight that single carriage return. This can be easily done by just using the hotkey, Ctrl-A. Then Copy that, go back to Scrivener, and then select the style you made earlier.

To the right of the pane that has those styles listed are several fields. You’ll want the first field under “Paragraph Prefix/Suffix”. And now, paste that carriage return you copied from Notepad into that first field.

What this does is that when Scrivener compiles your project, it will insert that carriage return at the start of each paragraph you have formatted with the Style you made. And thus, your paragraphs without an empty line break between them will now have one after being compiled, rendering your text in a format that can be properly used in settings where an empty line break is required between paragraphs, such as MediaWiki.

I hope that someone out there finds this useful.

Here’s a trick to avoid having to style all of your “body” text, or at least catch those handful of paragraphs that you failed to mark as “body”…

When customizing your compile format, modify the document formats so that the sample text in them is styled for you imported Body style. Any text in your project that lacks a style assigned to it will then become “Body” styled, which will gain the extra line feed you’ve set up for it.

This does mean that lists have to be styled, as well as any other markdown that relies on having only one line feed after each line, instead of two, or they will be assigned the Body style. So this “advice” is only helpful if you’re willing to do that.

Another thing: if you go that route (not styling most paragraphs, but only non-body text like block quotes, lists, tables, etc…), you can redefine all of the styles used in Scrivener’s editor to have an outline around the styled text, so that you can tell at a glance that it has a style applied to it.

1 Like

I recently wrote up a little how-to on this topic, available in this thread. The key thing to note is that we’ve anticipated this preference and have basically set up the stock Markdown compile Formats to work that way after changing a few of their settings.

I tried that before, but for some reason it didn’t get properly parsed when I compiled my work. But it could be that we’re misunderstanding each other here, and if so, I just want to make sure we’re both on the same page.

Here’s some pictures to fill in for a few thousand words.

This is how my editing pane looks with my preferred formatting:

And here’s my desired output, as seen in PanWriter (an open source distraction free word processor that uses Pandoc as a back-end for exporting work):

This is the result I get when I apply your method:

I’m not sure if this is how it’s supposed to turn out, but without an actual, empty line break between each paragraph, these sections of text simply get turned into a wall of unbroken text in MediaWiki.

I suspect the issue is that Scrivener, as it is primarily aimed at professionals, expects someone to be writing using a manuscript format that will have those empty line breaks. But I’m not a professional. Instead, I prefer to have a more finished appearance, similar to how something would look in a published format.

Interesting, there appears to be a bug in the Windows version that is preventing this from working with stock settings. If you so much as select the provided line/paragraph-spacing setting from the format bar in Section Layouts, it then goes on to work fine.

(I’ve also noted that it doesn’t actually save your choice! You can set it to 18pt pre-para spacing and it always pops back to 9pt. Argh.)

That aside, the setup as described should be working, I’ve uploaded a sample project for you to take a look at:

Line Spacing - Sample Project (153.2 KB)

There is one potential sticking point worth mentioning: if you tested this approach using the project you described adding a “body” style to, then following the instructions I provided to the letter will not work, since formatting cannot be overridden on top of styles. That’s why the approach is generally discouraged since it makes using the compiler more complicated in the end.

To achieve this, with “body” styled text, you’d have to add that style to the Styles compile format pane and add paragraph spacing to it.

If you test the “Basic Pandoc (Paragraph Spacing w/ styles)” format that I included in the sample project, you should see both sections converted, whereas with the first format only the first section is fixed. But as you can see from that, it can work, it just takes more effort, and requires knowledge of where these settings are, and how styles work vs un-styled text and so forth. Thus it’s all quite a bit more advanced than what most people are willing to put up with.

I suspect the issue is that Scrivener, as it is primarily aimed at professionals, expects someone to be writing using a manuscript format that will have those empty line breaks.

I don’t know about that, I would say it is fairly typical for most people to write the way you are, and manuscript formatting is generally done with line height settings rather than physical carriage returns. In word processors—where most people hail from—it is discouraged to “double space” between paragraphs.

I would say if anything, pertinent to Markdown usage in Scrivener, is that it generally expects the editor to be used as you would when writing Markdown in a traditional text editor, with specification-friendly empty lines between paragraphs. But as should be demonstrated here, that isn’t necessary, it’s just how it assumes you will be composing as a default behaviour.

Yeah, I’m still not sure of what’s going on here. Just to make sure, I’ve got screen shots of the settings as I think you described in your instructions. Please let me know if I got something wrong.

First, I made sure to not use my “Body” style, just to make sure it wasn’t mucking with anything…

And removed it as a Style option from the Compiler…

And then the settings for Section Layout and Transformations:

Is there anything I missed?

The only potential thing that is missing is overlooking the fact that each individual Section Layout determines whether or not it overrides the text formatting (that way you can have some that strictly print text as-is rather than modifying it in some way). What I see in your screenshot is the override checkbox on the Heading layout, which doesn’t actually handle any text. It may be this box wasn’t ticked for the two that do.

And again, make sure you set the paragraph spacing deliberately, after enable it, to get around that bug I mentioned. It doesn’t seem to “see” spacing until you do.

Got it.

Just one thing: where do I find the setting for paragraph spacing? I think I’ve seen it before, but I can’t remember where for the life of me. The only other spacing options I see are for line spacing.

That’s the one, it is all folded into one tool. Use the “Other” selection at the very bottom of the dropdown menu to access additional settings.

Like so, then?


Okay, just tried it out and it works now. I’ll be putting it through its paces to be sure, but if I find anything else related that’s going wrong, I’ll be sure to come back and let you folks know, since you mentioned that this is a bug in the Windows version.

EDIT: And I just noticed what you meant about it not saving the setting. So each time I compile, I’ll need to go back in there and reset the line spacing back to “Double”.

I really hope this bug gets fixed soon. That will get tiresome very fast.

1 Like

You shouldn’t have to change the line spacing at all, that isn’t turned into whitespace. It’s only the “before paragraph” spacing that matters, which is fortunately “hard coded” by the bug in such a state that it works.