Skip to content

Keep a plural's "s" in the word after a digit and an apostrophe [patch] - #155

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/154-digit-apostrophe
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/154-digit-apostrophe

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #154

What changes

  • IsApostropheWithinWord now treats an apostrophe as in-word when a letter or a digit comes before it, as long as a letter still follows. "the 1990's" now gives snake the_1990s and Pascal The1990s, where it used to give the_1990_s and The1990S.
  • LowercaseLettersAfterDigits also lowercases a letter that follows a digit and an apostrophe. This undoes TextInfo.ToTitleCase treating that letter as a word start, so Title case gives The 1990's rather than The 1990'S. It works for both ' and U+2019.

Behaviour change to an existing test

ApostropheNotBetweenLettersShouldStillSeparateWords asserted "80's music" → "80_s_music", which is exactly the split the issue calls a bug. That row now lives in the new test with the expected value 80s_music. The other rows in that test ('quoted' word, rock 'n' roll) are unchanged and still pass.

Tests

  • New ApostropheAfterADigitShouldNotSplitTheWord covers the 1990's, the 90’s (U+2019), 4's and 5's, 1990's and 80's music. Each case checks Title, Pascal, camel, snake and MACRO, plus a snake round trip through Pascal and through Title.
  • With the source change reverted, all five cases fail. With it applied, the full suite passes: 214 of 214 on net10.0.
  • The existing apostrophe tests (it's, API's, o'NEIL, and so on) still pass.

Note

Several open CaseConverter PRs also edit CaseConverter.cs (#139 to #153). This branch starts from current main and doesn't depend on any of them. Whichever merges later may need a trivial rebase.


Generated by Claude Code

An apostrophe counted as in-word only between two letters, so "the 1990's"
split into "the_1990_s" and Title case gave "The 1990'S". A digit before the
apostrophe now counts too, and Title case lowers the letter after a digit and
an apostrophe the same way it lowers one directly after a digit.

Fixes #154

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6ERvyATBYDH9pPgb7
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An apostrophe after a digit splits off the "s": "the 1990's" → Title "The 1990'S", snake "the_1990_s", Pascal "The1990S"

2 participants