-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8fcb1ff
Showing
10 changed files
with
647 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.DS_Store | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
{ | ||
"requireCurlyBraces": [ | ||
"if", | ||
"else", | ||
"for", | ||
"while", | ||
"do", | ||
"try", | ||
"catch" | ||
], | ||
"requireSpaceAfterKeywords": [ | ||
"if", | ||
"else", | ||
"for", | ||
"while", | ||
"do", | ||
"switch", | ||
"return", | ||
"try", | ||
"catch" | ||
], | ||
"requireSpaceBeforeBlockStatements": true, | ||
"requireParenthesesAroundIIFE": true, | ||
"requireSpacesInConditionalExpression": true, | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInAnonymousFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInNamedFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"requireMultipleVarDecl": true, | ||
"requireBlocksOnNewline": true, | ||
"disallowPaddingNewlinesInBlocks": true, | ||
"disallowEmptyBlocks": true, | ||
"disallowSpacesInsideObjectBrackets": true, | ||
"disallowSpacesInsideArrayBrackets": true, | ||
"disallowSpacesInsideParentheses": true, | ||
"requireSpacesInsideObjectBrackets": "all", | ||
"disallowDanglingUnderscores": true, | ||
"requireSpaceAfterObjectKeys": true, | ||
"requireCommaBeforeLineBreak": true, | ||
"requireOperatorBeforeLineBreak": [ | ||
"?", | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==", | ||
">", | ||
">=", | ||
"<", | ||
"<=" | ||
], | ||
"disallowLeftStickedOperators": [ | ||
"?", | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==", | ||
">", | ||
">=", | ||
"<", | ||
"<=" | ||
], | ||
"requireRightStickedOperators": ["!"], | ||
"disallowRightStickedOperators": [ | ||
"?", | ||
"+", | ||
"/", | ||
"*", | ||
":", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==", | ||
">", | ||
">=", | ||
"<", | ||
"<=" | ||
], | ||
"requireLeftStickedOperators": [","], | ||
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], | ||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], | ||
"requireSpaceBeforeBinaryOperators": [ | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==" | ||
], | ||
"requireSpaceAfterBinaryOperators": [ | ||
"+", | ||
"-", | ||
"/", | ||
"*", | ||
"=", | ||
"==", | ||
"===", | ||
"!=", | ||
"!==" | ||
], | ||
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"], | ||
"requireCamelCaseOrUpperCaseIdentifiers": true, | ||
"disallowKeywords": ["with"], | ||
"disallowMultipleLineStrings": true, | ||
"disallowMultipleLineBreaks": true, | ||
"validateLineBreaks": "LF", | ||
"validateQuoteMarks": "'", | ||
"disallowMixedSpacesAndTabs": true, | ||
"disallowTrailingWhitespace": true, | ||
"disallowKeywordsOnNewLine": ["else"], | ||
"requireLineFeedAtFileEnd": true, | ||
"maximumLineLength": 78, | ||
"requireCapitalizedConstructors": true, | ||
"safeContextKeyword": "self", | ||
"requireDotNotation": true, | ||
"disallowYodaConditions": true, | ||
"validateJSDoc": { | ||
"checkParamNames": true, | ||
"checkRedundantParams": true, | ||
"requireParamTypes": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- 0.10 | ||
- 0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2014 Titus Wormer <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
make: lint complexity cover | ||
|
||
test: | ||
@./node_modules/.bin/mocha --reporter spec --check-leaks -u exports spec/*.spec*.js | ||
|
||
watch: | ||
@./node_modules/.bin/mocha --reporter min --check-leaks --watch spec/*.spec*.js | ||
|
||
lint: | ||
# Lint (passes when empty): | ||
@./node_modules/.bin/jshint index.js spec/*.spec*.js | ||
@./node_modules/.bin/jscs ./index.js --reporter=inline | ||
|
||
|
||
complexity: | ||
# Complexity (passes when empty): | ||
@./node_modules/.bin/cr -l --maxcyc 15 --format minimal --silent index.js | ||
|
||
cover: | ||
# Cover (and test): | ||
@./node_modules/.bin/istanbul cover --report html ./node_modules/.bin/_mocha -- -- --reporter min --check-leaks -u exports spec/*.spec*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# retext [![Build Status](https://travis-ci.org/wooorm/retext.png)](https://travis-ci.org/wooorm/retext) | ||
|
||
**retext** is a extensible natural language parser system—by default using [parse-english](https://github.com/wooorm/parse-english) as a parser and [textom](https://github.com/wooorm/textom/) as the object model. Provides a plugin-system for analysing and manipulating natural language. In JavaScript. NodeJS, and the browser. Tests provide 100% coverage. | ||
|
||
## Installation | ||
|
||
### With NPM | ||
|
||
```sh | ||
$ npm install retext | ||
``` | ||
|
||
### Git | ||
|
||
```sh | ||
git clone https://github.com/wooorm/retext.git | ||
cd retext | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
var Retext = require('retext'), | ||
emoji = require('retext-emoji'), | ||
smartypants = require('retext-smartypants'), | ||
input; | ||
|
||
// Modified first paragraph from: | ||
// http://en.wikipedia.org/wiki/Three_wise_monkeys | ||
input = 'The three wise monkeys [. . .] sometimes called the ' + | ||
'three mystic apes--are a pictorial maxim. Together ' + | ||
'they embody the proverbial principle to ("see no evil, ' + | ||
'hear no evil, speak no evil"). The three monkeys are ' + | ||
'Mizaru (:see_no_evil:), covering his eyes, who sees no ' + | ||
'evil; Kikazaru (:hear_no_evil:), covering his ears, ' + | ||
'who hears no evil; and Iwazaru (:speak_no_evil:), ' + | ||
'covering his mouth, who speaks no evil.' | ||
|
||
var text = new Retext() | ||
.use(emoji({ | ||
'convert' : 'encode' | ||
})) | ||
.use(smartypants()) | ||
.parse(input) | ||
.toString(); | ||
// The three wise monkeys […] sometimes called the three | ||
// mystic apes—are a pictorial maxim. Together they | ||
// embody the proverbial principle to (“see no evil, | ||
// hear no evil, speak no evil”). The three monkeys are | ||
// Mizaru (🙈), covering his eyes, who sees no evil; | ||
// Kikazaru (🙉), covering his ears, who hears no evil; | ||
// and Iwazaru (🙊), covering his mouth, who speaks no evil. | ||
``` | ||
|
||
Plugins used: [retext-emoji](https://github.com/wooorm/retext-emoji) and [retext-smartypants](https://github.com/wooorm/retext-smartypants). | ||
|
||
## API | ||
|
||
### Retext(parser) | ||
|
||
Return a new `Retext` instance with the given parser. | ||
|
||
Takes a parser (Object, String, or null), or its name to use. Defaults to `"parse-english"`. When a string, requires the module. | ||
|
||
### Retext.prototype.use(plugin) | ||
|
||
Attaches a plugin. Returns self. | ||
|
||
Takes a plugin—a humble function—and when the `parse` method of the Retext instance is called, the plugin will be called with the parsed tree, and the Retext instance as arguments. Plugins can also have an `attach` method, which will be only called once (when the plugin is `use`d). | ||
|
||
### Retext.prototype.parse(source) | ||
|
||
Parses the given source (using the to the constructor given parser), and returns the—by `use`d plugins, modified—tree. | ||
|
||
Note that, during the parsing stage, when the `use` method is called by a plugin, the nested plugin is immediately called, before continuing on with its parent plugin—this enabled plugins to depend on other plugins. | ||
|
||
Returns a RootNode. | ||
|
||
## Related | ||
|
||
* [parse-english](https://github.com/wooorm/parse-english "Parse English") | ||
* [textom](https://github.com/wooorm/textom "TextOM") | ||
|
||
## License | ||
|
||
MIT |
Oops, something went wrong.