Line breaks are removed when exporting through MMD

Excellent job on beta 3! I’ve only had time for a quick look, but it looks quite wonderful.

I did notice one thing while trying out the brand new MMD export. It seems that it strips out all line breaks from the text. This is regardless of which language you use for SmartyPants.

When I did the language tweeks of the SP script I had to run the output through a small perl shell script that looked like this:

while (<>) { $_ =~ s/\n/\<br\/\>/gi; print $_; }

This obviously replaces
tags with real line breaks. I always imagined that MMD would take care of this, but perhaps not?

I think this would be best kept as a user customisation, because there is at least one case created by Scrivener which would create superfluous line breaks: When you opt to not have Annotations in the output, and some of your annotations exist within their own paragraphs. This would create a series of empty lines in the output, which would be retained by any conversion to
tags.

Given that it looks like you know how to do it, I would suggest altering the scripts in Scrivener, and adding your Perl script to the primary Perl scripts that Keith is calling for your intended output.

They are located at:

/Applications/Scrivener.app/Contents/MacOS/MultiMarkdown/bin/multimarkdown2*.pl

Are you sure about this? I must say I fail to see how losing these line breaks could be considered acceptable to any user. It at least tends to mange most of my texts – especially those with a lot of dialogue (and consequently a lot of soft line breaks).

Er – I really wouldn’t know how to tweak Keith’s scripts myself. The code posted above if shamelessly lifted from the vastness of cyberspace – I’m a pearl idiot myself. But I suppose I could learn…

Well, I can only really be sure of myself. :slight_smile: I know it would drive me batty. But here is an example of the situation I was describing, where annotations are brackets:

