Skip to content

Split a capitalised word after a capital followed by ß or a ligature [patch] - #141

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/140-inherit-case-in-acronym-rule
Nov 4, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/140-inherit-case-in-acronym-rule

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #140

What changed

  • Some lowercase letters have no uppercase form, such as ß and the ligatures like ff. The An all-caps word containing ß is split into bogus words, so ToMacroCase isn't idempotent: "straße" → "STRAßE" → "STR_Aß_E" #87 fix made each one take the case of the nearest cased letter before it, but only the capitalised-word rule used that. The acronym-tail rule (XMLDoc → XML Doc) in IsWordBoundary still used a plain char.IsUpper check, so after Off, Xß or GROß a capitalised word never started a new word.
  • That rule now treats such a letter as uppercase when the nearest cased letter before it is uppercase. This is done in a new InheritsUppercase helper that mirrors EndsWordThatIsNotUppercase.
  • This differs slightly from the suggestion in the issue, which counted the letter as uppercase whenever EndsWordThatIsNotUppercase returned false. That would also have split a ligature that has no cased letter before it, such as fiDoc → fi Doc. That case is unchanged here, and a test pins it.
input before after
"off switch".ToPascalCase().ToPascalCase() Offswitch OffSwitch
"the off state".ToPascalCase().ToSnakeCase() the_offstate the_off_state
"aßBar".ToPascalCase() Aßbar AßBar
"GROßBar".ToSnakeCase() großbar groß_bar

Tests

  • ToPascalCaseShouldBeIdempotentAfterACapitalFollowedByLettersWithNoUppercaseForm: runs the rows from the issue, covering both ß and ff, through PascalCase and camelCase twice.
  • ACapitalisedWordAfterAnUppercaseRunEndingInSharpSOrALigatureShouldSplit: checks the expected outputs from the acceptance criteria.
  • ALigatureWithNoCasedLetterBeforeItShouldNotSplitFromTheCapitalAfterIt: guards the fiDoc case.

Without the source change, four of the new cases fail. With it, the full suite passes locally (216 tests, 0 failures).

Note: open PR #139 also edits CaseConverter.cs, so whichever of the two merges second may need a rebase.


Generated by Claude Code

…[patch]

A lowercase letter with no uppercase form, such as ß or ff, takes the
case of the nearest cased letter before it. That inheritance was applied
to the capitalised-word rule but not to the acronym-tail rule, so after
"Off", "Xß" or "GROß" a capitalised word was never split off. PascalCase
output then changed when converted again ("OffSwitch" became
"Offswitch"), and "GROßBar".ToSnakeCase() gave "großbar".

The acronym-tail rule now treats such a letter as uppercase when the
nearest cased letter before it is uppercase. With no cased letter
before it, as in "fiDoc", nothing changes.

Fixes #140

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5wGJLhri3KXBeZJwH
Resolves the conflict in IsWordBoundary with #139 and #143. The
inherited uppercase of a letter with no uppercase form is now looked up
only before a capital, the same way #139 made the cased-next scan lazy.
Looked up at every code point, it walked back over a long run of such
letters each time and failed LongRunOfLowercaseWithNoUppercaseConvertsInLinearTime.

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

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 23d57f3 into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/140-inherit-case-in-acronym-rule branch November 4, 2026 02:02
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.

ToPascalCase merges the next word after a capital followed by "ß" or a ligature ("off switch" → "OffSwitch" → "Offswitch")

2 participants