#22323 closed Bug (worksforme)

Title Filter Inproper Casing of Words With Apostrophe in Second Position

Reported by: jenkinsbr2 Owned by: jenkinsbr2
Component: Template system Version: 1.6
Severity: Normal Keywords: title filter
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I discovered a very minor edge case when using the title filter on words that have an apostrophe in the second position.
Ex: I'm, I'll, I'd, etc.

The current wrapper for Python's .title uses a regex that matches [a-z]'[A-Z] which will result in something such as I'Ll not being corrected.

I propose simply using a non-capturing look behind such as (?<=[a-zA-Z])'[A-Z]. While a solution with Unicode support would be nicer, as far as I can tell it's not really feasible with Python's current re implementation. I've made this change and written an additional test that covers this edge case that I can submit as a pull request if there's no side effects I've overlooked.

Change History (1)

comment:1 Changed 18 months ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

This proposal has been made in the past; marking wontfix because it's almost impossible to implement.

The search for a completely accurate capitalisation is a tarpit. To pick an easy example - your scheme would break when capitalising the Italian name d'Angelo. The current scheme has known flaws, but is simple to explain, draws from a well known implementation (Python's title() method on strings). Any alternate scheme will also have flaws, but they'll be flaws of our own making, and our own responsibility to fix.

Note: See TracTickets for help on using tickets.
Back to Top