Delete Newline Characters Is Also Deleting Text Formatting

Hello Guys!

I have some text that I need to clean by taking out the newlines. I have found that it is best to to replace via regex \R+

So, I have this text:

PageEdit -- mode Edit -- (1440x641) 2022-10-11 at 9.02.21 p.m.

And this is the macro:

Keyboard Maestro Editor — Command 2 - Make paragraph 2022-10-11 at 9.03.44 p.m.

Unfortunately this macro also takes out the formatting (italics, bold, etc), and the resulting text is this one:

I am using a WYSIWYG editor for epubs. I have tested with many other programs and the result is the same, so I think that maybe something is going on with this macro.

Anyone has faced this issue before and resolved it?

Thanks a lot!

Try Regular Expression (Case Sensitive) and [\r\n]+.

Check what is changed before and after macro:
Finder➡️Edit➡️Show Clipboard
or in Terminal:

osascript -e 'clipboard info'

Thanks @suliveevil!

I have tried it and it is the same effect. When checking the clipboard in Finder, I have seen that it does not display formatting. I have tried to copy from a web site, etc and it is displayed there as plain text.

However in the Terminal it shows the formatting. Here is the output of before and after executing the macro.

david@192 ~ % osascript -e 'clipboard info'
«class HTML», 15433, string, 269, Unicode text, 538, «class ut16», 540
david@192 ~ % osascript -e 'clipboard info'
«class utf8», 258, «class ut16», 518, string, 258, Unicode text, 516

So, I know it changes it but still have no clue how to fix this :dizzy_face: Any ideas come to mind?


It's up to the app you are cutting/copying from what formats it places on the clipboard. And it's up to the app you are pasting into what formats it will receive.

You'll see from what you posted that you are copying HTML, not styled text. And it may be that even if you can keep it as HTML while doing the S'n'R the app might be too dumb to understand it when pasted back in.

(Note that your macro works as expected if run on actual styled text in eg Word.)

It might help if you say what the app is. Alternatively, doesn't it have its own built-in Search and Replace you could leverage?