Windows or Old Mac line endings → OS X unix LF

This can probably be done with the built-in filters, but I may be misusing or misunderstanding them, or perhaps one of them has a glitch ?

In the meanwhile, I'm converting CR line endings to standard LF (when copy pasting from a PDF) using this approach:

Fix line endings (Windows or old Mac → LF).kmmacros (17.8 KB)

osascript -l JavaScript <<JXA_END 2>/dev/null
(function () {
	var a = Application.currentApplication();
	a.includeStandardAdditions = true;
			/(\r|\r\n)/g, '\n'
	return a.theClipboard();

The Filter to Unix Line Endings should do that.

So perhaps a bug ?

( It seems to be translating \r to a 3 byte Unicode Line Separator sequence in lieu of the expected ‘\n’ )

Not a bug – an over-complex initial clipboard from the colored and styled text in the PDF, as discussed in

Many thanks for your point that the Unix Line Endings Filter needs a simple text clipboard to work on, and that the Remove Styles filter is the first thing to apply.

Here, FWIW, are before and after evaluations (in Script Debugger) of the Applescript expression

the clipboard as record

BEFORE (multiple styled representations in the clipboard)

AFTER Remove Styles (just cleaned text in the clipboard)