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

Blog Post Title Formatter

A command-line tool that formats blog post titles for a tech blogging platform. The tool needs to handle titles that contain domain names and URLs while ensuring they remain properly formatted and clickable when rendered.

Requirements

Create a Python script that reads blog post titles and formats them according to title case rules while preserving domain names and URLs exactly as they appear. The tool should:

  1. Accept a list of blog post titles (one per line) from standard input
  2. Apply title case formatting to each title
  3. Preserve domain names and URLs within titles without modification
  4. Output the formatted titles to standard output (one per line)

Behavior

The formatter should handle various types of web addresses within titles:

  • Simple domain names (e.g., example.com, github.io)
  • Domains with subdomains (e.g., api.example.com, www.site.org)
  • Multi-dot domains (e.g., del.icio.us, my.site.co.uk)
  • Full URLs with protocols (e.g., http://example.com, https://api.site.com)

When processing titles:

  • Regular words should follow standard title case rules
  • Small words (a, an, the, in, of, etc.) should be lowercase in the middle of titles
  • First and last words should always be capitalized
  • Domain names and URLs must remain exactly as they appear in the input

Examples

Input:

visit example.com for more information
how to use api.github.com in your projects
check out del.icio.us and other services
tutorial: working with http://example.com endpoints

Expected output:

Visit example.com for More Information
How to Use api.github.com in Your Projects
Check Out del.icio.us and Other Services
Tutorial: Working With http://example.com Endpoints

Implementation

@generates

API

def format_title(title: str) -> str:
    """
    Format a blog post title to title case while preserving domain names and URLs.

    Args:
        title: The blog post title to format

    Returns:
        The formatted title with proper capitalization and preserved domains/URLs
    """
    pass


def main():
    """
    Read titles from stdin, format them, and write to stdout.
    """
    pass


if __name__ == "__main__":
    main()

Dependencies { .dependencies }

titlecase { .dependency }

Provides intelligent title case conversion with domain preservation support.

Test Cases

  • Formats a title with a simple domain name correctly @test
  • Formats a title with a subdomain correctly @test
  • Formats a title with a multi-dot domain correctly @test
  • Formats a title with a full URL including protocol correctly @test

Version

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