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

Text Formatter with Dash Delimiter Support

Overview

Build a text formatting tool that processes multi-part titles containing various types of dash delimiters. The tool should properly capitalize text segments separated by different dash characters commonly used in typography.

Requirements

Your implementation should:

  1. Process dash-delimited titles: Accept text input containing different Unicode dash characters as segment separators
  2. Handle multiple dash types: Support the following dash characters:
    • Hyphen-minus: - (U+002D)
    • En dash: (U+2013)
    • Figure dash: (U+2012)
    • Em dash: (U+2014)
    • Horizontal bar: (U+2015)
  3. Capitalize after dashes: Ensure that the first word following any dash delimiter is properly capitalized
  4. Preserve dash characters: Maintain the original dash type in the output

Test Cases

Basic Dash Handling { .section }

@test Input: "episode 7 — the force awakens" Expected output: Properly capitalize "the" after the em dash

@test Input: "new york – london flight" Expected output: Properly capitalize "london" after the en dash

Multiple Dash Types { .section }

@test Input: "part one — introduction: part two – the story begins" Expected output: Handle both em dash and en dash correctly, capitalizing words after each

Implementation Notes

  • Focus on correctly identifying and handling different dash types as phrase delimiters
  • The solution should work with Unicode text processing
  • Test your implementation with the provided test cases

Deliverables

  1. formatter.py - Main implementation file containing the text formatting logic
  2. tests.py - Test file with test cases demonstrating correct dash handling

Dependencies { .dependencies }

titlecase { .dependency }

Provides intelligent title case conversion with support for various punctuation marks and delimiters.

Install with Tessl CLI

npx tessl i tessl/pypi-titlecase

tile.json