|
|
- {
- "_args": [
- [
- "snapdragon@^0.8.1",
- "/home/herrhase/Workspace/tentakelfabrik/tiny-components/tiny-consent/node_modules/micromatch"
- ]
- ],
- "_from": "snapdragon@>=0.8.1 <0.9.0",
- "_id": "snapdragon@0.8.2",
- "_inCache": true,
- "_installable": true,
- "_location": "/snapdragon",
- "_nodeVersion": "9.7.1",
- "_npmOperationalInternal": {
- "host": "s3://npm-registry-packages",
- "tmp": "tmp/snapdragon_0.8.2_1520776598430_0.674348590844402"
- },
- "_npmUser": {
- "email": "github@sellside.com",
- "name": "jonschlinkert"
- },
- "_npmVersion": "5.7.1",
- "_phantomChildren": {
- "is-descriptor": "0.1.6"
- },
- "_requested": {
- "name": "snapdragon",
- "raw": "snapdragon@^0.8.1",
- "rawSpec": "^0.8.1",
- "scope": null,
- "spec": ">=0.8.1 <0.9.0",
- "type": "range"
- },
- "_requiredBy": [
- "/braces",
- "/expand-brackets",
- "/extglob",
- "/micromatch",
- "/nanomatch"
- ],
- "_resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
- "_shasum": "64922e7c565b0e14204ba1aa7d6964278d25182d",
- "_shrinkwrap": null,
- "_spec": "snapdragon@^0.8.1",
- "_where": "/home/herrhase/Workspace/tentakelfabrik/tiny-components/tiny-consent/node_modules/micromatch",
- "author": {
- "name": "Jon Schlinkert",
- "url": "https://github.com/jonschlinkert"
- },
- "bugs": {
- "url": "https://github.com/jonschlinkert/snapdragon/issues"
- },
- "contributors": [
- {
- "name": "Brian Woodward",
- "url": "https://twitter.com/doowb"
- },
- {
- "name": "Edward Betts",
- "url": "http://edwardbetts.com"
- },
- {
- "name": "Jon Schlinkert",
- "url": "http://twitter.com/jonschlinkert"
- }
- ],
- "dependencies": {
- "base": "^0.11.1",
- "debug": "^2.2.0",
- "define-property": "^0.2.5",
- "extend-shallow": "^2.0.1",
- "map-cache": "^0.2.2",
- "source-map": "^0.5.6",
- "source-map-resolve": "^0.5.0",
- "use": "^3.1.0"
- },
- "description": "Fast, pluggable and easy-to-use parser-renderer factory.",
- "devDependencies": {
- "gulp": "^3.9.1",
- "gulp-eslint": "^3.0.1",
- "gulp-format-md": "^0.1.10",
- "gulp-istanbul": "^1.1.1",
- "gulp-mocha": "^3.0.1",
- "gulp-unused": "^0.2.0",
- "mocha": "^3.0.2"
- },
- "directories": {},
- "dist": {
- "fileCount": 9,
- "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==",
- "shasum": "64922e7c565b0e14204ba1aa7d6964278d25182d",
- "tarball": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
- "unpackedSize": 35228
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "index.js",
- "lib"
- ],
- "gitHead": "6c952b12cabe896a86d9a4fe378f934bccbe6436",
- "homepage": "https://github.com/jonschlinkert/snapdragon",
- "keywords": [
- "lexer",
- "snapdragon"
- ],
- "license": "MIT",
- "main": "index.js",
- "maintainers": [
- {
- "name": "doowb",
- "email": "brian.woodward@gmail.com"
- },
- {
- "name": "jonschlinkert",
- "email": "github@sellside.com"
- }
- ],
- "name": "snapdragon",
- "optionalDependencies": {},
- "readme": "# snapdragon [![NPM version](https://img.shields.io/npm/v/snapdragon.svg?style=flat)](https://www.npmjs.com/package/snapdragon) [![NPM downloads](https://img.shields.io/npm/dm/snapdragon.svg?style=flat)](https://npmjs.org/package/snapdragon) [![Build Status](https://img.shields.io/travis/jonschlinkert/snapdragon.svg?style=flat)](https://travis-ci.org/jonschlinkert/snapdragon)\n\n> Fast, pluggable and easy-to-use parser-renderer factory.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save snapdragon\n```\n\nCreated by [jonschlinkert](https://github.com/jonschlinkert) and [doowb](https://github.com/doowb).\n\n**Features**\n\n* Bootstrap your own parser, get sourcemap support for free\n* All parsing and compiling is handled by simple, reusable middleware functions\n* Inspired by the parsers in [pug](http://jade-lang.com) and [css](https://github.com/reworkcss/css).\n\n## History\n\n### v0.5.0\n\n**Breaking changes**\n\nSubstantial breaking changes were made in v0.5.0! Most of these changes are part of a larger refactor that will be finished in 0.6.0, including the introduction of a `Lexer` class.\n\n* Renderer was renamed to `Compiler`\n* the `.render` method was renamed to `.compile`\n* Many other smaller changes. A more detailed overview will be provided in 0.6.0. If you don't have to time review code, I recommend you wait for the 0.6.0 release.\n\n## Usage examples\n\n```js\nvar Snapdragon = require('snapdragon');\nvar snapdragon = new Snapdragon();\n```\n\n**Parse**\n\n```js\nvar ast = snapdragon.parser('some string', options)\n // parser middleware that can be called by other middleware\n .set('foo', function () {})\n // parser middleware, runs immediately in the order defined\n .use(bar())\n .use(baz())\n```\n\n**Render**\n\n```js\n// pass the `ast` from the parse method\nvar res = snapdragon.compiler(ast)\n // compiler middleware, called when the name of the middleware\n // matches the `node.type` (defined in a parser middleware)\n .set('bar', function () {})\n .set('baz', function () {})\n .compile()\n```\n\nSee the [examples](./examples/).\n\n## Getting started\n\n**Parsers**\n\nParsers are middleware functions used for parsing a string into an ast node.\n\n```js\nvar ast = snapdragon.parser(str, options)\n .use(function() {\n var pos = this.position();\n var m = this.match(/^\\./);\n if (!m) return;\n return pos({\n // `type` specifies the compiler to use\n type: 'dot',\n val: m[0]\n });\n })\n```\n\n**AST node**\n\nWhen the parser finds a match, `pos()` is called, pushing a token for that node onto the ast that looks something like:\n\n```js\n{ type: 'dot',\n val: '.',\n position:\n { start: { lineno: 1, column: 1 },\n end: { lineno: 1, column: 2 } }}\n```\n\n**Renderers**\n\nRenderers are _named_ middleware functions that visit over an array of ast nodes to compile a string.\n\n```js\nvar res = snapdragon.compiler(ast)\n .set('dot', function (node) {\n console.log(node.val)\n //=> '.'\n return this.emit(node.val);\n })\n```\n\n**Source maps**\n\nIf you want source map support, make sure to emit the position as well.\n\n```js\nvar res = snapdragon.compiler(ast)\n .set('dot', function (node) {\n return this.emit(node.val, node.position);\n })\n```\n\n## Docs\n\n### Parser middleware\n\nA parser middleware is a function that returns an abject called a `token`. This token is pushed onto the AST as a node.\n\n**Example token**\n\n```js\n{ type: 'dot',\n val: '.',\n position:\n { start: { lineno: 1, column: 1 },\n end: { lineno: 1, column: 2 } }}\n```\n\n**Example parser middleware**\n\nMatch a single `.` in a string:\n\n1. Get the starting position by calling `this.position()`\n2. pass a regex for matching a single dot to the `.match` method\n3. if **no match** is found, return `undefined`\n4. if a **match** is found, `pos()` is called, which returns a token with:\n - `type`: the name of the [compiler] to use\n - `val`: The actual value captured by the regex. In this case, a `.`. Note that
- "readmeFilename": "README.md",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jonschlinkert/snapdragon.git"
- },
- "scripts": {
- "test": "mocha"
- },
- "verb": {
- "layout": "default",
- "lint": {
- "reflinks": true
- },
- "plugins": [
- "gulp-format-md"
- ],
- "reflinks": [
- "css",
- "pug",
- "verb",
- "verb-generate-readme"
- ],
- "related": {
- "description": "These libraries use snapdragon:",
- "list": [
- "braces",
- "expand-brackets",
- "extglob",
- "micromatch"
- ]
- },
- "tasks": [
- "readme"
- ],
- "toc": false
- },
- "version": "0.8.2"
- }
|