2 // convert nbsp to regular space
4 // line-breaks after slashes (for long URLs etc.)
10 [/([\s([]|^)"([^\s?!.,;\/)])/g, '$1\u201c$2'],
12 [/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2'],
13 // remaining " at end of word
14 [/([^0-9])"/g, '$1\u201d'],
16 [/"(.+?)"/g, '\u201c$1\u201d'],
17 // double prime as two single quotes
20 [/(\W|^)'(\S)/g, '$1\u2018$2'],
21 // conjunction's possession
22 [/([a-z])'([a-z])/ig, '$1\u2019$2'],
23 // abbrev. years like '93
24 [/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3'],
26 [/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3'],
27 // backwards apostrophe
28 [/(\B|^)\u2018(?=([^\u2018\u2019]*\u2019\b)*([^\u2018\u2019]*\B\W[\u2018\u2019]\b|[^\u2018\u2019]*$))/ig, '$1\u2019'],
34 // turn a hyphen surrounded by spaces, between words, into an em-dash
35 [/([a-z\u201d]) - ([a-z\u201c])/ig, '$1\u2014$2'],
36 // turn a hyphen between a space and a quote, into an em-dash
37 [/([a-z]) -(\u201d)/ig, '$1\u2014$2'],
38 [/(\u201c)- ([a-z])/ig, '$1\u2014$2'],
39 // turn a double or triple hyphen, optionally surrounded by spaces, between words, or at the start of a line, into an em-dash
40 [/([a-z"'“”‘’]|\n) ?---? ?([a-z"'“”‘’])/ig, '$1\u2014$2'],
42 // Two spaces after a period is INCORRECT.
43 [ /(\w[\.\?\!])[ \u00a0]{2}(\w)/g, '$1 $2'],
45 // ellipsis rectification
46 [/(\s)\.\.\./g, '$1…'],
47 [/\.\.\.(\s)/g, '…$1'],
49 // Hyphen followed by a numeral (with an optional space first), becomes an actual minus sign
50 [/(\s)-( ?)([0-9])/g, '$1\u2212$2$3'],
53 [/(\s)->(\s)/g, '$1\u2192$2'],
54 [/(\s)<-(\s)/g, '$1\u2190$2'],
55 [/(\s)=>(\s)/g, '$1\u21d2$2'],
56 [/(\s)<=(\s)/g, '$1\u21d0$2'],
57 [/(\s)<=>(\s)/g, '$1\u21d4$2']