Plugin "Start Case" ignores all caps, and periods

Hi there,


Middle column is plugin → lowercase
Right column is plugin → start case

There’s 2 bugs here (pardon me if it’s a feature)

First, when I tried to just use plugin → start case, I noticed that ALL CAPS words were not formatting properly. Meaning, ELTWINE should be Eltwine, but it comes out as ELTWINE instead.

So I did a workaround by having 2 plugins and that works.

Except for the 2nd bug at the last line. The periods disappeared from the rightmost column. Lowercase is fine though. I guess it treats the periods as indicators to start a new capital letter but I think if there’s no spacing between the letters and the periods, the periods shouldn’t function as a break. Ideally, I would like the final formatting to be Monster.com.sg Pte Ltd.

Thanks for the help!

Interesting that it removes punctuation. I wonder if AI column would do a better job.

I think in some cases, people want to keep certain words as uppercase if your input is uppercase, say “LTD”. The code Glide wrote here seems to be using that approach.

The second one indeed looks like a bug.

I think this would work for you at the moment.

await import("https://cdn.jsdelivr.net/npm/@gouch/to-title-case@2.2.1/to-title-case.min.js");

return p1.toLowerCase().toTitleCase()

The package is a bit more intelligent in terms of what words to capitalize and what not. They don’t capitalize words like “a”, “the”, “of” whilst the native start case does.

4 Likes

Is this multilingual?

When I tried Vietnamese, both approaches don’t work.

1 Like

Thanks!

Tried it ad it mostly works except for the monster line at the bottom

Please try this. I added a list of words to exclude so you can be more flexible.

const toTitleCase = str => str.toLowerCase().split(' ').map((word, index) => {
    if (index === 0 || !['of', 'a', 'an', 'the', 'and', 'but', 'or', 'for', 'nor', 'on', 'at', 'to', 'from', 'by', 'over'].includes(word)) {
        return word.charAt(0).toUpperCase() + word.slice(1);
    } else {
        return word;
    }
}).join(' ');

const result = toTitleCase(p1);
return result; 

1 Like

It works! But there’s a weird error though. But it works

That’s not an error. That’s how the column behaves.

So I’d just ignore the “Function Error” part ya. Thank you it works well!

1 Like

Try editing, for example, by adding a space and the message will disappear. But it will appear again if you open it again.
You’re welcome

Maybe you just need to handle the empty cases before the function above. Try something like:

if(!p1) {
return "";
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.