diff --git a/lib/dox.js b/lib/dox.js index 24cdbe22..ae3b0d7e 100644 --- a/lib/dox.js +++ b/lib/dox.js @@ -124,7 +124,10 @@ exports.parseComments = function(js, options){ } else if (withinSingle && !withinMultiline && '\n' == js[i]) { withinSingle = false; buf += js[i]; - } else if (!withinSingle && !withinMultiline && ('\'' == js[i] || '"' == js[i])) { + } else if ( + !withinSingle && !withinMultiline && ('\'' == js[i] || '"' == js[i]) && + !('\\' == js[i] && '\'' == js[i+1]) && !('\\' == js[i-1] && '\'' == js[i]) + ) { withinString = !withinString; buf += js[i]; } else { diff --git a/test/dox.test.js b/test/dox.test.js index b47b933a..3f05c14d 100644 --- a/test/dox.test.js +++ b/test/dox.test.js @@ -924,5 +924,13 @@ module.exports = { comments[1].tags[0].description.should.equal("

Invalid argument.

"); done(); }); + }, + + 'can properly handle escaped single quotes': function (done) { + fixture('error.js', function (err, str) { + var comments = dox.parseComments(str); + comments.length.should.equal(2); + done(); + }) } }; diff --git a/test/fixtures/error.js b/test/fixtures/error.js new file mode 100644 index 00000000..7947c40b --- /dev/null +++ b/test/fixtures/error.js @@ -0,0 +1,16 @@ +/** + * Thrower - description + * + * @class Thrower + */ +function Thrower () { + throw new Error('Something hasn\'t been defined.'); +} + + +/** + * anonymous function - description + * + * @return {type} description + */ +Thrower.prototype.foo = function () {};