From 101026fe3c4f3bfb479d75119b6831e3dc815b52 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 21 Sep 2012 14:52:47 -0400 Subject: [PATCH] Fix parsing of selectors with comments between elements. This brings over cloudhead/less.js@3331637913 and fixes #179 --- lib/carto/parser.js | 2 ++ test/rendering/weird_comments_2.mml | 14 ++++++++++++++ test/rendering/weird_comments_2.mss | 7 +++++++ test/rendering/weird_comments_2.result | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 test/rendering/weird_comments_2.mml create mode 100644 test/rendering/weird_comments_2.mss create mode 100644 test/rendering/weird_comments_2.result diff --git a/lib/carto/parser.js b/lib/carto/parser.js index ed1566f..0c7ed4b 100644 --- a/lib/carto/parser.js +++ b/lib/carto/parser.js @@ -690,7 +690,9 @@ carto.Parser = function Parser(env) { while (s = $(this.selector)) { selectors.push(s); + $(this.comment); if (! $(',')) { break; } + $(this.comment); } if (s) $(this.comment); diff --git a/test/rendering/weird_comments_2.mml b/test/rendering/weird_comments_2.mml new file mode 100644 index 0000000..d3acc85 --- /dev/null +++ b/test/rendering/weird_comments_2.mml @@ -0,0 +1,14 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "weird_comments_2.mss" + ], + "Layer": [{ + "name": "world", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Datasource": { + "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", + "type": "shape" + } + }] +} diff --git a/test/rendering/weird_comments_2.mss b/test/rendering/weird_comments_2.mss new file mode 100644 index 0000000..0be9deb --- /dev/null +++ b/test/rendering/weird_comments_2.mss @@ -0,0 +1,7 @@ +#world { + [ne_10m_adm = 'GBR'], /* United Kingdom */ + [ne_10m_adm = 'FRA'] /* France */ + { + polygon-fill: #fff; + } +} diff --git a/test/rendering/weird_comments_2.result b/test/rendering/weird_comments_2.result new file mode 100644 index 0000000..904bc8a --- /dev/null +++ b/test/rendering/weird_comments_2.result @@ -0,0 +1,25 @@ + + + + + + + + world + + + + + + +