Simple script to combine lines into a single paragraph

What : a small script that allows to combine lines into a single paragraph.

Why : as a regular user of OCR, and copy-paste from pdfs, I often end with a lot of scattered lines. This script allows me to select everything and transform it into a paragraph instantly.

How : I use the following script with Templater :

<%*
noteContent = tp.file.selection();
newContent = noteContent.replace(/\n/g, " ");
return newContent;
%>

Then I bind it to a shortcut.

2 Likes

Thanks for the idea. I needed this!

I modified it a little bit. Now it’s going to replace also all double blank characters and trim at the start and the end of the selection.

<%*
noteContent = tp.file.selection();
newContent = noteContent.replace(/\n/g, " ");
newContent = newContent.replace(/ {2,}/g, " ");
newContent = newContent.trim();
return newContent;
%>
1 Like