[code]
Dragging Tip: By default, when you drag items around you can drop them on other items as well as between them (dropping “onâ€

Also to consider is the conflict of philosophies. In XHTML, you are encouraged to use style to adjust the appearance of a document, rather than embedding the appearance into the content. So instead of using successive
tags, you would create a “lastparagraph” class with an extra large margin-bottom, and apply that to your last paragraph. LaTeX has an even more strict philosophy of “don’t do anything about appearance, I’m the layout designer, that is my job.” Of course you can, but you are encouraged not to.

I am guessing that it is for this very reason that neither MMD nor Markdown have any syntax for forcing empty lines. Just a guess. You might be able to come up with some work-around using code blocks or something.

Ok. I see what you mean. Let me illustrate what I’m concerned about:

Using Scriveners MMD output transformes

Ett par meter framför kvinnan gick en pojke och en flicka och höll varandra i handen. Den vithåriga kvinnan sneglade längtansfullt på det unga paret. "Kärleken ligger verkligen i luften. Vart man än tittar ser man förälskade par. Kanske är det värmen som sätter hormonerna i svallning?" "Är du avundsjuk?" "Avundsjuk? Nej, pyttsan! Jag har minsann inte alltid varit ensam", sa kvinnan, "Jag -- om någon -- har verkligen känt äkta kärlek". "Jasså?" sa den manliga vännen med låtsad förvåning. "Jo, då. Till och med jag har som ung förlorat mig i passionens vågsvall -- men visst har jag redan tråkat ut dig med den historien?" "Kanske -- men den tål säkert att höras igen."

into

[code]Ett par meter framför kvinnan gick en pojke och en flicka och höll varandra i handen. Den vithÃ¥riga kvinnan sneglade längtansfullt pÃ¥ det unga paret. â€

Oh! Yes. MMD requires a full paragraph space between things to keep them as paragraphs. So in other words, Scrivener’s (and by extension, RTF’s) soft line breaks are ignored. What you really want in this particular situation, is to use MMD’s soft break, which is to apply two spaces to the end of each line.

I wonder if it is possible for Keith to make it so that RTF soft breaks get converted into two spaces like this? That would be a much better solution, as it would allow intentional breaking to be preserved, without adding a wild garden of
s all over the place in unintentional spots.

Great tip about the double space at the end of lines. I had no idea. Hopefully there will be some other way around this, since I think it’s a bit counter-intuitive having to add extra spaces like this. It kind of disrupts the writing experience.

This would perhaps be something for Fletcher to ponder, rather than Keith? I would think it better to straighten this out within MMD – not within Scrivener itself. Or – as you just suggested – perhaps Scrivener could temporarily convert these soft line breaks into double spaces during export.

This would best be categorized as a misunderstanding of how Markdown, and by extension, MultiMarkdown work.

It is designed to work like this. This is to allow a plain text file that has been line wrapped (to 72 or 80 characters for instance) to be handled properly.

If you desire a new paragraph, then you use two newlines, leaving a blank line in between paragraphs.

If you want to force a single hard return, then you use “space-space-newline.” This is NOT used to indicate a new paragraph. This is used when you have some special formatting needs, such as a list of text items that for some reason you do not want formatted as a list. Or if you need to insert a line break in some metadata (an address for instance).

Again, paragraphs are separated by a blank line (e.g. two newlines).

Markdown, and more specifically MultiMarkdown, are powerful approaches to formatting text with minimal markup. The MultiMarkdown web pages (google it) include several examples showing how a single plain text file can be transformed into high quality XHTML, LaTeX, pdf, or (sometimes) RTF output. I highly recommend using it for writing documents that you wish to format yourself into production quality PDF’s. But, as much as I avoid RTFM myself, I would suggest it in this case. There are lots of tricks you can use to get the output you desire, but for many users there may be a philosophical shift that needs to occur first. It’s a very different approach than a typical word processor.

This would be exactly the wrong thing to do with MultiMarkdown. See my other post for more description.

It should be very rare that one needs to use the “space-space-newline” to generate a
.

Again, I suggest to anyone interested in using MMD that they take some time to read the MMD and Markdown web pages and syntax descriptions. It’s well worth it!

I beg to differ. I use it all the time when writing dialogue, and I think a lot of English-speaking-writers do as well.

MD/MMD is a solid product, and I really respect the concept behind it. That does however not mean that Scrivener wouldn’t benefit from a somewhat more intuitive implementation when it comes to line breaks and such. At least not in my humble opinion. But then again, I’ve never really used MMD for anything else than web copy before and I tend to write a little differently for that medium.

If he wants to use verse formatting for dialogue (something I have never seen before, but then even Joyce had problems with typical dialogue formatting), then it would seem to me that the usage of what you are referring to as list spacing, would be desired. There are numerous cases where such formatting would be desired, such as in verse and poetry, where you would not want full paragraph spacing or indenting to occur. Why, in these cases, is the use of MMD’s ability to generate a verse style section philosophically opposed to M/MD?

And incidentally, this is a primary purpose of the “soft” line break in Scrivener.

I categorically refuse to have anything to do with this. :slight_smile: Scrivener only does a very basic export to MMD - and this is my intention. If you are using MultiMarkdown to export to any format, then it is up to you, the user, to ensure that you are using the correct MultiMarkdown syntax to get the results you require. It is not Scrivener’s job to second-guess any more than parsing annotations and footnotes.

This is the hard party line. :slight_smile:

All the best,
Keith

Really? Now I’m curious. What is the most common way of writing dialogue in English? Do you always use a new paragraph for each line in a conversation? Tell me, tell me please.

Well, there we have it, then. It does render Scrivener a little less usable for me, though.

Yes. Always.

I don’t really understand why. You wanted MultiMarkdown, didn’t you? And now you have it. Scrivener doesn’t remove any line breaks at all. Not at all. It just takes your text and compiles it into a normal MMD file. So, what is the problem? If you wanted MultiMarkdown, then surely you wanted to use the syntax to create your documents? Sorry, but I don’t really understand the issue here. MultiMarkdown has certain demands that you need to meet to format a document. If these are a problem, then they need to be addressed by Fletcher, not me - like I say, it is not Scrivener’s place to alter your text too much if you have told it that you are using MultiMarkdown…

Bewildered (well, okay, just a little confused),
Keith

That is how I usually see it. When the conversation switches speakers a new paragraph is used. There are exceptions, of course, but I think this would be more of a typographical artistic style than a writer’s choice.

Yes I do – and I’m very grateful for it. I never realised that soft line breaks were handled this way by MMD though, but that’s my headache, not yours. Thank you for your efforts.

Hi Joakim, sorry if I came across as a bit grumpy - I just came home from a long day at work and was trying to deal with all the beta issues. I wonder if Fletcher has a solution? Is dialogue handled with soft line breaks in German, then, rather than full paragraph breaks?

Why would you not use separate paragraphs for each speaker? It’s been a while since I took a formal writing course, but this is standard practice in all the books I read.

Now, whether you want to indent the first line of a paragraph is an entirely separate matter, and that is between you and LaTeX. Not MultiMarkdown. But everything I have read on LaTeX suggests the default behavior (but I am not an expert on this.)

But if I am mistaken, or misunderstanding you, please let me know.

Now, using MMD for poetry could be difficult, depending on your needs. The memoir class document (if I remember correctly) has some interesting work on using LaTeX for poetry.

Using MMD to format this will be difficult, if not impossible. It’s fairly simple to do soft line breaks for basic stuff, but for some of the more modern visually complex poetry, you’re on your own.