From single newlines to double?

I have some incoming markdown files in which I would like to convert \n line endings to \n\n paragraph delimiters.

I can easily do something at the command line, perhaps with a regex, but I wonder if there is, at this stage, any way of doing that for selected stretches of text within WriteRoom 4.0 Preview (407) ?

No, I don’t think so.

WriteRoom does have Format > Cleanup > Unwrap Paragraphs, for converting hard wrapped paragraphs into single paragraphs. But that’s, I think, the opposite of what you want.

I think some form of find and replace processing is probably what is needed.

If there is some existing Markdown tool command that can do this let me know and I’ll try to implement in WriteRoom too. Is this a common pattern/need?

I think just enabling the Line Breaks setting should handle this case. My apologies if I am missing something here, but the problem I have seen is not in the actual characters in the text file, but in the way the MD parser converts those character.

1 Like

I think perhaps not – in this case, the files are coming in as an unsegmented sequence of sentences, from a transcript. Probably hard to avoid some exercise of judgment, and manual segmentation :slight_smile:

Good thought – the WriteRoom 4.0 Preview (407) > Settings > Markdown > Line Breaks setting

(keep every line break on export to HTML, RTF, etc )

Is certainly helpful at the export stage.

What I’m really trying to do here is just make these texts more readable in the editor.
The thing is probably to do that manually, perhaps in something like VSC, with a bit of regex help within selected ranges.

e.g. perhaps:

  • First (all) \n → \n\n
  • Then in selected ranges (identified as paras) collapse \n\n → \n
    `

That is different. For this kind of thing, I let Claude write my regular expressions or micro-scripts. I asked it about how to do the first half of what you want and it suggested a CLI Perl solution:

perl -0777 -pe 's/(?<!\n)\n(?!\n|\z)/\n\n/g' input.txt > output.txt

The -0777 reads the whole file as a string, so the regex can work across the lines.

1 Like

Thanks – yes – various routes of that kind, and can be complicated, in the case of RTL, by ambiguities about the sequencing of a sentence-final period and the delimiting newline :slight_smile:


( which came first, the start of the sentence, or the end ? )

Oh my. That graduates from an annoying problem to a hard one. I wonder if the Typography Setting could grow a line break height padding setting that would solve this in the view and not the file.