Custom script
When the built-in cleaning isn’t quite enough, add your own step. Settings → Script runs a JavaScript function on every cleaned copy, after all the other steps.
- Turn on Run a custom JavaScript transform after cleaning.
- Write a function named
transformthat receives the text and returns the new text:
function transform(text) { return text.replace(/\s*\n\s*/g, " ");}Insert Example has three to start from: Remove all line breaks, Join wrapped lines, keep paragraphs (good for PDFs) and Lowercase everything. Reset goes back to the empty template.
Good to know
Section titled “Good to know”- The script runs on every cleaned copy, not on copies kept original. With Plain Text with Links it changes only the plain-text version: apps that take rich text get the version with links, as it was.
- If the script fails, the copy is pasted without it, and the Script tab shows the error in red.
- A script that runs longer than 1.5 seconds is stopped. If it never ends (an endless loop, say), fix it and relaunch Pastesmith.
- Test it in Try It before you rely on it: the result shows there, and your clipboard doesn’t change.
The script runs on your Mac, inside Pastesmith. It can’t reach the network or your files.