Skip to content

A capitalised apostrophe name is split into two words: "O'Neil".ToSnakeCase() → "o_neil", but "o'neil" and "O'NEIL" → "oneil" #96

Description

@matt-edmondson

What's wrong

Commit 5c15077 (#83) keeps an in-word apostrophe from splitting a word in Pascal, Camel, Snake, Kebab and Macro. That only works when the letter after the apostrophe is lowercase. When it is uppercase, as in the usual spelling of names like "O'Neil" and "D'Angelo", the word is still split.

Reproduced (net10.0):

Input Pascal Camel Snake Kebab Macro Title
O'Neil ONeil oNeil o_neil o-neil O_NEIL O'neil
o'neil Oneil oneil oneil oneil ONEIL
O'NEIL Oneil oneil
D'Angelo d_angelo
d'angelo dangelo
Don'T don_t Don't

Expected: O'Neil gives Oneil, oneil, oneil, oneil and ONEIL. That matches o'neil and O'NEIL, and matches ToTitleCase, which already treats it as the one word "O'neil".

Why it happens

In CaseConverter/CaseConverter.cs:

  1. ReplaceNonAlphaNumericWithSpace / IsApostropheWithinWord (~lines 42–82) drop the in-word apostrophe, so "O'Neil" becomes "ONeil".
  2. SplitOnCaseChange / IsWordBoundary (~lines 109–171) then run on the joined text. The acronym-tail rule (upper, upper, then lower, ~lines 151–153) breaks before the "N".
  3. The "don't split after an apostrophe" check (~lines 156–158) can never fire, because the apostrophe is already gone by then.

Why it matters

Suggested fix

Either of these:

  • When an in-word apostrophe is dropped, lowercase the letter that follows it, so no case transition is left behind.
  • Or run the case-change split while the apostrophe is still in the string, and treat letter + ' + letter as a single word. The rule at ~line 158 already declines to break after an apostrophe.

Acceptance criteria

  • "O'Neil" and "Don'T" produce the same Pascal/Camel/Snake/Kebab/Macro output as their lowercase spellings.
  • Data rows for both are added beside the existing "o'neil" row in CaseConverterTests.cs (~line 412).

Activity

  1. matt-edmondson commented on Sep 28, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Notes: The second suggested fix (split while the apostrophe is still present) is the more robust one, because it also makes the existing rule at ~line 158 reachable.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingreadyFully specified; implement as written

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions