Closed magikstm closed 1 year ago
I have a fix and a test case for it.
I'll submit a PR.
@magikstm Nice work!
I will add that the current title
filter indiscriminately capitalizes every word in the input. I can't speak for languages other than English, but there are certain words which should not be capitalized in a title.
i.e.
{{ "Examining Steiner's theorem and its consequences for physics" | title }}
should yield
Examining Steiner's Theorem and Its Consequences for Physics
For reference, this is a Javascript implementation of a titlecase function that considers these edge cases.
@eh8
Adding a similar feature as the linked javascript:
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i
Would be out of scope of the current feature.
I'm unsure if it should be added or not. It's only in english and it is "opiniated" on which words are or aren't capitalized.
Yeah, let's not add something English-specific. If people want that, they can add their own for their language.
With this input: {{ "Steiner's theorem" | title }}
Current result is: Steiner'S Theorem
Expected result is: Steiner's Theorem
First mentioned here: https://zola.discourse.group/t/title-case-filter-with-apostrophes/1526
Can be reproduced here: https://tera.netlify.app/playground/