smartquotes
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "smartquotes", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "Kelly Martin", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -39,3 +39,3 @@ (function (root, factory) { | ||
.replace(/'''/g, '\u2034') // triple prime | ||
.replace(/(\W|^)"(\S+)/g, '$1\u201c$2') // beginning " | ||
.replace(/(\W|^)"(\w)/g, '$1\u201c$2') // beginning " | ||
.replace(/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2') // ending " | ||
@@ -46,5 +46,5 @@ .replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word | ||
.replace(/([a-z])'([a-z])/ig, '$1\u2019$2') // conjunction's possession | ||
.replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93 | ||
.replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // ending ' | ||
.replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93 | ||
.replace(/(\B|^)\u2018(?=([^\u2018\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe | ||
.replace(/(\B|^)\u2018(?=([^\u2018\u2019]*\u2019\b)*([^\u2018\u2019]*\B\W[\u2018\u2019]\b|[^\u2018\u2019]*$))/ig, '$1\u2019') // backwards apostrophe | ||
.replace(/"/g, '\u2033') // double prime | ||
@@ -51,0 +51,0 @@ .replace(/'/g, '\u2032'); // prime |
@@ -5,18 +5,28 @@ var jsdom = require('jsdom'); | ||
test('smartquotes.string()', function (t) { | ||
// a list of test strings and expected converted values | ||
var expectations = { | ||
'"test"': '\u201ctest\u201d', | ||
'the\u2014 "test"': 'the\u2014 \u201ctest\u201d', | ||
'\'test\'': '\u2018test\u2019', | ||
'ma\'am': 'ma\u2019am', | ||
'\'em': '\u2019em', | ||
'Marshiness of \'Ammercloth\'s': 'Marshiness of \u2019Ammercloth\u2019s', | ||
'\'95': '\u201995', | ||
'\'\'\'': '\u2034', | ||
'\'\'': '\u2033', | ||
'"Better than a 6\'5" whale."': '\u201cBetter than a 6\u20325\u2033 whale.\u201d', | ||
'"It\'s my \'#1\' choice!" - 12" Foam Finger from \'93': '\u201cIt\u2019s my \u2018#1\u2019 choice!\u201d - 12\u2033 Foam Finger from \u201993', | ||
'"Say \'what?\'" says a Mill\'s Pet Barn employee.': '\u201cSay \u2018what?\u2019\u201d says a Mill\u2019s Pet Barn employee.', | ||
'"Quote?": Description': '\u201cQuote?\u201d: Description', | ||
'\'Quo Te?\': Description': '\u2018Quo Te?\u2019: Description', | ||
'"De Poesjes van Kevin?": Something, something': '\u201cDe Poesjes van Kevin?\u201d: Something, something', | ||
'And then she blurted, "I thought you said, \'I don\'t like \'80s music\'?"': "And then she blurted, \u201cI thought you said, \u2018I don\u2019t like \u201980s music\u2019?\u201d" | ||
}; | ||
test('smartquotes.string()', (t) => { | ||
var s = smartquotes.string; | ||
t.equal(s('"test"'), '\u201ctest\u201d'); | ||
t.equal(s('the\u2014 "test"'), 'the\u2014 \u201ctest\u201d'); | ||
t.equal(s('\'test\''), '\u2018test\u2019'); | ||
t.equal(s('ma\'am'), 'ma\u2019am'); | ||
t.equal(s('\'em'), '\u2019em'); | ||
t.equal(s('Marshiness of \'Ammercloth\'s'), 'Marshiness of \u2019Ammercloth\u2019s'); | ||
t.equal(s('\'95'), '\u201995'); | ||
t.equal(s('\'\'\''), '\u2034'); | ||
t.equal(s('\'\''), '\u2033'); | ||
t.equal(s('"Better than a 6\'5" whale."'), '\u201cBetter than a 6\u20325\u2033 whale.\u201d'); | ||
t.equal(s('"It\'s my \'#1\' choice!" - 12" Foam Finger from \'93'), '\u201cIt\u2019s my \u2018#1\u2019 choice!\u201d - 12\u2033 Foam Finger from \u201993'); | ||
t.equal(s('"Say \'what?\'" says a Mill\'s Pet Barn employee.'), '\u201cSay \u2018what?\u2019\u201d says a Mill\u2019s Pet Barn employee.'); | ||
t.equal(s('"Quote?": Description'), '\u201cQuote?\u201d: Description'); | ||
t.equal(s('\'Quote?\': Description'), '\u2018Quote?\u2019: Description'); | ||
Object.keys(expectations).forEach((string) => { | ||
t.equal(s(string), expectations[string]); | ||
}); | ||
@@ -27,3 +37,3 @@ // All synchronous, no need for t.plan() | ||
test('smartquotes.element()', function (t) { | ||
test('smartquotes.element()', (t) => { | ||
t.plan(3); | ||
@@ -30,0 +40,0 @@ |
Sorry, the diff of this file is not supported yet
35539
172