From d16d3a010c5386775f189b0309268ba1e45810fb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 16 Sep 2016 12:23:43 +0100 Subject: Ignore blank lines in style map --- NEWS | 4 ++++ lib/options-reader.js | 6 +++--- test/options-reader.tests.js | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 9f06d54..eedb309 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +# 1.2.2 + +* Ignore blank lines in style map. + # 1.2.1 * Use alt text title as alt text for images when the alt text description is diff --git a/lib/options-reader.js b/lib/options-reader.js index 3765fd3..dc17fe8 100644 --- a/lib/options-reader.js +++ b/lib/options-reader.js @@ -75,11 +75,11 @@ function readCustomStyleMap(styleMap) { return []; } else if (_.isString(styleMap)) { return styleMap.split("\n") - .filter(function(line) { - return line.charAt(0) !== "#"; - }) .map(function(line) { return line.trim(); + }) + .filter(function(line) { + return line !== "" && line.charAt(0) !== "#"; }); } else { return styleMap; diff --git a/test/options-reader.tests.js b/test/options-reader.tests.js index 06e0764..b0f202b 100644 --- a/test/options-reader.tests.js +++ b/test/options-reader.tests.js @@ -38,6 +38,13 @@ test('lines starting with # in custom style map are ignored', function() { assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); }); +test('blank lines in custom style map are ignored', function() { + var options = readOptions({ + styleMap: "\n\n" + }); + assert.deepEqual(standardOptions.styleMap, options.styleMap); +}); + test('default style mappings are ignored if includeDefaultStyleMap is false', function() { var options = readOptions({ styleMap: "p.SectionTitle => h2", -- cgit v1.2.3