Improved Title Case Macro

You don't need either a Named Clipboard, nor a Display Clipboard.

Since the macro adds two items to the System Clipboard History, you just need to delete them at the end of the macro, and the item on the System Clipboard (ready to paste) is what you had before you triggered the macro:

Each of these deletes the top (current) Clipboard item.

This is all you need:

##Macro Library   Improved Title Case Ver 2.2 (Del CB 2X) @JMichaelTX


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/0/0ed02a57a44c0bdbd8de0baf51211c5378149c9e.kmmacros">Improved Title Case Ver 2.2 (Del CB 2X) @JMichaelTX.kmmacros</a> (5.0 KB)

**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---

<img src="/uploads/default/original/2X/a/a730fa5bdee2394186c5e2474082ec6fc367747d.png" width="459" height="681">

Ah. That was my mistake. I was only deleting past clipboard once. Thank you both!

1 Like

For a built-in locale-sensitive variant:

Copy as Title Case.kmmacros (18.7 KB)


JavaScript for Automation source code

$(Application('Keyboard Maestro Engine').getvariable('itcHeadline'))
    .capitalizedStringWithLocale($.NSLocale.currentLocale).js
1 Like

Hey Folks,

I made a minor bug-fix to my script in post 17 above.

-Chris

New & Improved Title Case

The built-in title case filter in Keyboard Maestro distinguishes between "small words" that should not be capitalized and words that should but it doesn't recognize acronyms or handle hashtags and @ words.

Take, for example, these fake headlines:

The sub-report of the ACI committee
C.I.A. Defeats F.B.I. in Smart Softball match-up
Lightroom CC Includes Significant ACR Revisions
OpticsPro takes on lightroom cc and phase one capture one pro
The #MeToo movement gains momentum
Use @SomeoneElse to contact your congressman

This is how the built-in filter applies capitalization:

The Sub-Report of the ACI Committee
CIA Defeats FBI In Smart Softball Match-Up
Lightroom CC Includes Significant ACR Revisions
OpticsPro Takes on Lightroom Cc and Phase One Capture One Pro
The #MeToo Movement Gains Momentum
Use @SomeoneElse to Contact Your Congressman

John Gruber wrote a Perl routine in 2008 to handle title case which was refined that same year by Aristotle Pagaltzis and put in the public doman (https://gist.github.com/gruber/9f9e8650d68b13ce4d78). It applies capitalization to those same headlines like this:

The Sub-Report of the ACI Committee
C.I.A. Defeats F.B.I. In Smart Softball Match-Up
Lightroom CC Includes Significant ACR Revisions
OpticsPro takes on lightroom cc and phase one capture one pro

The main difference is that when the Gruber/Pagaltzis routine detects an acronym, it leaves it alone, although it won't presume one if it's lowercase.

THIS REVISION

In this revision of the Keyboard Maestro macro, we added UTF-8 handling and changed a forced lower-case initial for hastags and @ words to simply leaving them alone (along with file paths).

We also introduced an exception that strips periods from acronymns.

A commented version of the code accompanies the .zip file to make it easier to eliminate that feature or add other exceptions.

USAGE

Select the text you want to convert and type the Hot Key, which has been set to Shift-Option-T. Your selection will be replaced with the capitalized string.

TitleCase.3.zip (4.7 KB)

3 Likes

@mrpasini, I see with your update that you have included the text of your OP, for completeness. Good idea.

I think the time period in which you can update of your OP has passed. Would you like me to replace your OP with this post? OR, at the very least, add a notice/link to your update post so that readers will be aware of the latest update?

Please let me know your preference.

I hadn’t actually thought of updating the original post because there was an ongoing conversation.

I wouldn’t mind disabling the prior two versions in favor of the latest but I didn’t see a way to do that.

The text for the most recent update does restate the issue but adds to it, explaining what’s new, so they aren’t equivalent. But the original is certainly obsolete.

How should I handle this in the future?

So, do you want me to replace your OP with the last update post?

The usual, unofficial, procedure for anything posted in the "Macro Library" is to keep the OP updated to the latest version, unless there is reason to do otherwise. So we usually insert some type of "Updated: date/time" along with Ver: n.nn <Ver Date>

Unfortunately, the original poster is limited to about 1 or 2 months for updating the post.

I have a yellow "updated" image which looks like this:
updated

The source is:

<img src="/uploads/default/original/2X/9/9fa034801953dfe7d1745afcb7087c7530a06e23.gif" width="70" height="17"  alt="updated" title="updated"> 

This utilizes an existing image. Everyone is welcome to use it you like.
Some prefer to just use a heading style, like ### Updated, which looks like this:

Updated

Use whichever you prefer.

9 posts were split to a new topic: Improved Sentence Case Macro

[/quote]

That reply came from my email client (Postbox), which would not know the forum's requirements. Could it be a parsing issue with the forum's software?

I've got a three-liner at the moment that handles the following cases, but the thought occurred to me to run these by you to see if they are what you're dealing with. If not, send me a sample and I'll work it out.

Here are my test cases:

Before: THE FBI SAID IT WAS CONDUCTING FORENSIC TESTING OF TWO-YEAR OLD HASHTAGS.

After: The fbi said it was conducting forensic testing of two-year old hashtags.

Before: This is a sentence... "well, so is this." and this too! but what about this one? that, too.

After: This is a sentence... "Well, so is this." And this too! But what about this one? That, too.

Before: Joseph Grundfest, a commissioner at the S.E.C. in the 1980s and now a professor at Stanford, said he had been contacting current SEC officials and staff to urge them to bring cases, and fast. “it’s more than the extent of the violation,” he said. a spokeswoman for the S.E.C. did not respond to a request for comment.

After: Joseph Grundfest, a commissioner at the S.E.C. in the 1980s and now a professor at Stanford, said he had been contacting current SEC officials and staff to urge them to bring cases, and fast. “It’s more than the extent of the violation,” he said. A spokeswoman for the S.E.C. did not respond to a request for comment.

Yes. I'll do that now.

FYI, this magnificent script is not running correctly since Mojave, unless you disable SIP.

This is according to MacScripters Forum.

I've tried it in Monterey and I get the following error:

Hey Alex,

Quite – Apple deprecated AppleScript scripting additions (OSAX)en in Mojave.

The only way to run them is to disable SIP, and that's not a particularly good idea.

Although I am doing so on Mojave, I will not do that when I move to Monterey (fairly soon).

The good news is that Mark Alldritt (developer of Script Debugger) has come up with a way to use the various Satimage Osaxen on macOS from Mojave to Monterey (and probably beyond – as long as Rosetta is available).

Making the Satimage.osax work on macOS Mojave and beyond.

I'll consider adapting that script to AppleScriptObjC, JavaScript for Automation, Perl, or Python, but it's unlikely that I'll get to it anytime soon.

-Chris