Python port of John Gruber's titlecase.pl for intelligent title case conversion with style guide compliance
Overall
score
79%
A text formatting utility that converts compound phrases and names to proper title case according to journalistic style guidelines.
@generates
def format_title(text: str) -> str:
"""
Convert text to title case with proper handling of compound constructions.
Handles:
- Hyphenated compounds (e.g., "end-to-end" -> "End-to-End")
- Slash-separated phrases (e.g., "yes/no" -> "Yes/No")
- Scottish/Irish names with Mac/Mc prefixes (e.g., "mcdonald" -> "McDonald")
- Combined patterns requiring nested processing
Small words (a, an, and, as, at, but, by, en, for, if, in, of, on, or,
the, to, v, v., via, vs, vs.) remain lowercase in middle positions of
compound constructions.
Args:
text: The input text to format
Returns:
The text formatted in title case
"""
passProvides title case conversion following journalistic style guidelines.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-titlecasedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10