diff --git a/source/SentenceCase.popclipext/Config.js b/source/SentenceCase.popclipext/Config.js deleted file mode 100644 index 869fe113..00000000 --- a/source/SentenceCase.popclipext/Config.js +++ /dev/null @@ -1,7 +0,0 @@ -define({ - identifier: "com.pilotmoon.popclip.extension.sentence-case", - name: "Sentence Case", - icon: "square filled S", - action: require('sentence-case.js'), - popclipVersion: 3482, -}); \ No newline at end of file diff --git a/source/SentenceCase.popclipext/Config.json b/source/SentenceCase.popclipext/Config.json index 5eca2524..926a1c60 100644 --- a/source/SentenceCase.popclipext/Config.json +++ b/source/SentenceCase.popclipext/Config.json @@ -1,16 +1,8 @@ { - "Actions" : [ - { - "After" : "paste-result", - "Image File" : "sentence-case.png", - "Script Interpreter" : "\/usr\/bin\/php", - "Shell Script File" : "sentence-case.php", - "Title" : "Sentence Case" - } - ], - "Extension Description" : "Start each selected sentence with a capital letter.", - "Extension Identifier" : "com.pilotmoon.popclip.extension.sentence-case", - "Extension Name" : "Sentence Case", - "Note": "Updated for macOS 12.0 Monterey.", - "popclipVersion" : 3543 + "name" : "Sentence Case", + "identifier" : "com.pilotmoon.popclip.extension.sentence-case", + "description" : "Start each selected sentence with a capital letter.", + "icon": "square filled S", + "popclip version" : 4151, + "module": "sentence-case.js" } \ No newline at end of file diff --git a/source/SentenceCase.popclipext/sentence-case.js b/source/SentenceCase.popclipext/sentence-case.js index 7766ef43..9cc97f3f 100644 --- a/source/SentenceCase.popclipext/sentence-case.js +++ b/source/SentenceCase.popclipext/sentence-case.js @@ -1,32 +1,31 @@ -function sentenceCase(text) { - const regex=/(^\s*\p{L}{1}|[.?!]\s+\p{L}{1})/gu; // split into something approximating sentences - text = text.toLowerCase(); - return text.replace(regex, (match) => match.toUpperCase()); +function sentenceCase(text) { + const regex = /(^\s*\p{L}{1}|[.?!]\s+\p{L}{1})/gu; // split into something approximating sentences + text = text.toLowerCase(); + return text.replace(regex, (match) => match.toUpperCase()); } -if (typeof(define) !== 'undefined') { // when running in popclip, export the function - define(() => { - return (selection) => { - popclip.pasteText(sentenceCase(selection.text)); - } - }) -} -else { // when running in jsc, perform tests - function test() { - const data=[ - ["blah", "Blah"], - ["BLAH. blah.", "Blah. Blah."], - [" BLAH blah? BHAL.\nff", " Blah blah? Bhal.\nFf"], - ["BLAH (blah-more", "Blah (blah-more"], - ["élan fdf? написанная! OK", "Élan fdf? Написанная! Ok"], - - ["Nick's best dog's fur", "Nick's best dog's fur"], - ]; - data.forEach((pair) => { - const [input, output]=pair; - const result=sentenceCase(input); - print(`${output===result?'pass ':'fail *'} ${input} => ${result} (expected: ${output})`); - }); - } - test(); +exports.action = (input) => { + popclip.pasteText(sentenceCase(input.text)); +}; + +function test() { + const data = [ + ["blah", "Blah"], + ["BLAH. blah.", "Blah. Blah."], + [" BLAH blah? BHAL.\nff", " Blah blah? Bhal.\nFf"], + ["BLAH (blah-more", "Blah (blah-more"], + ["élan fdf? написанная! OK", "Élan fdf? Написанная! Ok"], + + ["Nick's best dog's fur", "Nick's best dog's fur"], + ]; + data.forEach((pair) => { + const [input, output] = pair; + const result = sentenceCase(input); + print( + `${ + output === result ? "pass " : "fail *" + } ${input} => ${result} (expected: ${output})`, + ); + }); } +// test(); diff --git a/source/SentenceCase.popclipext/sentence-case.php b/source/SentenceCase.popclipext/sentence-case.php deleted file mode 100644 index b47e6117..00000000 --- a/source/SentenceCase.popclipext/sentence-case.php +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/source/SentenceCase.popclipext/sentence-case.png b/source/SentenceCase.popclipext/sentence-case.png deleted file mode 100644 index aa85278b..00000000 Binary files a/source/SentenceCase.popclipext/sentence-case.png and /dev/null differ diff --git a/source/Uppercase.popclipext/Config.js b/source/Uppercase.popclipext/Config.js index 001e6203..d76ce0cc 100644 --- a/source/Uppercase.popclipext/Config.js +++ b/source/Uppercase.popclipext/Config.js @@ -1,8 +1,10 @@ -define({ - identifier: "com.pilotmoon.popclip.extension.uppercase", - name: "Uppercase", - icon: "square filled AB", - action: (selection) => { - popclip.pasteText(selection.text.toUpperCase()); - } -}) \ No newline at end of file +// #popclip +// name: Uppercase +// #identifier: com.pilotmoon.popclip.extension.uppercase +// description: Make the selected text ALL UPPERCASE. +// icon: "square filled AB" +// popclip version: 4151 + +exports.action = (input) => { + popclip.pasteText(input.text.toUpperCase()); +}; diff --git a/source/Uppercase.popclipext/Config.json b/source/Uppercase.popclipext/Config.json deleted file mode 100644 index c5d63352..00000000 --- a/source/Uppercase.popclipext/Config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Actions" : [ - { - "After" : "paste-result", - "Image File" : "uppercase.png", - "Script Interpreter" : "\/usr\/bin\/php", - "Shell Script File" : "uppercase.php", - "Title" : "Uppercase" - } - ], - "Extension Description" : "Make the selected text ALL UPPERCASE.", - "Extension Identifier" : "com.pilotmoon.popclip.extension.uppercase", - "Extension Name" : "Uppercase", - "Note" : "Updated for macOS 12.0 Monterey.", - "popclipVersion": 3543 -} \ No newline at end of file diff --git a/source/Uppercase.popclipext/uppercase.png b/source/Uppercase.popclipext/uppercase.png deleted file mode 100644 index cd539512..00000000 Binary files a/source/Uppercase.popclipext/uppercase.png and /dev/null differ