Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/lowmess/lameass.recipes. A recipe site, but without the ads and 3,000 word essays lameass.recipes
nextjs sanity-io theme-ui typescript
Something went wrong. Try again.
489 B · 17 lines
TypeScript
at develop
123456789101112131415161718// Not really smartypants. Just a small subset of that functionality
const smartypants = (str: string): string => { // replace primes in contractions with apostrophes const aposRe = /(\w)[']{1}(\w)/g // replace '--' with em dash const emDashRe = /[-]{2}/g // replace hyphen between numbers with en dash const enDashRe = /(\d){1}[ ]*[-][ ]*(\d){1}/g
return str .replace(aposRe, '$1’$2') .replace(emDashRe, '—') .replace(enDashRe, '$1–$2')}
export default smartypants