Hi, I have a text where I want to insert line breaks, but if I do Insert > Line break, the text shows correctly in Scrivener but when compiled to Markdown an odd character seems to be inserted. Perhaps it’s a Unicode line break symbol? But the standard Markdown representation of a line break is the ‘’ character followed by a newline. Is there any chance the MultiMarkdown compile could be updated to do this?
Actually I see here: Basic Syntax | Markdown Guide that perhaps the “two spaces at the end of the line” is preferable to \
characters, as it is more compatible across Markdown parsers.
If you use two spaces at the end of your lines where you want line breaks, you won’t be able to use Scrivener’s feature designed to look for and fix accidental double spaces.
But, you could use \
, and if ever that is a problem, you could replace those \
with space-space at compile.
For the rest, I think (but I ain’t sure) that if you insert \
instead of a line-break in your body text, you’ll get the desired line-break post-compile.
Unfortunately, that won’t work as (among other things) these lines are within a blockquote paragraph. The line break itself gets turned into a paragraph break. If it were in a non-blockquote paragraph it would be OK because I can adjust the line spacing and stop the new line being turned into a separate paragraph.
Now, what I can do is put it as raw Markdown, which does work, but that’s a little bit of a nuisance as it loses the clarity of reading and writing in formatting that is one of the main reasons I’m writing in Scrivener rather than a text editor.
Fundamentally though the MultiMarkdown compiler is producing output which is not valid Markdown/MultiMarkdown, so in my view it’s a bug which would be wonderful to see fixed up if at all possible.
Then maybe try that “double space at the end of the line” thing.
And if it works, then, in the editor, use any cryptic symbol of your choosing from the character map instead.
And have then your compile format later replace it for a double-space.
This way, your intended line-breaks will be visible to you in the editor, and also won’t mess up the double-space search & fix feature from Scrivener.
Just a suggestion, of course. As an alternative.
EDIT: You could even then use real line-breaks, plain and simple, and have your compile format later replace them with space space.
Excellent suggestion! And perhaps in due course the MultiMarkdown compile will get fixed but until then that should sort it out
About the potential bug itself, which version of Scrivener are you running? Windows or Mac?
I’m on a Mac, version 3.2.3
To clarify something, Scrivener’s Markdown integration is with Pandoc and MultiMarkdown, both of which respect the \
method. So if that’s what you would prefer to use, then go for it. Unless you intend to compile to .md and process that using some other converter, you should be fine. The backslash method is part of the CommonMark specification, which is the closest thing there is to a standard. Personally I prefer it in most cases, because I prefer visible syntax.
To return to the original question: yes, the line break Unicode character has no meaning in a text file and no Markdown tools I’m aware of will do anything with it. Inserting various Unicode characters into the editor and having those passed through into the output isn’t a bug in and of itself. Scrivener isn’t going to assume to know what you mean by that.[1] For all it knows you are using a text processor that does handle them in some manner.[2] That doesn’t mean you can’t use them in Scrivener though! But you would need to tell Scrivener what you mean by this symbol, and have it convert it to something useful. This can be done with Replacements in your compile format. If you have it search for the line break character and turned into \
or two spaces, both with a carriage return following, then you should be good to go.
You can find an active example of this being done in the “General Non-Fiction (LaTeX)” project template, in the Non-Fiction section. If you open its “LaTeX (Memoir Book)” compile Format that comes with that template, and look at the Replacements table, you’ll find an entry toward the bottom where the with field has \\
visible within it. Unfortunately whitespace control characters are invisible in this table, but if you were to copy and paste the contents of these fields into a editor that shows invisible characters you would better see what is going on. Of course LaTeX uses two backslashes instead of one, but you get the idea.
@Vincent_Vincent: if you use two spaces at the end of your lines where you want line breaks, you won’t be able to use Scrivener’s feature designed to look for and fix accidental double spaces.
Fortunately that isn’t something Markdown writers have to worry too much about. Multiple spaces are removed (save for this one specific usage at the end of the line) automatically. Of course one might want to use that command for their own personal preference though, but it’s not something you have to give any thought to for producing good quality output.
- The one exception is if you use the Convert rich text to MultiMarkdown option in the General compile options tab. That’s a whole different way of working though, and makes using any actual Markdown in the editor more clumsy as you have to use Preserve Formatting or specially set up styles to instruct the compiler to leave Markdown blocks of text alone. I don’t recommend it in general, it’s a better option for those that want Markdown outputs in addition to Scrivener’s other outputs. If you’re just looking to make some things here and there less syntax-oriented, mixing in stuff like Replacements and styles that take text and add syntax to it, is the superior option.
- For example, Apple’s TextEdit will interpret page break characters in text files when printing or displaying the file in page preview mode. This is a rarity though, and most text editors and processors and pretty-printers will at best do nothing with it, and at worst print a visible “Huh?” code of some variety.
I actually meant the opposite :
If one adds and extra space at the end of a sentence (expecting it to later turn into a line-break), as in period-space-space-Capital letter/next sentence, using Edit/Text tidying / Replace multiple spaces with single spaces
would no longer be an option, as it would take the double space away from the text.
For the double space to be at the end of a line, you actually need “an end to the line”, and that was here the whole issue.
That statement you quoted is in regards to how Markdown itself works. I can have 50 spaces between two words in my editor, but it will come out with one space in the output. You can try it right here on the forum in fact. There is about 3cm of spaces in my composition editor here, between the words “in” and “fact” in that previous sentence.
So that in and of itself, means Markdown authors do not have to worry about details like this while writing. You can accidentally add multiple spaces and it has no effect on the output. And if you don’t have to worry about that, you don’t really need this menu command anyway. Thus, not being able to use it is of little consequence.
I see. Makes sense.
Anyways, I just tested it, and Edit/Text tidying / Replace multiple spaces with single spaces
removes the extra space even before a line break or carriage return one way or the other.
…But sadly enough, even then, leaving one. (A completely useless one…)
Not the same topic, but imo the function should remove spaces preceding a line break or carriage return.
I don’t know, you could argue that removing multiple spaces with “single space” is exactly what it is doing. It’s a very simple tool, not a broad-spectrum whitespace cleaning tool.
If someone has a very messy document with lots of whitespace everywhere, regex (or maybe a tool built for this) is probably the best answer. There are many dozens of routine cleaning tasks not present in that Text Tidying menu. We only address the most common ones for convenience.
Yeah. One can simply do it with project replace, replace space-CR with just CR, but I thought that since that feature is probably a RegEx already (?), it wouldn’t be too hard for it to actually “remove useless spaces” rather than only fix “double spaces”.
Not a big deal anyways.
So, here’s a frustrating detail: it won’t work reliably with the compile format set with the ‘Convert to plain text: Paragraph spacing’ option selected (Compile > … > Edit format > Transformations).
I admit that I’ve been fighting against using blank lines in my thesis to separate paragraphs, but I will now concede defeat and convert all the paragraphs. It will also solve the various other odd places where the transformation didn’t work.
I find myself looking at the Edit > Text Tidying > Remove Empty Lines Between Paragraphs menu item, and wishing very much that there was an equivalent one: Add Empty Lines Between Paragraphs!
(Backup your project before experimenting with this)
Use project replace. Edit / Find / Project Replace
Replace your carriage returns with return-return.
(You can do it to only selected documents if you wish.)
Works with the Find...
function too.
Perfect. Thank you! I’m extremely grateful for that — saved me a huge amount of time.
Next question: how can I update the “None” formatting to no longer have paragraph spacing before and after?
-
Select some text from a paragraph of that style.
-
Adjust it for that one paragraph
-
Go to
and redefine the style.
Paragraphs of that style will then automatically conform across your project.
If you meant the “no style” formatting, just do as I said, but instead of redefining a specific style :
Yes, that works perfectly for paragraphs that have a style. What I can’t figure out is how to affect the default formatting for existing documents. I have updated the default which now applies correctly to any new documents, but it doesn’t seem to reformat the existing ones?
Most of my paragraphs have no style (i.e. the Style dropdown shows “No Style” in it).