-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
44 additions
and
100 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
define({ | ||
identifier: "com.pilotmoon.popclip.extension.uppercase", | ||
name: "Uppercase", | ||
icon: "square filled AB", | ||
action: (selection) => { | ||
popclip.pasteText(selection.text.toUpperCase()); | ||
} | ||
}) | ||
// #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()); | ||
}; |
This file was deleted.
Oops, something went wrong.
Binary file not shown.