wezm / titlecase

A tool and Rust crate for transforming text into Title Case.
https://7bit.org/titlecase/
Other
88 stars 3 forks source link

Doesn't lowercase small words #6

Closed q3cpma closed 2 years ago

q3cpma commented 2 years ago

For example

$ echo 'Way Of The Dragon' | titlecase
Way Of The Dragon
wezm commented 2 years ago

Well that's embarrassing, thanks for the bug report. Can't believe I don't have a test case for that, despite the behaviour being mentioned in the README. The code looks like it's trying to do it:

https://github.com/wezm/titlecase/blob/93667678ed18f2b8b4762cfa838070bb014d391c/src/lib.rs#L115-L116

But I suspect the \A and \z in SMALL_RE are not right.

https://github.com/wezm/titlecase/blob/93667678ed18f2b8b4762cfa838070bb014d391c/src/lib.rs#L81

q3cpma commented 2 years ago

On Tue Aug 30, 2022 at 1:20 AM CEST, Wesley Moore wrote:

Well that's embarrassing, thanks for the bug report. Can't believe I don't have a test case for that, despite the behaviour being mentioned in the README. The code looks like it's trying to do it:

https://github.com/wezm/titlecase/blob/93667678ed18f2b8b4762cfa838070bb014d391c/src/lib.rs#L115-L116

But I suspect the \A and \z in SMALL_RE are not right.

Having tried to do it by myself, I suspect you need lookbehind/lookahead constraints if you want to do it with regexp, which Rust don't have. So, a manual scanner may be needed.

wezm commented 2 years ago

Published v2.1.0 with a fix for this.

q3cpma commented 2 years ago

On Tue Aug 30, 2022 at 2:22 PM CEST, Wesley Moore wrote:

Published v2.1.0 with a fix for this.

Thanks.