Closed qcho closed 5 years ago
All the functions in the library are language-agnostic. The second function parameter was introduced to solve this problem.
As you can see in the fiddle Resig's implementation is not perfect either.
It is impossible to include in the library the language specific words that remain lower-cased (e.g. a, an, for, etc).
If you're interested in a more advanced version of title case function, feel free to use https://github.com/gouch/to-title-case.
Hi,
The Title Case implementation doesn't follow proper rules for this case. In the original feature-request #21 these rules where explained but it seems somehow they didn't go into the implementation.
A description of those rules can be seen on: https://www.bkacontent.com/how-to-correctly-use-apa-style-title-case/
Here is an example from New York Times. (More in the fiddle)
Expected behavior :smile_cat:
From Obama and Baker, a Lament for a Lost Consensus
Actual behavior :crying_cat_face:
From Obama And Baker, A Lament For A Lost Consensus
Steps to reproduce :construction_worker:
I've created this fiddle: https://jsfiddle.net/Qcho86/h97y0vfq/
Technical details: :wrench:
Here is a reference implementation by John Resig, the creator of jQuery. https://johnresig.com/blog/title-capitalization-in-javascript/ https://johnresig.com/files/titleCaps.js
As you can see in the fiddle Resig's implementation is not perfect either.
From that page a list of edge cases to take into account: https://daringfireball.net/projects/titlecase/examples-edge-cases