Skip to content

Keep a titlecase digraph after an apostrophe in its word [patch] - #168

Merged
matt-edmondson merged 4 commits into
mainfrom
fix/titlecase-digraph-after-apostrophe-167
Nov 11, 2026
Merged

matt-edmondson merged 4 commits into
mainfrom
fix/titlecase-digraph-after-apostrophe-167

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #167

What was wrong

"a'Džemal" (U+01C5) snaked to a_džemal and macro-cased to A_DŽEMAL. The two-letter spelling "a'Džemal" gives adžemal. l'Ljubljana had the same problem.

IsCapitalAfterApostropheInLowercaseContext called char.IsUpper on the letter after the apostrophe. That returns false for a titlecase digraph (category Lt), so the O'Neil rule never lowered the letter. SplitOnCaseChange then saw a change from lowercase to titlecase and broke the word there.

Change

The check now uses IsUpperOrTitlecase, the same helper SplitOnCaseChange has used since #158. LowercaseIf already maps Dž→dž, so nothing else needed to change.

Input Pascal snake macro
a'Džemal Adžemal adžemal ADŽEMAL
l'Ljubljana / l’Ljubljana Lljubljana lljubljana LLJUBLJANA

The issue also asked about the char.IsUpper(input, previousLetterStart) test that sets uppercaseSuffix. I checked Dž's against Dž's, and ADŽ's against ADŽ's. Both pairs already give matching words, so I left that test alone.

Tests

  • New: ATitlecaseDigraphAfterAnApostropheShouldStayInTheWord. Each row checks Pascal, camel, snake, kebab and MACRO, plus Pascal→snake round-trip.
    • Rows: a'Džemal, l'Ljubljana, and l’Ljubljana (U+2019).
    • Control row: the two-letter a'Džemal.
  • On unfixed main, the three digraph rows fail and the control row passes.
  • Full suite on Linux / .NET 10: 277/277 passed. dotnet build CaseConverter.sln gives 0 warnings and 0 errors.

The open PRs #160, #162 and #163 also edit the apostrophe path in CaseConverter.cs, but not this line. Whichever lands last may need a trivial rebase.


Generated by Claude Code

"a'Džemal" snaked to "a_džemal" while the two-letter spelling "a'Džemal"
gives "adžemal". IsCapitalAfterApostropheInLowercaseContext tested
char.IsUpper on the letter after the apostrophe, which is false for a
titlecase digraph (category Lt), so the O'Neil rule never lowered it.
SplitOnCaseChange then saw a lowercase-to-titlecase change and broke the
word. The test now uses IsUpperOrTitlecase, as SplitOnCaseChange has since
#158, so "a'Džemal" and "l'Ljubljana" give the same words as their
two-letter spellings in every converter.

Fixes #167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us
Resolve the test-file conflict with #169: both added a test method at the end of the class, so keep both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us
#169 widened the condition that uppercases a suffix onto the capital
before an in-word apostrophe, which took ReplaceNonAlphaNumericWithSpace
to a cognitive complexity of 17 (Sonar S3776, limit 15) and fails the
quality gate. The condition now lives in IsSuffixUppercasedOntoCapital;
behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us
#163 already moved the apostrophe-suffix condition into UppercasesSuffix, which
resolves the same S3776 complexity finding, so take main's line and drop the
now-unused IsSuffixUppercasedOntoCapital helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us
@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.

A titlecase digraph after an in-word apostrophe still splits the word: "a'Džemal" snakes to a_džemal, though "a'Džemal" gives adžemal

2 participants