From ccc04767be2252b9212e595ae1cc7b2bf0df803e Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Thu, 7 Mar 2013 23:48:31 +1300 Subject: [PATCH] handle edgecase --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f61acfa..d2eb59b 100644 --- a/index.js +++ b/index.js @@ -9,11 +9,11 @@ module.exports = function (text) { sections.push(section.join('\n')) } text.split('\n').forEach(function (line) { - if(/^#/.test(line)) { // new section + if(/^\s*#/.test(line)) { // new section add() section = [] } - section.push(line) + (section = section || []).push(line) }) //add the last section