tessl install tessl/pypi-titlecase@2.4.0Python port of John Gruber's titlecase.pl for intelligent title case conversion with style guide compliance
Agent Success
Agent success rate when using this tile
79%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.92x
Baseline
Agent success rate without this tile
86%
Build a text formatting utility that can apply different capitalization rules to titles based on context. The utility should support both standard title case (where first and last words are always capitalized) and relaxed title case (where small words can remain lowercase even at the beginning or end).
Your utility should provide a function format_title(text, capitalize_first_last=True) that:
capitalize_first_last=True (default), always capitalizes the first and last words regardless of whether they are small wordscapitalize_first_last=False, allows small words to remain lowercase even at the beginning or end of the titlecapitalize_first_last=True, returns "A Tale of Two Cities" @testcapitalize_first_last=False, returns "a Tale of Two Cities" @testcapitalize_first_last=True, returns "The Lord of the Rings" @testcapitalize_first_last=False, returns "the Lord of the Rings" @test@generates
def format_title(text: str, capitalize_first_last: bool = True) -> str:
"""
Format text as title case with configurable first/last word capitalization.
Args:
text: The input text to format
capitalize_first_last: If True, always capitalize first and last words.
If False, allow small words to remain lowercase.
Returns:
The formatted title string
"""
passProvides intelligent title case conversion following style guide rules.