coaching newsletter contact

Converting Drafts Text to Title Case

Drafts is easily one of the most used apps on my phone. To me, it is the pinnacle of resistance-free digital capture. If I look through my list of processed drafts, the most common forms of text I capture are content ideas and book suggestions. This tells me I read, write, and record a lot.

I like my placeholders for these new ideas to be uniform. In this case that means each content idea - whether it's a blog post idea or a new video - is captured as the title I would use for the content itself.

But let's be serious, I hate hitting the shift key at the beginning of every new word and I'm terrible at remembering which words should be capitalized and which should remain lowercase.

Knowing the power of Drafts, I asked if it were possible for my capture tool to handle this for me. That question led me to an article about title case and JavaScript by the always excellent Dr. Drang.

Using his script as a base, this is what I landed on:

var small = "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)";
var punct = "([!\"#$%&'()+,./:;<=>?@[\\\]^_`{|}~-])";

this.titleCaps = function(title){
    var parts = [], split = /[:.;?!] |(?: |^)["Ò]/g, index = 0;

    while (true) {
        var m = split.exec(title);

        parts.push( title.substring(index, m ? m.index : title.length)
            .replace(/\b([A-Za-z][a-z.'Õ]*)\b/g, function(all){
                return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : upper(all);
            })
            .replace(RegExp("\\b" + small + "\\b", "ig"), lower)
            .replace(RegExp("^" + punct + small + "\\b", "ig"), function(all, punct, word){
                return punct + upper(word);
            })
            .replace(RegExp("\\b" + small + punct + "$", "ig"), upper));

        index = split.lastIndex;

        if ( m ) parts.push( m[0] );
        else break;
    }

    return parts.join("").replace(/ V(s?)\. /ig, " v$1. ")
        .replace(/(['Õ])S\b/ig, "$1s")
        .replace(/\b(AT&T|Q&A)\b/ig, function(all){
            return all.toUpperCase();
        });
};

function lower(word){
    return word.toLowerCase();
}

function upper(word){
  return word.substr(0,1).toUpperCase() + word.substr(1);
}

draft.content = titleCaps(draft.content);
commit(draft);

To install it, click here.

From a practical standpoint, I set this up as an action key so I can use it easily. Now, all I do is type the idea, hit TI above the keyboard, and then action it off to where belongs.

Thu, Oct 13, 2016 07:00pm CDT https://bhlg.us/4jn1
#drafts

Want to see my August 2020 Bullet Journal setup?

Join 1,514 subscribers!

I'll send you the link to a six-minute overview video of my August 2020 spreads when you sign up for my newsletter, The Weekly Impulse.

Site Analytics

I use Fathom Analytics on this site because I care about your privacy. And if you ever want to see the stats collected and the data I see, check out the live analytics here.

Amazon Affiliate

joebuhlig.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means to earn fees when linking to Amazon.com and affiliated sites.

Disclaimer

Disclosure of Material Connection: Some of the links in the post above might be “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”

an analog mind in a digital world

👋 I'm Joe Buhlig. I strive to build productivity systems that stand the test of time and help me do more than check boxes. I'm here to help you do the same.

🎙 I read a lot of books and talk about it.

🐿 I can't focus on one thing for long, so I write a lot of code for an eclectic grouping of projects.

📓 And I'm a bit obsessed with finding non-proprietary solutions to digital problems. Thus, text files for the win! 🎉

MN U.S.A 1986-09-30
  • all
  • articles
  • code
  • likes
  • notes
  • photos
  • replies
  • reposts
  • steps
  • videos
coaching newsletter contact
© 2014-2025 by Joe Buhlig