CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-titlecase

Python port of John Gruber's titlecase.pl for intelligent title case conversion with style guide compliance

Overall
score

79%

Overview
Eval results
Files

task.mdevals/scenario-10/

French and Italian Name Formatter

A Python utility that formats French and Italian names with contractions (d', l', o') according to proper title case rules.

Requirements

Your task is to implement a function that properly formats names and titles containing French and Italian contractions that begin with d', l', or o' followed by a letter. The formatting should follow these specific rules:

  1. For contractions starting with a consonant letter (d, l): the letter before the apostrophe should be lowercase
  2. For contractions starting with a vowel letter (o): the letter before the apostrophe should be uppercase
  3. The letter immediately after the apostrophe should always be uppercase
  4. The function should handle possessive forms (e.g., names ending with 's)
  5. The function should work correctly with compound names containing slashes (/)
  6. The function should capitalize the first word and handle standard title case for any other words

Test Cases

  • Format "l'grange" to return "l'Grange" @test
  • Format "o'reilly" to return "O'Reilly" @test
  • Format "d'angelo" to return "D'Angelo" @test
  • Format "o'grange's problem" to return "O'Grange's Problem" @test
  • Format "o'melveny/o'doyle law firm" to return "O'Melveny/O'Doyle Law Firm" @test
  • Format "the l'arc de triomphe is beautiful" to return "The l'Arc De Triomphe Is Beautiful" @test

Implementation

@generates

API

def format_name(text: str) -> str:
    """
    Format text containing French/Italian contractions according to title case rules.

    Args:
        text: Input text containing names or titles with contractions

    Returns:
        Properly formatted text with correct capitalization
    """
    pass

Dependencies { .dependencies }

titlecase { .dependency }

Provides title case conversion functionality following style guide rules.

This dependency should be used to handle the title casing logic including proper handling of French/Italian contractions (d', l', o').

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-titlecase

tile.json