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

Hyphenated Phrase Formatter

Build a text processing utility that properly formats hyphenated compound phrases for publication headers and titles. The utility should handle various hyphenated constructions while maintaining grammatical correctness.

Requirements

The system should process hyphenated phrases according to these rules:

  1. Each word component in a hyphenated phrase should be capitalized appropriately
  2. Grammatically minor words (articles, prepositions, conjunctions) within hyphenated phrases should remain lowercase when they appear in middle positions
  3. The first and last components of a hyphenated phrase should always be capitalized
  4. The processing should handle nested structures like multiple hyphens in a single phrase

Examples

The utility should transform text as follows:

  • Input: "state-of-the-art technology" Output: "State-of-the-Art Technology"

  • Input: "one-on-one meeting" Output: "One-on-One Meeting"

  • Input: "mother-in-law's advice" Output: "Mother-in-Law's Advice"

  • Input: "end-to-end solution" Output: "End-to-End Solution"

Implementation

@generates

Implement a function that processes text containing hyphenated phrases and returns the properly formatted result.

Test Cases

  • Processing a hyphenated phrase with small words in the middle produces correct capitalization @test
  • Processing multiple hyphenated phrases in a single sentence works correctly @test
  • The first word component in a hyphenated phrase is always capitalized @test
  • The last word component in a hyphenated phrase is always capitalized @test

Dependencies { .dependencies }

titlecase { .dependency }

Provides text formatting and title casing functionality following style guide rules.

Install with Tessl CLI

npx tessl i tessl/pypi-titlecase

tile.json