Replacing Single Linebreaks with Space

Hi guys,

I have converted some epub books into markdown via pandoc, It caused a lot of linebreaks inside paragraphs, but paragraphs are still distinguishable. I want to remove only single linebreaks from the text. Right now I am using this AHK script which I have to select every paragraph manually to work. And it acts weirdly from time to time so I have to pay a close attention and waste my time. I suspect it is because of using Clipboard in it.

Is there a find and replace way of solving it, or even a script in any language that I can run Inside obsidian?

Thank you all in advanced

Have you tried the “strict line breaks” toggle in Settings?

This sounds like a job for sed or tr if you can figure out the proper regex.

1 Like

it is fine in review mode, I want it fixed in the actual text / edit mode.

what are sed or tr? I knew it needs regex but my knowledge of subject is zero, I was hoping someone with that kind of knowledge solve the regex for me

They are old school command line tools, if you can paste an example file here and the expected result I may be able to point you in the right direction.

Original:
Original.md (8.3 KB)

Final Result:
Final Result.md (8.1 KB)

P.S. : Also as I was uploading these files I noticed that both files look the same in Typora even in edit mode. Maybe It is just a problem with my setting after all

I would look at these in a text editor, the only discernible difference I notice, is that the original will have something like this: []{#pagelist_173}with, and the final result will have something like this: []with.

That happens because of the AHK code I use and is not intentional, it also removes “!” for some reason.
Which text editor you are using? I am looking at them now with Notepad and there is a lot of difference, actually it’s the Original ones that looks human readable to my surprise because of linebreaks in each line.

P.S.

Original:

Final Result:

See attached. Might be too lengthy a process, but it seems to work okay.

Original.md (8.6 KB)

1 Like

Thanks, It would still save me a lot of time, comparing the code I am using right now.
What character I should enter in Ctrl + F to search for paragraph breaks/ line breaks and spaces?

1 Like

Welcome.

On Macs, users type option enter for a paragraph return and command option enter for a line break. Don’t know the keystrokes for other operating systems. I could see that the file had paragraph returns at the end of the broken lines (not line breaks), so I only had to search and replace those. It helps to see invisible characters to understand the construction of the text. Don’t know what apps show invisibles in Windows. Word? Scrivener? Notepad?

1 Like

I searched a bit and Notepad++ can do it just fine, altho I think It could be added to obsidian core as a useful feature. I am sure it is important for regex in other occasions too.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.