Skip to main content

Python Port of John Gruber's titlecase.pl

Project description

This filter changes all words to Title Caps, and attempts to be clever about SMALL words like a/an/the in the input.

The list of “SMALL words” which are not capped comes from the New York Times Manual of Style, plus some others like ‘vs’ and ‘v’.

This is a resurrection of Stuart Colville’s titlecase.py, which was in turn a port of John Gruber’s titlecase.pl.

Issues, updates, pull requests, etc should be directed to github.

Installation

The easiest method is to simply use pip:

(sudo) pip install titlecase

Usage

Titlecase provides only one function, simply:

>>> from titlecase import titlecase
>>> titlecase('a thing')
'A Thing'

A callback function may also be supplied, which will be called for every word:

>>> def abbreviations(word, **kwargs):
...   if word.upper() in ('TCP', 'UDP'):
...     return word.upper()
...
>>> titlecase.titlecase('a simple tcp and udp wrapper', callback=abbreviations)
'A Simple TCP and UDP Wrapper'

The callback function is supplied with an all_caps keyword argument, indicating whether the entire line of text was entirely capitalized. Returning None from the callback function will allow titlecase to process the word as normal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

titlecase-0.7.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

titlecase-0.7.2.macosx-10.9-x86_64.exe (69.6 kB view details)

Uploaded Source

File details

Details for the file titlecase-0.7.2.tar.gz.

File metadata

  • Download URL: titlecase-0.7.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for titlecase-0.7.2.tar.gz
Algorithm Hash digest
SHA256 1979b829043b4c69f4e1b6d252e885803cb389b788a97628b67422fff6f801fb
MD5 d771ad0ee4d812dd4c5d17596210f347
BLAKE2b-256 50d5652480b64a3c188a69c13ddbb395e576d2e1552e470b98c2c317848517d6

See more details on using hashes here.

File details

Details for the file titlecase-0.7.2.macosx-10.9-x86_64.exe.

File metadata

File hashes

Hashes for titlecase-0.7.2.macosx-10.9-x86_64.exe
Algorithm Hash digest
SHA256 e8240bd4bd3aef4c7e15493cedcbd01f3a2a628d960cae0a33cb54302add854e
MD5 752613a96946ac2ff27bda56cde08253
BLAKE2b-256 e4f94516e063841a135137aba330c8cd154bb0c28c3223a0b64f0a3f0529e324

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page