Skip to content

Commit 8fcb1ff

Browse files
committed
0.0.2
0 parents  commit 8fcb1ff

10 files changed

+647
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
coverage

.jscs.json

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"requireCurlyBraces": [
3+
"if",
4+
"else",
5+
"for",
6+
"while",
7+
"do",
8+
"try",
9+
"catch"
10+
],
11+
"requireSpaceAfterKeywords": [
12+
"if",
13+
"else",
14+
"for",
15+
"while",
16+
"do",
17+
"switch",
18+
"return",
19+
"try",
20+
"catch"
21+
],
22+
"requireSpaceBeforeBlockStatements": true,
23+
"requireParenthesesAroundIIFE": true,
24+
"requireSpacesInConditionalExpression": true,
25+
"requireSpacesInFunctionExpression": {
26+
"beforeOpeningCurlyBrace": true
27+
},
28+
"requireSpacesInAnonymousFunctionExpression": {
29+
"beforeOpeningRoundBrace": true,
30+
"beforeOpeningCurlyBrace": true
31+
},
32+
"requireSpacesInNamedFunctionExpression": {
33+
"beforeOpeningRoundBrace": true,
34+
"beforeOpeningCurlyBrace": true
35+
},
36+
"requireSpacesInFunctionExpression": {
37+
"beforeOpeningCurlyBrace": true
38+
},
39+
"requireMultipleVarDecl": true,
40+
"requireBlocksOnNewline": true,
41+
"disallowPaddingNewlinesInBlocks": true,
42+
"disallowEmptyBlocks": true,
43+
"disallowSpacesInsideObjectBrackets": true,
44+
"disallowSpacesInsideArrayBrackets": true,
45+
"disallowSpacesInsideParentheses": true,
46+
"requireSpacesInsideObjectBrackets": "all",
47+
"disallowDanglingUnderscores": true,
48+
"requireSpaceAfterObjectKeys": true,
49+
"requireCommaBeforeLineBreak": true,
50+
"requireOperatorBeforeLineBreak": [
51+
"?",
52+
"+",
53+
"-",
54+
"/",
55+
"*",
56+
"=",
57+
"==",
58+
"===",
59+
"!=",
60+
"!==",
61+
">",
62+
">=",
63+
"<",
64+
"<="
65+
],
66+
"disallowLeftStickedOperators": [
67+
"?",
68+
"+",
69+
"-",
70+
"/",
71+
"*",
72+
"=",
73+
"==",
74+
"===",
75+
"!=",
76+
"!==",
77+
">",
78+
">=",
79+
"<",
80+
"<="
81+
],
82+
"requireRightStickedOperators": ["!"],
83+
"disallowRightStickedOperators": [
84+
"?",
85+
"+",
86+
"/",
87+
"*",
88+
":",
89+
"=",
90+
"==",
91+
"===",
92+
"!=",
93+
"!==",
94+
">",
95+
">=",
96+
"<",
97+
"<="
98+
],
99+
"requireLeftStickedOperators": [","],
100+
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
101+
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
102+
"requireSpaceBeforeBinaryOperators": [
103+
"+",
104+
"-",
105+
"/",
106+
"*",
107+
"=",
108+
"==",
109+
"===",
110+
"!=",
111+
"!=="
112+
],
113+
"requireSpaceAfterBinaryOperators": [
114+
"+",
115+
"-",
116+
"/",
117+
"*",
118+
"=",
119+
"==",
120+
"===",
121+
"!=",
122+
"!=="
123+
],
124+
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
125+
"requireCamelCaseOrUpperCaseIdentifiers": true,
126+
"disallowKeywords": ["with"],
127+
"disallowMultipleLineStrings": true,
128+
"disallowMultipleLineBreaks": true,
129+
"validateLineBreaks": "LF",
130+
"validateQuoteMarks": "'",
131+
"disallowMixedSpacesAndTabs": true,
132+
"disallowTrailingWhitespace": true,
133+
"disallowKeywordsOnNewLine": ["else"],
134+
"requireLineFeedAtFileEnd": true,
135+
"maximumLineLength": 78,
136+
"requireCapitalizedConstructors": true,
137+
"safeContextKeyword": "self",
138+
"requireDotNotation": true,
139+
"disallowYodaConditions": true,
140+
"validateJSDoc": {
141+
"checkParamNames": true,
142+
"checkRedundantParams": true,
143+
"requireParamTypes": true
144+
}
145+
}

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage
2+
.travis.yml

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
- 0.11

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2014 Titus Wormer <tituswormer@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
make: lint complexity cover
2+
3+
test:
4+
@./node_modules/.bin/mocha --reporter spec --check-leaks -u exports spec/*.spec*.js
5+
6+
watch:
7+
@./node_modules/.bin/mocha --reporter min --check-leaks --watch spec/*.spec*.js
8+
9+
lint:
10+
# Lint (passes when empty):
11+
@./node_modules/.bin/jshint index.js spec/*.spec*.js
12+
@./node_modules/.bin/jscs ./index.js --reporter=inline
13+
14+
15+
complexity:
16+
# Complexity (passes when empty):
17+
@./node_modules/.bin/cr -l --maxcyc 15 --format minimal --silent index.js
18+
19+
cover:
20+
# Cover (and test):
21+
@./node_modules/.bin/istanbul cover --report html ./node_modules/.bin/_mocha -- -- --reporter min --check-leaks -u exports spec/*.spec*.js

Readme.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# retext [![Build Status](https://travis-ci.org/wooorm/retext.png)](https://travis-ci.org/wooorm/retext)
2+
3+
**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.
4+
5+
## Installation
6+
7+
### With NPM
8+
9+
```sh
10+
$ npm install retext
11+
```
12+
13+
### Git
14+
15+
```sh
16+
git clone https://github.com/wooorm/retext.git
17+
cd retext
18+
```
19+
20+
## Usage
21+
22+
```js
23+
var Retext = require('retext'),
24+
emoji = require('retext-emoji'),
25+
smartypants = require('retext-smartypants'),
26+
input;
27+
28+
// Modified first paragraph from:
29+
// http://en.wikipedia.org/wiki/Three_wise_monkeys
30+
input = 'The three wise monkeys [. . .] sometimes called the ' +
31+
'three mystic apes--are a pictorial maxim. Together ' +
32+
'they embody the proverbial principle to ("see no evil, ' +
33+
'hear no evil, speak no evil"). The three monkeys are ' +
34+
'Mizaru (:see_no_evil:), covering his eyes, who sees no ' +
35+
'evil; Kikazaru (:hear_no_evil:), covering his ears, ' +
36+
'who hears no evil; and Iwazaru (:speak_no_evil:), ' +
37+
'covering his mouth, who speaks no evil.'
38+
39+
var text = new Retext()
40+
.use(emoji({
41+
'convert' : 'encode'
42+
}))
43+
.use(smartypants())
44+
.parse(input)
45+
.toString();
46+
// The three wise monkeys […] sometimes called the three
47+
// mystic apes—are a pictorial maxim. Together they
48+
// embody the proverbial principle to (“see no evil,
49+
// hear no evil, speak no evil”). The three monkeys are
50+
// Mizaru (🙈), covering his eyes, who sees no evil;
51+
// Kikazaru (🙉), covering his ears, who hears no evil;
52+
// and Iwazaru (🙊), covering his mouth, who speaks no evil.
53+
```
54+
55+
Plugins used: [retext-emoji](https://github.com/wooorm/retext-emoji) and [retext-smartypants](https://github.com/wooorm/retext-smartypants).
56+
57+
## API
58+
59+
### Retext(parser)
60+
61+
Return a new `Retext` instance with the given parser.
62+
63+
Takes a parser (Object, String, or null), or its name to use. Defaults to `"parse-english"`. When a string, requires the module.
64+
65+
### Retext.prototype.use(plugin)
66+
67+
Attaches a plugin. Returns self.
68+
69+
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).
70+
71+
### Retext.prototype.parse(source)
72+
73+
Parses the given source (using the to the constructor given parser), and returns the—by `use`d plugins, modified—tree.
74+
75+
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.
76+
77+
Returns a RootNode.
78+
79+
## Related
80+
81+
* [parse-english](https://github.com/wooorm/parse-english "Parse English")
82+
* [textom](https://github.com/wooorm/textom "TextOM")
83+
84+
## License
85+
86+
MIT

0 commit comments

Comments
 (0)