@lifeparticle/ap-style-title-case
v1.5.0
Published
AP style title case
Downloads
81
Maintainers
Readme
This project is inspired by ap-style-title-case.
Install
npm i @lifeparticle/ap-style-title-case
Use
React
import apCase from "@lifeparticle/ap-style-title-case";
import "./App.css";
import { useState } from "react";
function App() {
const [title, setTitle] = useState("");
return (
<div>
<input type="text" onChange={(e) => setTitle(apCase(e.target.value))} />
<input type="text" value={title} />
</div>
);
}
export default App;
Test
npm i --save-dev jest
npm test
Algorithm
- Capitalize first word of the title
- Capitalize last word of the title
- Don't capitalize these words
"a","an","and","as","at","but","by","for","if","in","nor","of","off","on","or","per","so","the","to","up","via","yet"
- Capitalize other words
Resources
- https://www.bkacontent.com/how-to-correctly-use-apa-style-title-case/
- https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case