snapdragon-capture
Advanced tools
Comparing version 0.1.0 to 0.2.0
27
index.js
@@ -13,5 +13,3 @@ 'use strict'; | ||
* ``` | ||
* @param {String} `type` | ||
* @param {RegExp|Function} `regex` Pass the regex to use for capturing. Pass a function if you need access to the parser instance. | ||
* @return {Object} Returns the parser instance for chaining | ||
* | ||
* @api public | ||
@@ -46,8 +44,6 @@ */ | ||
* var pos = this.position(); | ||
* var m = this.match(/^\./); | ||
* if (!m) return; | ||
* return pos({ | ||
* type: 'foo', | ||
* val: m[0] | ||
* }); | ||
* var match = this.match(/^\./); | ||
* if (match) { | ||
* return pos(this.node(match[0])); | ||
* } | ||
* }); | ||
@@ -69,11 +65,10 @@ * ``` | ||
var pos = this.position(); | ||
var m = this.match(regex); | ||
if (!m || !m[0]) return; | ||
var prev = this.prev(); | ||
var node = this.node(pos, m[0]); | ||
node.define('match', m); | ||
prev.addNode(node); | ||
var match = this.match(regex); | ||
if (match) { | ||
var node = pos(this.node(match[0], type)); | ||
node.match = match; | ||
return node; | ||
} | ||
}.bind(this)); | ||
return this; | ||
} |
{ | ||
"name": "snapdragon-capture", | ||
"description": "Snapdragon plugin that adds a capture method to the parser instance.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/snapdragon-capture", | ||
@@ -25,8 +25,20 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"mocha": "^3.2.0", | ||
"snapdragon": "^0.8.1" | ||
"snapdragon": "^0.10.0" | ||
}, | ||
"keywords": [ | ||
"capture", | ||
"generategenerator", | ||
"snapdragon" | ||
"compile", | ||
"compiler", | ||
"convert", | ||
"handler", | ||
"match", | ||
"parse", | ||
"parser", | ||
"plugin", | ||
"render", | ||
"set", | ||
"snapdragon", | ||
"snapdragonplugin", | ||
"transform", | ||
"visitor" | ||
], | ||
@@ -33,0 +45,0 @@ "verb": { |
@@ -26,8 +26,2 @@ # snapdragon-capture [![NPM version](https://img.shields.io/npm/v/snapdragon-capture.svg?style=flat)](https://www.npmjs.com/package/snapdragon-capture) [![NPM monthly downloads](https://img.shields.io/npm/dm/snapdragon-capture.svg?style=flat)](https://npmjs.org/package/snapdragon-capture) [![NPM total downloads](https://img.shields.io/npm/dt/snapdragon-capture.svg?style=flat)](https://npmjs.org/package/snapdragon-capture) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/snapdragon-capture.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/snapdragon-capture) | ||
**Params** | ||
* `type` **{String}** | ||
* `regex` **{RegExp|Function}**: Pass the regex to use for capturing. Pass a function if you need access to the parser instance. | ||
* `returns` **{Object}**: Returns the parser instance for chaining | ||
**Example** | ||
@@ -42,3 +36,3 @@ | ||
### [capture](index.js#L59) | ||
### [capture](index.js#L55) | ||
@@ -61,8 +55,6 @@ Create a node of the given `type` using the specified regex or function. | ||
var pos = this.position(); | ||
var m = this.match(/^\./); | ||
if (!m) return; | ||
return pos({ | ||
type: 'foo', | ||
val: m[0] | ||
}); | ||
var match = this.match(/^\./); | ||
if (match) { | ||
return pos(this.node(match[0])); | ||
} | ||
}); | ||
@@ -76,3 +68,3 @@ ``` | ||
* [snapdragon-util](https://www.npmjs.com/package/snapdragon-util): Utilities for the snapdragon parser/compiler. | [homepage](https://github.com/jonschlinkert/snapdragon-util "Utilities for the snapdragon parser/compiler.") | ||
* [snapdragon](https://www.npmjs.com/package/snapdragon): Fast, pluggable and easy-to-use parser-renderer factory. | [homepage](https://github.com/jonschlinkert/snapdragon "Fast, pluggable and easy-to-use parser-renderer factory.") | ||
* [snapdragon](https://www.npmjs.com/package/snapdragon): Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map… [more](https://github.com/jonschlinkert/snapdragon) | [homepage](https://github.com/jonschlinkert/snapdragon "Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map support.") | ||
@@ -87,8 +79,8 @@ ### Contributing | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
@@ -98,6 +90,6 @@ | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install && npm test | ||
``` | ||
@@ -115,6 +107,6 @@ | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](LICENSE). | ||
MIT | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.1, on January 20, 2017._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 08, 2017._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7900
64
105