You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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.
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 =newRetext()
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.
0 commit comments