Compare commits

...

6 Commits

Author SHA1 Message Date
Sandro Santilli e175c70785 Set version to 0.9.5-cdb3
11 years ago
Sandro Santilli 835aeb6add Do not assume instaceof of Function have a "call" method
11 years ago
Sandro Santilli 3c215873ef Set version to 0.9.5-cdb2
11 years ago
Sandro Santilli a997e4159a Support exponential notation in filter values
11 years ago
Sandro Santilli 4995b9da2b Set version to 0.9.5-cdb1
11 years ago
Sandro Santilli 2ddef7a6fe Fix escaping of single quote. Closes #307, updates tests.
11 years ago

@ -46,7 +46,7 @@ carto.Parser = function Parser(env) {
var match, args, length, c, index, endIndex, k; var match, args, length, c, index, endIndex, k;
// Non-terminal // Non-terminal
if (tok instanceof Function) { if (tok.call) {
return tok.call(parser.parsers); return tok.call(parser.parsers);
// Terminal // Terminal
// Either match a single character in the input, // Either match a single character in the input,
@ -462,7 +462,7 @@ carto.Parser = function Parser(env) {
dimension: function() { dimension: function() {
var c = input.charCodeAt(i); var c = input.charCodeAt(i);
if ((c > 57 || c < 45) || c === 47) return; if ((c > 57 || c < 45) || c === 47) return;
var value = $(/^(-?\d*\.?\d+)(\%|\w+)?/); var value = $(/^(-?\d*\.?\d+(?:[eE][-+]?\d+)?)(\%|\w+)?/);
if (value) { if (value) {
return new tree.Dimension(value[1], value[2], memo); return new tree.Dimension(value[1], value[2], memo);
} }

@ -10,7 +10,7 @@ tree.Quoted.prototype = {
toString: function(quotes) { toString: function(quotes) {
var xmlvalue = this.value var xmlvalue = this.value
.replace(/&/g, '&amp;') .replace(/&/g, '&amp;')
.replace(/\'/g, '&apos;') .replace(/\'/g, '\\\'')
.replace(/\"/g, '&quot;') .replace(/\"/g, '&quot;')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/\>/g, '&gt;'); .replace(/\>/g, '&gt;');

@ -1,6 +1,6 @@
{ {
"name": "carto", "name": "carto",
"version": "0.9.5", "version": "0.9.5-cdb3",
"description": "Mapnik Stylesheet Compiler", "description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto", "url": "https://github.com/mapbox/carto",
"repository": { "repository": {

@ -17,7 +17,7 @@ describe('Quoted', function() {
it('should produce xml-friendly output', function() { it('should produce xml-friendly output', function() {
var f = new tree.Quoted("Tom's & \"<quoted>\""); var f = new tree.Quoted("Tom's & \"<quoted>\"");
assert.ok(f); assert.ok(f);
assert.equal(f.toString(true), "'Tom&apos;s &amp; &quot;&lt;quoted&gt;&quot;'"); assert.equal(f.toString(true), "'Tom\\'s &amp; &quot;&lt;quoted&gt;&quot;'");
}); });
}); });
}); });

@ -0,0 +1,15 @@
{
"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": [
"filterexp.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"
}
}]
}

@ -0,0 +1 @@
#world [a = 1.2e3][b = 1.2e-3][c = 1.2e+3] { polygon-fill:#fff; }

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map 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" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
<Style name="world" filter-mode="first">
<Rule>
<Filter>([a] = 1200) and ([b] = 0.0012) and ([c] = 1200)</Filter>
<PolygonSymbolizer fill="#ffffff" />
</Rule>
</Style>
<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">
<StyleName>world</StyleName>
<Datasource>
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
<Parameter name="type"><![CDATA[shape]]></Parameter>
</Datasource>
</Layer>
</Map>

@ -5,7 +5,7 @@
<Style name="world" filter-mode="first"> <Style name="world" filter-mode="first">
<Rule> <Rule>
<Filter>([name2] = ' Sa&apos;ad')</Filter> <Filter>([name2] = ' Sa\'ad')</Filter>
<PolygonSymbolizer fill="#ffffff" /> <PolygonSymbolizer fill="#ffffff" />
</Rule> </Rule>
</Style> </Style>

Loading…
Cancel
Save