{"_id":"@mapbox/carto","_rev":"307-42c248845ea3956b2282add98fc89a7c","name":"@mapbox/carto","description":"Mapnik Stylesheet Compiler","dist-tags":{"latest":"0.16.3"},"versions":{"0.16.3":{"name":"@mapbox/carto","version":"0.16.3","description":"Mapnik Stylesheet Compiler","url":"https://github.com/mapbox/carto","repository":{"type":"git","url":"git+ssh://git@github.com/mapbox/carto.git"},"author":{"name":"Mapbox","email":"info@mapbox.com","url":"http://mapbox.com/"},"keywords":["mapnik","maps","css","stylesheets"],"contributors":[{"name":"Tom MacWright","email":"macwright@gmail.com"},{"name":"Konstantin Käfer"},{"name":"Alexis Sellier","email":"self@cloudhead.net"}],"license":"Apache-2.0","bin":{"carto":"./bin/carto"},"man":["./man/carto.1"],"main":"./lib/carto/index","engines":{"node":">=0.4.x"},"dependencies":{"chroma-js":"~1.2.1","hsluv":"~0.0.1","js-yaml":"~3.7.0","lodash":"~4.17.2","mapnik-reference":"~8.5.5","semver":"~5.3.0","yargs":"~6.5.0"},"devDependencies":{"coveralls":"~2.11.15","istanbul":"~0.4.5","mocha":"~3.2.0","mocha-eslint":"^3.0.1","sax":"~1.2.1"},"scripts":{"pretest":"npm install && mocha -R spec --timeout 50000 -f jslint","test":"mocha -R spec --timeout 50000 -i -f jslint","coverage":"istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info"},"gitHead":"ddb92f2c00a9ba4e2569808c13959b12300f3828","bugs":{"url":"https://github.com/mapbox/carto/issues"},"homepage":"https://github.com/mapbox/carto#readme","_id":"@mapbox/carto@0.16.3","_shasum":"ce139c21856c36f329e6b16bc58c8e49597f8613","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"tmcw","email":"tom@macwright.org"},"dist":{"shasum":"ce139c21856c36f329e6b16bc58c8e49597f8613","tarball":"https://registry.npmjs.org/@mapbox/carto/-/carto-0.16.3.tgz","integrity":"sha512-MqKXwPxMAn7TO4IQ1Y1bfJeE0LPAWXz75JYB/E0uegQpGN4bAbt2ENT086a34QHndqO3/NQwdwCcIkxg+97S1Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE/SBll0rh+S6IolKmX4ajjKlSQS/x4Y+zTD79lU3oGzAiBP43nOKUfwvEMwqjOoH6fH8sPGMMxbOj2mYbfiqsz5sA=="}]},"maintainers":[{"name":"tmcw","email":"tom@macwright.org"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/carto-0.16.3.tgz_1482372541160_0.6007563679013401"},"directories":{}}},"readme":"# CartoCSS\n\n[![Build Status](https://secure.travis-ci.org/mapbox/carto.svg)](http://travis-ci.org/mapbox/carto) [![Build status](https://ci.appveyor.com/api/projects/status/github/mapbox/carto?svg=true)](https://ci.appveyor.com/project/Mapbox/carto) [![Coverage Status](https://coveralls.io/repos/github/mapbox/carto/badge.svg?branch=master)](https://coveralls.io/github/mapbox/carto?branch=master) [![Package Version](https://img.shields.io/npm/v/carto.svg)](https://www.npmjs.com/package/carto)\n\nIs the language for map design used by [Mapbox Studio Classic](http://mapbox.com/mapbox-studio-classic/). It is similar in syntax to CSS, but builds upon it with specific abilities to filter map data and by providing things like variables.\n\nCarto, aka CartoCSS, targets the [Mapnik renderer](http://mapnik.org) and is able to generate Mapnik XML.\n\nCarto is an evolution of the [Cascadenik](https://github.com/mapnik/Cascadenik) idea and language,\nwith an emphasis on speed and flexibility. If you are a previous user of Cascadenik, see the [key differences wiki](https://github.com/mapbox/carto/wiki/Differences-With-Cascadenik).\n\n## Documentation\n\nFor users looking to learn how to use Mapbox Studio Classic the best places to start are to 1) Download [Mapbox Studio Classic](https://www.mapbox.com/mapbox-studio-classic/) and review the [Carto reference documentation](https://github.com/mapbox/carto/blob/master/docs/latest.md).\n\nTutorials like the [Mapbox Getting started with CartoCSS guide](https://www.mapbox.com/guides/getting-started-cartocss/) are a great place to start to learn the basics of CartoCSS.\n\nFor more advanced topics see the [Studio style quickstart guide](https://www.mapbox.com/guides/style-quickstart/) and [Studio style manual](https://www.mapbox.com/guides/style-manual). The links below reference the Tilemill application, which preceded Mapbox Studio Classic, but still contain useful and relevant information.\n\n - [Details on Filtering data with CartoCSS](https://www.mapbox.com/tilemill/docs/guides/selectors/)\n - [How order works in rendering](https://www.mapbox.com/tilemill/docs/guides/symbol-drawing-order/)\n - [How to style labels](https://www.mapbox.com/tilemill/docs/guides/styling-labels/)\n - [How to style lines](https://www.mapbox.com/tilemill/docs/guides/styling-lines/)\n - [How to style polygons](https://www.mapbox.com/tilemill/docs/guides/styling-polygons/)\n - See also the [Styling Concepts](#styling-concepts) for explanations of advanced features.\n\n## Developers\n\nFor details about how to install Carto from source and use on the command line see the [Installation section](#installation).\n\n## Styling Concepts\n\n### Attachments and Instances\n\nIn CSS, a certain object can only have one instance of a property. A `<div>` has a specific border width and color, rules that match better than others (#id instead of .class) override previous definitions. `CartoCSS` acts the same way normally for the sake of familiarity and organization, but Mapnik itself is more powerful.\n\nLayers in Mapnik can have multiple [borders](http://trac.mapnik.org/wiki/LineSymbolizer) and multiple copies of other attributes. This ability is useful in drawing line outlines, like in the case of road borders or 'glow' effects around coasts. `CartoCSS` makes this accessible by allowing attachments to styles:\n\n```css\n#world {\n  line-color: #fff;\n  line-width: 3;\n}\n\n#world::outline {\n  line-color: #000;\n  line-width: 6;\n}\n```\n\nAttachments are optional.\n\nWhile attachments allow creating implicit \"layers\" with the same data, using **instances** allows you to create multiple symbolizers in the same style/layer:\n\n```css\n#roads {\n  casing/line-width: 6;\n  casing/line-color: #333;\n  line-width: 4;\n  line-color: #666;\n}\n```\n\nThis makes Mapnik first draw the line of color #333 with a width of 6, and then immediately afterwards, it draws the same line again with width 4 and color #666. Contrast that to attachments: Mapnik would first draw all casings before proceeding to the actual lines.\n\n## Variables & Expressions\n\nCartoCSS inherits from its basis in [less.js](http://lesscss.org/) some new features in CSS. One can define variables in stylesheets, and use expressions to modify them.\n\n```css\n@mybackground: #2B4D2D;\n\nMap {\n  background-color: @mybackground\n}\n\n#world {\n  polygon-fill: @mybackground + #222;\n  line-color: darken(@mybackground, 10%);\n}\n```\n\n## Nested Styles\n\nCartoCSS also inherits nesting of rules from less.js.\n\n```css\n/* Applies to all layers with .land class */\n.land {\n  line-color: #ccc;\n  line-width: 0.5;\n  polygon-fill: #eee;\n  /* Applies to #lakes.land */\n  #lakes {\n    polygon-fill: #000;\n  }\n}\n```\n\nThis can be a convenient way to group style changes by zoom level:\n\n```css\n[zoom > 1] {\n  /* Applies to all layers at zoom > 1 */\n  polygon-gamma: 0.3;\n  #world {\n    polygon-fill: #323;\n  }\n  #lakes {\n    polygon-fill: #144;\n  }\n}\n```\n\n## FontSets\n\nBy defining multiple fonts in a `text-face-name` definition, you create [FontSets](http://trac.mapnik.org/wiki/FontSet) in `CartoCSS`. These are useful for supporting multiple character sets and fallback fonts for distributed styles.\n\n<table>\n  <tr>\n    <th>carto</th><th>XML</th>\n    </tr>\n    <tr>\n    <td valign='top'>\n\n    <pre>#world {\n  text-name: \"[NAME]\";\n  text-size: 11;\n  text-face-name: \"Georgia Regular\", \"Arial Italic\";\n}</pre>\n\n</td>\n<td valign='top'>\n<pre>&lt;FontSet name=&quot;fontset-0&quot;&gt;\n  &lt;Font face-name=&quot;Georgia Regular&quot;/&gt;\n  &lt;Font face-name=&quot;Arial Italic&quot;/&gt;\n&lt;/FontSet&gt;\n&lt;Style name=&quot;world-text&quot;&gt;\n  &lt;Rule&gt;\n    &lt;TextSymbolizer fontset-name=&quot;fontset-0&quot;\n      size=&quot;11&quot;\n      name=&quot;[NAME]&quot;/&gt;\n  &lt;/Rule&gt;\n&lt;/Style&gt;</pre>\n</td>\n<tr>\n</table>\n\n## Filters\n\nCartoCSS supports a variety of filter styles:\n\nNumeric comparisons:\n\n```\n#world[population > 100]\n#world[population < 100]\n#world[population >= 100]\n#world[population <= 100]\n```\n\nGeneral comparisons:\n\n```\n#world[population = 100]\n#world[population != 100]\n```\n\n\nString comparisons:\n\n```\n/* a regular expression over name */\n#world[name =~ \"A.*\"]\n```\n\n#### Installation\n\nIf you're using [Mapbox Studio Classic](http://mapbox.com/mapbox-studio/), you're already\nusing CartoCSS and don't need to do a thing.\n\nIf you're a developer-type and want to use the `carto` binary with\n`node.js` (and you have [npm](http://npmjs.org/) installed),\n\n    npm install -g carto\n\nOptionally you may also want to install millstone which is required for resolving data in the same way as Mapbox Studio Classic does:\n\n    npm install -g millstone\n\n\nHaving `millstone` installed specifically enable support for localizing external resources (URLs and local files) referenced in your mml file, and detecting projections (using [node-srs](https://github.com/mapbox/node-srs))\n\nNow that Carto is installed you should have a `carto` command line tool available that can be run on a Mapbox Studio Classic project:\n\n    carto project.mml > mapnik.xml\n\nAvailable parameters:\n* -h / --help - Display help message\n* -v / --version - Display version information\n* -b / --benchmark - Outputs total compile time\n* -l / --localize - Use millstone to localize resources when loading an MML (default: off)\n* -n / --nosymlink - Use absolute paths instead of symlinking files\n* -a / --api VERSION - Specify Mapnik API version (e.g. --api 3.0.10) (default: 2.3.0)\n* -ppi RESOLUTION - Pixels per inch used to convert m, mm, cm, in, pt, pc to pixels (default: 90.714)\n\n#### From code\n\nCurrently CartoCSS is designed to be invoked from [node.js](http://nodejs.org/).\nThe `Renderer` interface is the main API for developers, and it takes an MML file as a string as input.\n\n    // defined variables:\n    // - input (the name or identifier of the file being parsed)\n    var carto = require('carto');\n\n    try {\n        var data = fs.readFileSync(input, 'utf-8');\n        var mml = new carto.MML();\n        mml.load(path.dirname(input), data, function (err, data) {\n            if (err) throw err;\n            var output = new carto.Renderer({\n                filename: input,\n                local_data_dir: path.dirname(input),\n            }).render(data);\n            console.log(output);\n        });\n    } catch(err) {\n        if (Array.isArray(err)) {\n            err.forEach(function(e) {\n                carto.writeError(e, options);\n            });\n        } else { throw err; }\n    }\n\n### Vim\n\nTo install, download or clone this repository, then copy the `vim-carto`\ndirectory located at `build/vim-carto` to your `~/.vim` directory.\n\n    cp build/vim-carto/* ~/.vim -R\n\n## Credits\n\nCartoCSS is based on [less.js](https://github.com/cloudhead/less.js), a CSS compiler written by Alexis Sellier.\n\nSee also a [list of dependencies](https://david-dm.org/mapbox/carto#info=dependencies&view=list).\n\n## Authors\n\n* Tom MacWright (tmcw)\n* Konstantin Käfer (kkaefer)\n* AJ Ashton (ajashton)\n* Dane Springmeyer (springmeyer)\n","maintainers":[{"email":"yannick.meeus+npm+production+ci@mapbox.com","name":"mbx-npm-ci-production"},{"email":"yannick.meeus+npm+staging+ci@mapbox.com","name":"mbx-npm-ci-staging"},{"email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-production"},{"email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-staging"},{"email":"yannick.meeus+npm+prod+09@mapbox.com","name":"mbx-npm-09-production"},{"email":"yannick.meeus+npm+prod+08@mapbox.com","name":"mbx-npm-08-production"},{"email":"yannick.meeus+npm+prod+07@mapbox.com","name":"mbx-npm-07-production"},{"email":"yannick.meeus+npm+prod+06@mapbox.com","name":"mbx-npm-06-production"},{"email":"yannick.meeus+npm+prod+05@mapbox.com","name":"mbx-npm-05-production"},{"email":"yannick.meeus+npm+prod+04@mapbox.com","name":"mbx-npm-04-production"},{"email":"yannick.meeus+npm+prod+03@mapbox.com","name":"mbx-npm-03-production"},{"email":"yannick.meeus+npm+prod+02@mapbox.com","name":"mbx-npm-02-production"},{"email":"yannick.meeus+npm+prod+01@mapbox.com","name":"mbx-npm-01-production"},{"email":"yannick.meeus@mapbox.com","name":"mbx-npm-02-staging"},{"email":"accounts+npmjs-01@mapbox.com","name":"mapbox-npm-01"},{"email":"accounts+npmjs-02@mapbox.com","name":"mapbox-npm-02"},{"email":"accounts+npmjs-07@mapbox.com","name":"mapbox-npm-07"},{"email":"accounts+npmjs-03@mapbox.com","name":"mapbox-npm-03"},{"email":"accounts+npmjs-04@mapbox.com","name":"mapbox-npm-04"},{"email":"accounts+npmjs-09@mapbox.com","name":"mapbox-npm-09"},{"email":"accounts+npmjs-05@mapbox.com","name":"mapbox-npm-05"},{"email":"accounts+npmjs-06@mapbox.com","name":"mapbox-npm-06"},{"email":"accounts+npmjs-08@mapbox.com","name":"mapbox-npm-08"},{"email":"accounts+npmjs-advanced-actions@mapbox.com","name":"mapbox-npm-advanced-actions"},{"email":"accounts+npmjs-npm-ci@mapbox.com","name":"mapbox-npm-ci"},{"email":"accounts+npmjs@mapbox.com","name":"mapbox-npm"},{"email":"accounts@mapbox.com","name":"mapbox-admin"},{"email":"accounts+npm-mapbox-machine-user@mapbox.com","name":"mapbox-machine-user"}],"time":{"modified":"2023-01-12T12:41:12.083Z","created":"2016-12-22T02:09:02.022Z","0.16.3":"2016-12-22T02:09:02.022Z"},"homepage":"https://github.com/mapbox/carto#readme","keywords":["mapnik","maps","css","stylesheets"],"repository":{"type":"git","url":"git+ssh://git@github.com/mapbox/carto.git"},"contributors":[{"name":"Tom MacWright","email":"macwright@gmail.com"},{"name":"Konstantin Käfer"},{"name":"Alexis Sellier","email":"self@cloudhead.net"}],"author":{"name":"Mapbox","email":"info@mapbox.com","url":"http://mapbox.com/"},"bugs":{"url":"https://github.com/mapbox/carto/issues"},"license":"Apache-2.0","readmeFilename":"README.md"}