ap-style-title-case

Convert a string to title case using AP Stylebook rules

Usage no npm install needed!

<script type="module">
  import apStyleTitleCase from 'https://cdn.skypack.dev/ap-style-title-case';
</script>

README

ap-style-title-case

Build Downloads Size

Convert a value to title case using AP/APA style.

Install

npm:

npm install ap-style-title-case

Use

var titleCase = require('ap-style-title-case')

console.log(titleCase('why sunless tanning is A hot trend'))
// 'Why Sunless Tanning Is a Hot Trend'

API

apStyleTitleCase(value[, options])

Convert a value (string) to title case (string) using AP/APA style.

  • options.keepSpaces (boolean, default: false) — Superfluous whitespace is ignored by default, turn this on to allow it
  • options.stopwords (Array.<string>, default: see list below) — Lowercase the given stop words instead of the defaults

The Rules

  • Always capitalize the first word, even if it’s a stop word
  • Always capitalize the last word, even if it’s a stop word
  • Lowercase these words: a an and at but by for in nor of on or so the to up yet

Many writers make the error of leaving “to be” verbs in lower case. Even though “is,” “are,” “was,” and “be,” are all short words, they should still be capitalized in a title because they are verbs.

When you write titles that contain prepositions, your word processor will likely tell you that you should leave words like “with,” “about,” and “around” lowercase. Defiantly look past the squiggly line indicating a potential error, and remember that in AP title case, prepositions with four or more letters should be capitalized.

These rules are the exact same for APA style, the only difference being that AP style does not recommend the use of title case for newspaper headlines, but rather sentence case.

References

License

MIT © Zeke Sikelianos