summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-09-16 12:23:43 +0100
committerMichael Williamson <mike@zwobble.org>2016-09-16 12:24:23 +0100
commitd16d3a010c5386775f189b0309268ba1e45810fb (patch)
tree856fdef758ba5e963c3fa5470a25e2c9d4eb760d
parent206843c9f701a3e62ba7c45b07173471b6309870 (diff)
Ignore blank lines in style map
-rw-r--r--NEWS4
-rw-r--r--lib/options-reader.js6
-rw-r--r--test/options-reader.tests.js7
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",