Script to Correct Paragraph Spacing

When I paste text into DTP from websites, often the spaces between paragraphs are lost, or reduced to a single return when I need two returns. The solution is simple but I wonder how to do this in Automator or Applescript? Then I can use it as a Toolbar script. I’m a clutz with Applescript.


Select All text in DTP

Command F - Find

Enter in Find field: Option Return

Enter in Replace with field: Option Return Return

Replace All


Any coders out there who can help? Thanks in advance

Paste text into… what?

Have you tried Edit > Paste and Match Style?

This problem comes up whenever I use the “Take Rich Note” context menu service in Safari, which creates a new record in DTP with reduced paragraph returns ( only me experiencing this?) Paste and match style will retain the spacing but lose formatting and any images in the rtfd file it seems.

Your “Word Service” is great but last time I looked, it was too much for this simple spacing request and so I’m asking about a single script. Thanks.

Do you actually want to change the paragraph spacing (see AppleScript property of text suite of DEVONthink) or only replace single returns with two returns?

Just replace single returns with two returns. Thanks.

Here’s a simple script that inserts a new, empty paragraph after each paragraph in the frontmost window (only plain/rich text is supported):


tell application id "DNtp"
	try
		tell text of think window 1
			set n to (count of paragraphs)
			repeat with i from 1 to n
				make new paragraph with data (return) at (after paragraph (2 * i - 1))
			end repeat
		end tell
	end try
end tell

Thank you Christian for your attention and such an elegant script – It works flawlessly. It’s a little slow going though if it’s used on a long document as it iterates through each line.

I reinstalled the Devonthink Word Service and found that the Reformat command works better than ever. It restores missing carriage returns after using the Take Rich Note service in Safari as I described. Plus it can be used in DevonNote documents as well which also suffer the same problem.

Thanks for your help. This problem is now solved.