1
- # hast-util-to-nlcst [ ![ Build ] [ build-badge ]] [ build ] [ ![ Coverage ] [ coverage-badge ]] [ coverage ] [ ![ Downloads ] [ downloads-badge ]] [ downloads ] [ ![ Chat ] [ chat-badge ]] [ chat ]
1
+ # hast-util-to-nlcst
2
2
3
- Transform [ HAST] [ ] to [ NLCST] [ ] .
3
+ [ ![ Build] [ build-badge ]] [ build ]
4
+ [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5
+ [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6
+ [ ![ Size] [ size-badge ]] [ size ]
7
+ [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8
+ [ ![ Backers] [ backers-badge ]] [ collective ]
9
+ [ ![ Chat] [ chat-badge ]] [ chat ]
4
10
5
- > ** Note ** : You probably want to use [ rehype-retext ] [ ] .
11
+ [ ** hast ** ] [ hast ] utility to transform to [ ** nlcst ** ] [ nlcst ] .
6
12
7
- ## Installation
13
+ > ** Note** : You probably want to use [ ` rehype-retext ` ] [ rehype-retext ] .
14
+
15
+ ## Install
8
16
9
17
[ npm] [ ] :
10
18
11
- ``` bash
19
+ ``` sh
12
20
npm install hast-util-to-nlcst
13
21
```
14
22
@@ -24,9 +32,9 @@ Say we have the following `example.html`:
24
32
</article >
25
33
```
26
34
27
- ... and next to it, ` index.js ` :
35
+ … and next to it, ` index.js ` :
28
36
29
- ``` javascript
37
+ ``` js
30
38
var rehype = require (' rehype' )
31
39
var vfile = require (' to-vfile' )
32
40
var English = require (' parse-english' )
@@ -65,50 +73,45 @@ RootNode[2] (1:1-6:1, 0-134)
65
73
66
74
## API
67
75
68
- ### ` toNLCST(node , file, Parser)`
76
+ ### ` toNlcst(tree , file, Parser)`
69
77
70
- Transform a [ HAST] [ ] syntax tree and corresponding [ virtual file] [ vfile ]
71
- into an [ NLCST] [ nlcst ] tree.
78
+ Transform the given [ ** hast** ] [ hast ] [ * tree* ] [ tree ] to [ ** nlcst** ] [ nlcst ] .
72
79
73
80
##### Parameters
74
81
75
- ###### ` node `
76
-
77
- Syntax tree with positional information ([ ` HASTNode ` ] [ hast ] ).
78
-
79
- ###### ` file `
80
-
81
- Virtual file ([ ` VFile ` ] [ vfile ] ).
82
-
83
- ###### ` parser `
84
-
85
- Constructor of an NLCST parser, such as [ ` parse-english ` ] [ english ] ,
86
- [ ` parse-dutch ` ] [ dutch ] , or [ ` parse-latin ` ] [ latin ] (` Function ` ).
82
+ * ` tree ` ([ ` HastNode ` ] [ hast-node ] )
83
+ — [ * Tree* ] [ tree ] with [ positional info] [ positional-information ]
84
+ ([ ` HastNode ` ] [ hast-node ] )
85
+ * ` file ` ([ ` VFile ` ] [ vfile ] )
86
+ — Virtual file
87
+ * ` parser ` (` Function ` )
88
+ — [ ** nlcst** ] [ nlcst ] parser, such as [ ` parse-english ` ] [ english ] ,
89
+ [ ` parse-dutch ` ] [ dutch ] , or [ ` parse-latin ` ] [ latin ]
87
90
88
91
##### Returns
89
92
90
- [ ` NLCSTNode ` ] [ nlcst ] .
93
+ [ ` NlcstNode ` ] [ nlcst-node ] .
91
94
92
95
##### Notes
93
96
94
- ###### Implied sentences
97
+ ###### Implied paragraphs
95
98
96
99
The algorithm supports implicit and explicit paragraphs, such as:
97
100
98
101
``` html
99
102
<article >
100
- An implicit sentence .
101
- <h1 >An explicit sentence .</h1 >
103
+ An implicit paragraph .
104
+ <h1 >An explicit paragraph .</h1 >
102
105
</article >
103
106
```
104
107
105
- Overlapping paragraphs are also supported (see the tests or the HTML spec
106
- for more info).
108
+ Overlapping paragraphs are also supported (see the tests or the HTML spec for
109
+ more info).
107
110
108
111
###### Ignored nodes
109
112
110
- Some elements are ignored and their content will not be present in NLCST:
111
- ` <script> ` , ` <style> ` , ` <svg> ` , ` <math> ` , ` <del> ` .
113
+ Some elements are ignored and their content will not be present in
114
+ [ ** nlcst ** ] [ nlcst ] : ` <script> ` , ` <style> ` , ` <svg> ` , ` <math> ` , ` <del> ` .
112
115
113
116
To ignore other elements, add a ` data-nlcst ` attribute with a value of ` ignore ` :
114
117
@@ -119,7 +122,7 @@ To ignore other elements, add a `data-nlcst` attribute with a value of `ignore`:
119
122
120
123
###### Source nodes
121
124
122
- ` <code> ` elements are mapped to [ Source] [ ] nodes in NLCST .
125
+ ` <code> ` elements are mapped to [ ` Source ` ] [ source ] nodes in [ ** nlcst ** ] [ nlcst ] .
123
126
124
127
To mark other elements as source, add a ` data-nlcst ` attribute with a value
125
128
of ` source ` :
@@ -131,11 +134,13 @@ of `source`:
131
134
132
135
## Contribute
133
136
134
- See [ ` contributing.md ` in ` syntax-tree/hast ` ] [ contributing ] for ways to get
137
+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
135
138
started.
139
+ See [ ` support.md ` ] [ support ] for ways to get help.
136
140
137
- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
138
- repository, organisation, or community you agree to abide by its terms.
141
+ This project has a [ Code of Conduct] [ coc ] .
142
+ By interacting with this repository, organisation, or community you agree to
143
+ abide by its terms.
139
144
140
145
## License
141
146
@@ -155,32 +160,52 @@ repository, organisation, or community you agree to abide by its terms.
155
160
156
161
[ downloads ] : https://www.npmjs.com/package/hast-util-to-nlcst
157
162
163
+ [ size-badge ] : https://img.shields.io/bundlephobia/minzip/hast-util-to-nlcst.svg
164
+
165
+ [ size ] : https://bundlephobia.com/result?p=hast-util-to-nlcst
166
+
167
+ [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
168
+
169
+ [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
170
+
171
+ [ collective ] : https://opencollective.com/unified
172
+
158
173
[ chat-badge ] : https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
159
174
160
- [ chat ] : https://spectrum.chat/unified/rehype
175
+ [ chat ] : https://spectrum.chat/unified/syntax-tree
161
176
162
177
[ npm ] : https://docs.npmjs.com/cli/install
163
178
164
179
[ license ] : license
165
180
166
181
[ author ] : https://wooorm.com
167
182
168
- [ hast ] : https://github.com/syntax-tree/hast
169
-
170
- [ nlcst ] : https://github.com/syntax-tree/nlcst
183
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
171
184
172
- [ rehype-retext ] : https://github.com/rehypejs/rehype-retext
185
+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
173
186
174
- [ vfile ] : https://github.com/vfile/vfile
187
+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
175
188
176
189
[ english ] : https://github.com/wooorm/parse-english
177
190
178
191
[ latin ] : https://github.com/wooorm/parse-latin
179
192
180
193
[ dutch ] : https://github.com/wooorm/parse-dutch
181
194
182
- [ source ] : https://github.com/syntax-tree/nlcst#source
195
+ [ rehype-retext ] : https://github.com/rehypejs/rehype-retext
196
+
197
+ [ tree ] : https://github.com/syntax-tree/unist#tree
198
+
199
+ [ positional-information ] : https://github.com/syntax-tree/unist#positional-information
200
+
201
+ [ hast ] : https://github.com/syntax-tree/hast
202
+
203
+ [ hast-node ] : https://github.com/syntax-tree/hast#nodes
204
+
205
+ [ nlcst ] : https://github.com/syntax-tree/nlcst
183
206
184
- [ contributing ] : https://github.com/syntax-tree/hast/blob/master/contributing.md
207
+ [ nlcst-node ] : https://github.com/syntax-tree/nlcst#nodes
185
208
186
- [ coc ] : https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
209
+ [ vfile ] : https://github.com/vfile/vfile
210
+
211
+ [ source ] : https://github.com/syntax-tree/nlcst#source
0 commit comments