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.
Command Line Usage
Titlecase also provides a command line utility titlecase:
$ titlecase make me a title Make Me a Title $ echo "Can pipe and/or whatever else" | titlecase Can Pipe and/or Whatever Else # Or read/write files: $ titlecase -f infile -o outfile
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file titlecase-0.10.0.tar.gz
.
File metadata
- Download URL: titlecase-0.10.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f14115d3d56bcbf48c8c26f8ffb9c97321ac1968c762ee88319ab4942fa461b |
|
MD5 | 41a9ff91aac2cce49cbb6398ad1767b3 |
|
BLAKE2b-256 | 02106f19117f81910e6a35cfc4e9f520ca81ace4dfa79c23e1509ccf2b27ab01 |
File details
Details for the file titlecase-0.10.0-py2-none-any.whl
.
File metadata
- Download URL: titlecase-0.10.0-py2-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58e658713d24e474c6d21c37bb497b7b1369ff0ceae71c9fd23c773e188f63b8 |
|
MD5 | 12201d6230ca96947313e720960037b9 |
|
BLAKE2b-256 | b3e56d0729aaa7b177341064d9c60bde9738740f7ff4cf6efa16d5a867f70cde |