|
43 | 43 | // Name case Mcs and Macs |
44 | 44 | // Exclude names with 1-2 letters after prefix like Mack, Macky, Mace |
45 | 45 | // Exclude names ending in a,c,i,o, or j are typically Polish or Italian |
46 | | - |
47 | 46 | if (new RegExp(/\bMac[A-Za-z]{2,}[^aciozj]\b/).test(el) || |
48 | 47 | new RegExp(/\bMc/).test(el)) { |
49 | 48 |
|
|
87 | 86 | // And correct Mac exceptions otherwise missed |
88 | 87 | el = el |
89 | 88 | .replace(/\bMacmurdo/, "MacMurdo") |
90 | | - .replace(/\bMacisaac/, "MacIsaac"); |
| 89 | + .replace(/\bMacisaac/, "MacIsaac") |
91 | 90 |
|
92 | 91 |
|
93 | 92 | // Fixes for "son (daughter) of" etc. in various languages. |
94 | | - el = el |
95 | 93 | .replace(/\bAl(?=\s+\w)/g, "al") // al Arabic or forename Al. |
96 | 94 | .replace(/\bAp\b/g, "ap") // ap Welsh. |
97 | 95 | .replace(/\bBen(?=\s+\w)\b/g, "ben") // ben Hebrew or forename Ben. |
|
102 | 100 | .replace(/\bLa\b/g, "la") // la French |
103 | 101 | .replace(/\bL([eo])\b/g, "l$1") // lo Italian; le French. |
104 | 102 | .replace(/\bVan(?=\s+\w)/g, "van") // van German or forename Van. |
105 | | - .replace(/\bVon\b/g, "von"); // von Dutch/Flemish |
| 103 | + .replace(/\bVon\b/g, "von") // von Dutch/Flemish |
106 | 104 |
|
107 | 105 |
|
108 | 106 | // Fixes for roman numeral names, e.g. Henry VIII |
109 | | - el = el.replace(/\b(?:\d{4}|(?:[IVX])(?:X{0,3}I{0,3}|X{0,2}VI{0,3}|X{0,2}I?[VX]))$/i, |
110 | | - function (v) { |
111 | | - return v.toUpperCase(); |
112 | | - }); |
| 107 | + .replace(/\b(?:\d{4}|(?:[IVX])(?:X{0,3}I{0,3}|X{0,2}VI{0,3}|X{0,2}I?[VX]))$/i, |
| 108 | + function (v) { |
| 109 | + return v.toUpperCase(); |
| 110 | + }) |
113 | 111 |
|
114 | 112 |
|
115 | 113 | // Nation of Islam 2X, 3X, etc. names |
116 | | - el = el.replace(/\b[0-9](x)\b/, function (v) { return v.toUpperCase(); } ); |
| 114 | + .replace(/\b[0-9](x)\b/, function (v) { return v.toUpperCase(); } ) |
| 115 | + |
| 116 | + |
117 | 117 | // Somewhat arbitrary rule where two letter combos not containing vowels should be capitalized |
118 | 118 | // fixes /JJ Abrams/ and /JD Salinger/ |
119 | 119 | // With some exceptions |
|
134 | 134 | .replace(/\bY\s/g, "y"); |
135 | 135 |
|
136 | 136 | return el; |
137 | | - } |
| 137 | + }; |
138 | 138 |
|
139 | 139 |
|
140 | 140 | if (typeof exports !== 'undefined') { |
|
0 commit comments