Snippet: Uppercase first letter of each line

By email:

Feature request:

An extension that upper cases the first word of each sentence and line, but leaves the rest of the letters alone. Sentence Case doesn’t work for this because it changes everything else to lower case, and also doesn’t uppercase the first word of a line. One use case: if I have a list and I want to capitalize each item. Maybe it should be called Poetry Case?

Example, from:

list item A
list item B
list item C

To:

List item A
List item B
List item C

My solution

#popclip
name: Poetry Case
icon: PC
after: paste-result
javascript: |
  const regex = /(^[^\p{L}]*\p{L}{1})/gum 
  return popclip.input.text.replace(regex, match => match.toUpperCase())

(The above block is an extension snippet - select it to install the extension with PopClip)

Notes

  • Had some trouble thinking of a good icon…
  • The regex looks quite imposing. It matches everything up to and including the first letter character (\p{L}) of each line. Note that the u flag on the regex is needed to enable this \p{} construction, and the m flag makes ^ match the start of lines. I used https://regex101.com/r/FxemMU/1 to test the regex

Demo
CleanShot 2022-11-01 at 12.56.33

1 Like

Is there a quill icon? Could work for poetry

1 Like

Not in Apple Symbols but I did look :slight_smile:

I’d like to bring more built-in icons to PopClip for more possibilities.

1 Like