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-3/

Article Title Formatter

A utility that converts text strings into proper title case format following journalistic style guidelines.

@generates

Capabilities

Title Case Conversion

Converts strings to title case where most words are capitalized, but certain small words remain lowercase when they appear in the middle of the title.

  • Converting "this is a test" returns "This Is a Test" @test
  • Converting "small word at end is nothing to be afraid of" returns "Small Word at End Is Nothing to Be Afraid Of" @test
  • Converting "the quick brown fox" returns "The Quick Brown Fox" @test

First and Last Word Capitalization

Ensures the first and last words of a title are always capitalized, even if they are typically considered small words.

  • Converting "a tale of two cities" returns "A Tale of Two Cities" @test
  • Converting "nothing to be afraid of" returns "Nothing to Be Afraid Of" @test

Punctuation-Aware Formatting

Capitalizes words that follow subphrase punctuation like colons, question marks, and exclamation marks.

  • Converting "starting with a small word: a trick" returns "Starting With a Small Word: A Trick" @test
  • Converting "what is this: the answer" returns "What Is This: The Answer" @test

API

def format_title(text: str) -> str:
    """
    Converts a text string to title case following journalistic style guidelines.

    Small words (a, an, and, as, at, but, by, en, for, if, in, of, on, or,
    the, to, v, v., via, vs, vs.) are kept lowercase when they appear in the
    middle of the title. The first and last words are always capitalized.
    Words following colons, question marks, exclamation marks, and similar
    punctuation are capitalized.

    Args:
        text: The input string to convert to title case

    Returns:
        The text converted to proper title case format

    Examples:
        format_title("this is a test")
        # Returns: "This Is a Test"

        format_title("question: what happens?")
        # Returns: "Question: What Happens?"
    """
    pass

Dependencies { .dependencies }

titlecase { .dependency }

Provides title case conversion functionality following style guide rules.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-titlecase

tile.json