typescript version of smartquotes.js.
smart quotes are smart typography, and now it’s just a ’script away.
you can grab smartquotes-ts
from npm (or pnpm, or yarn):
npm install smartquotes-ts
import it, then pass in a string or use the string
method. both work the same:
import smartquotes from 'smartquotes-ts';
const myString = smartquotes.string('This is the "same" thing.');
“smart quotes” or “curly quotes” are the correct typographical way to show quotes. dumb quotes (straight quotes) were invented to save space on the keyboard, but they’re pretty ugly. smartquotes-ts
fixes all those dumb quotes for you automatically.
because they're the right way to do it. they make your text more readable and professional. dumb quotes? they’re for lazy coding, and you don’t want that. now you’ve got no excuse not to use smart quotes.
measurements use “primes” instead of quotes. smartquotes-ts
handles that for you too.
technically, when you shorten a word at the beginning, you need a backwards apostrophe. smartquotes-ts
does its best to catch these, like in years (’13) or places (the ’burbs). if it misses, just use ’
or wrap it in a <span>
tag to force it.
nope. smartquotes-ts
has zero dependencies. you can drop it into your project and it works on its own.
if you find bugs or improvements, fork the repo, make your changes (don’t touch the version numbers), and open a pull request. make sure you add any needed tests and run npm test
before opening the PR.