Expand description

titlecase capitlizes English text according to a style defined by John Gruber for post titles on his website Daring Fireball.

Example

use titlecase::titlecase;

let text = "a sample title to capitalize: an example";
assert_eq!(titlecase(text), "A Sample Title to Capitalize: An Example");

Style

Instead of simply capitalizing each word it does the following (amongst other things):

  • Lower case small words like an, of, or in.
  • Don’t capitalize words like iPhone.
  • Don’t interfere with file paths, URLs, domains, and email addresses.
  • Always capitalize the first and last words, even if they are small words or surrounded by quotes.
  • Don’t interfere with terms like “Q&A”, or “AT&T”.
  • Capitalize small words after a colon.

Functions

Returns input in title case.