Skip to content

fix: prevent spurious space before capitals inside quotes#84

Open
jmooring wants to merge 1 commit into
gobuffalo:mainfrom
jmooring:fix/humanize-quotes-83
Open

fix: prevent spurious space before capitals inside quotes#84
jmooring wants to merge 1 commit into
gobuffalo:mainfrom
jmooring:fix/humanize-quotes-83

Conversation

@jmooring

Copy link
Copy Markdown

When toParts encountered an uppercase letter following punctuation (e.g. a quotation mark), it incorrectly split the punctuation and the letter into separate parts. Joining those parts with spaces then produced an erroneous space, e.g. Humanize(`a "B"`) returned A " B" instead of A "B".

The fix adds a guard to the split-on-uppercase logic: the split is skipped when the current accumulation buffer contains both space-like characters and non-space characters. This situation arises when a quotation mark (or similar punctuation) follows a word boundary; the uppercase letter that follows is the first letter of a quoted word and should remain attached to the surrounding punctuation.

The guard preserves all existing behavour:

  • camelCase splitting (x has only letters, no space)
  • identifier separators like _ - : (x has only space-like chars)
  • leading punctuation like !@# before a word (x has no space)

Closes #83

When toParts encountered an uppercase letter following punctuation (e.g.
a quotation mark), it incorrectly split the punctuation and the letter
into separate parts. Joining those parts with spaces then produced an
erroneous space, e.g. Humanize(`a "B"`) returned `A " B"` instead
of `A "B"`.

The fix adds a guard to the split-on-uppercase logic: the split is
skipped when the current accumulation buffer contains both space-like
characters and non-space characters. This situation arises when a
quotation mark (or similar punctuation) follows a word boundary; the
uppercase letter that follows is the first letter of a quoted word and
should remain attached to the surrounding punctuation.

The guard preserves all existing behaviour:
- camelCase splitting (x has only letters, no space)
- identifier separators like _ - : (x has only space-like chars)
- leading punctuation like !@# before a word (x has no space)

Closes gobuffalo#83

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

bug: Humanize inserts erroneous space before capital letters inside quotes

1 participant