CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-titlecase

tessl install tessl/pypi-titlecase@2.4.0

Python 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%

task.mdevals/scenario-8/

Title Case Formatter with Flexible First/Last Word Rules

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).

Requirements

Core Functionality

Your utility should provide a function format_title(text, capitalize_first_last=True) that:

  1. Converts text to title case following standard rules for small words
  2. When capitalize_first_last=True (default), always capitalizes the first and last words regardless of whether they are small words
  3. When capitalize_first_last=False, allows small words to remain lowercase even at the beginning or end of the title

Test Cases

  • Given the text "a tale of two cities", with capitalize_first_last=True, returns "A Tale of Two Cities" @test
  • Given the text "a tale of two cities", with capitalize_first_last=False, returns "a Tale of Two Cities" @test
  • Given the text "the lord of the rings", with capitalize_first_last=True, returns "The Lord of the Rings" @test
  • Given the text "the lord of the rings", with capitalize_first_last=False, returns "the Lord of the Rings" @test

Implementation

@generates

API

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
    """
    pass

Dependencies { .dependencies }

titlecase { .dependency }

Provides intelligent title case conversion following style guide rules.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/titlecase@2.4.x
tile.json