diff --git a/lib/text-parse.js b/lib/text-parse.js index dd9c3a4..793579f 100644 --- a/lib/text-parse.js +++ b/lib/text-parse.js @@ -21,7 +21,7 @@ module.exports = function (options) { // splits the paragraph at end of sentence punctuation self.paragraphToSentences = function (paragraph) { paragraph = paragraph.trim(); - var sentences = paragraph.match( /[^\.!\?]+[\.!\?(?="|')]+(\s|$)/g ); + var sentences = paragraph.match( /[^\.!\?]+[\.!\?(?="|')]+(\s|$)/g ) || [ paragraph ]; return { raw: paragraph, type: 'paragraph', diff --git a/test/text-parse.js b/test/text-parse.js index 8cff79a..8b50cbd 100644 --- a/test/text-parse.js +++ b/test/text-parse.js @@ -99,6 +99,12 @@ describe('lib/text-parse', function() { paragraph.length.should.eql(3); }); + + it('should handle sentences which don\'t contain closing punctiation', function() { + var text = parser.textToParagraphs('This is a paragraph without a period, question, or exclamation'); + + text.length.should.eql(1); + }); }); // checking that it parses the paragraph correctly