Hi and good day,
On this forum 2 scripts were presented for texts, to replace simple line breaks where there should be 2 - a common feature when you copy and paste some text.
(for /n do /n/n )
Those 2 scripts are from @chrillek and @houthakker, so I saved the one as AppleScript and the other as JavaScript and I put them into the DT scripts folder.
But they don’t fire - irrespective if I select a file or not.
This is the 1st script:
SCRIPT 1
/** Replace /n with /n/n
by chrillek, 2020-05-06
**/
(() => {
app = Application(‘DEVONthink 3’);
app.includeStandardAdditions = true;
var sel = app.selection();
sel.forEach(doc => {
text = doc.plainText();
doc.plainText = text.replace(/\n/g,“\n\n”);
});
})
and this is the AS:
SCRIPT 2
— Replace /n with /n/n
— by houthakker, 2020-05-08
— How to run a simple Regex on the copied text? - #4 by houthakker
— no line breaks
use AppleScript version “2.4”
use scripting additions
on moreSpace(x)
x & linefeed
end moreSpace
on run
set the clipboard to unlines(map(moreSpace, paragraphs of ( the clipboard )))
end run
-------------------- GENERIC FUNCTIONS --------------------
– mReturn :: First-class m => (a → b) → m (a → b)
on mReturn(f)
– 2nd class handler function lifted into 1st class script wrapper.
if script is class of f then
f
else
script
property |λ| : f
end script
end if
end mReturn
– map :: (a → b) → [a] → [b]
on map(f, xs)
– The list obtained by applying f
– to each element of xs.
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|( item i of xs, i, xs)
end repeat
return lst
end tell
end map
– unlines :: [String] → String
on unlines(xs)
– A single string formed by the intercalation
– of a list of strings with the newline character.
set {dlm, my text item delimiters} to { my text item delimiters, linefeed}
set s to xs as text
set my text item delimiters to dlm
s
end unlines
/
Any assistance would be greatly appreciated!
With best regards,
Omar KN