|
1 |
| -'use strict'; |
| 1 | +'use strict' |
2 | 2 |
|
3 |
| -/* Dependencies. */ |
4 |
| -var assert = require('assert'); |
5 |
| -var array = require('x-is-array'); |
6 |
| -var zwitch = require('zwitch'); |
7 |
| -var mapz = require('mapz'); |
8 |
| -var unist = require('unist-util-assert'); |
| 3 | +var assert = require('assert') |
| 4 | +var array = require('x-is-array') |
| 5 | +var zwitch = require('zwitch') |
| 6 | +var mapz = require('mapz') |
| 7 | +var unist = require('unist-util-assert') |
9 | 8 |
|
10 | 9 | /* Construct. */
|
11 |
| -var mdast = zwitch('type'); |
| 10 | +var mdast = zwitch('type') |
12 | 11 |
|
13 | 12 | /* Expose. */
|
14 |
| -exports = unist.wrap(mdast); |
15 |
| -module.exports = exports; |
| 13 | +exports = unist.wrap(mdast) |
| 14 | +module.exports = exports |
16 | 15 |
|
17 |
| -exports.parent = unist.wrap(parent); |
18 |
| -exports.text = unist.text; |
19 |
| -exports.void = unist.void; |
20 |
| -exports.wrap = unist.wrap; |
21 |
| -exports.all = mapz(exports, {key: 'children', indices: false}); |
| 16 | +exports.parent = unist.wrap(parent) |
| 17 | +exports.text = unist.text |
| 18 | +exports.void = unist.void |
| 19 | +exports.wrap = unist.wrap |
| 20 | +exports.all = mapz(exports, {key: 'children', indices: false}) |
22 | 21 |
|
23 | 22 | /* Core interface. */
|
24 |
| -mdast.unknown = unknown; |
25 |
| -mdast.invalid = unknown; |
| 23 | +mdast.unknown = unknown |
| 24 | +mdast.invalid = unknown |
26 | 25 |
|
27 | 26 | /* Per-type handling. */
|
28 | 27 | mdast.handlers = {
|
@@ -53,184 +52,220 @@ mdast.handlers = {
|
53 | 52 | footnoteReference: unist.wrap(footnoteReference),
|
54 | 53 | table: unist.wrap(table),
|
55 | 54 | html: exports.text
|
56 |
| -}; |
| 55 | +} |
57 | 56 |
|
58 | 57 | function unknown(node, ancestor) {
|
59 |
| - unist(node, ancestor); |
| 58 | + unist(node, ancestor) |
60 | 59 | }
|
61 | 60 |
|
62 | 61 | function parent(node) {
|
63 |
| - unist.parent(node); |
64 |
| - exports.all(node); |
| 62 | + unist.parent(node) |
| 63 | + exports.all(node) |
65 | 64 | }
|
66 | 65 |
|
67 | 66 | function root(node, ancestor) {
|
68 |
| - parent(node); |
| 67 | + parent(node) |
69 | 68 |
|
70 |
| - assert.strictEqual(ancestor, undefined, '`root` should not have a parent'); |
| 69 | + assert.strictEqual(ancestor, undefined, '`root` should not have a parent') |
71 | 70 | }
|
72 | 71 |
|
73 | 72 | function list(node) {
|
74 |
| - parent(node); |
| 73 | + parent(node) |
75 | 74 |
|
76 | 75 | if (node.loose != null) {
|
77 |
| - assert.strictEqual(typeof node.loose, 'boolean', '`loose` must be `boolean`'); |
| 76 | + assert.strictEqual( |
| 77 | + typeof node.loose, |
| 78 | + 'boolean', |
| 79 | + '`loose` must be `boolean`' |
| 80 | + ) |
78 | 81 | }
|
79 | 82 |
|
80 | 83 | if (node.ordered != null) {
|
81 |
| - assert.strictEqual(typeof node.ordered, 'boolean', '`ordered` must be `boolean`'); |
| 84 | + assert.strictEqual( |
| 85 | + typeof node.ordered, |
| 86 | + 'boolean', |
| 87 | + '`ordered` must be `boolean`' |
| 88 | + ) |
82 | 89 | }
|
83 | 90 |
|
84 | 91 | if (!node.ordered) {
|
85 |
| - assert.ok(node.start == null, 'unordered lists must not have `start`'); |
| 92 | + assert.ok(node.start == null, 'unordered lists must not have `start`') |
86 | 93 | } else if (node.start != null) {
|
87 |
| - assert.strictEqual(typeof node.start, 'number', 'ordered lists must have `start`'); |
88 |
| - assert.ok(node.start >= 0, '`start` must be gte `0`'); |
| 94 | + assert.strictEqual( |
| 95 | + typeof node.start, |
| 96 | + 'number', |
| 97 | + 'ordered lists must have `start`' |
| 98 | + ) |
| 99 | + assert.ok(node.start >= 0, '`start` must be gte `0`') |
89 | 100 | }
|
90 | 101 | }
|
91 | 102 |
|
92 | 103 | function listItem(node) {
|
93 |
| - parent(node); |
| 104 | + parent(node) |
94 | 105 |
|
95 | 106 | if (node.loose != null) {
|
96 |
| - assert.strictEqual(typeof node.loose, 'boolean', '`loose` must be `boolean`'); |
| 107 | + assert.strictEqual( |
| 108 | + typeof node.loose, |
| 109 | + 'boolean', |
| 110 | + '`loose` must be `boolean`' |
| 111 | + ) |
97 | 112 | }
|
98 | 113 |
|
99 | 114 | if (node.checked != null) {
|
100 |
| - assert.strictEqual(typeof node.checked, 'boolean', '`checked` must be `boolean`'); |
| 115 | + assert.strictEqual( |
| 116 | + typeof node.checked, |
| 117 | + 'boolean', |
| 118 | + '`checked` must be `boolean`' |
| 119 | + ) |
101 | 120 | }
|
102 | 121 | }
|
103 | 122 |
|
104 | 123 | function heading(node) {
|
105 |
| - parent(node); |
| 124 | + parent(node) |
106 | 125 |
|
107 |
| - assert.ok(node.depth > 0, '`depth` should be gte `1`'); |
108 |
| - assert.ok(node.depth <= 6, '`depth` should be lte `6`'); |
| 126 | + assert.ok(node.depth > 0, '`depth` should be gte `1`') |
| 127 | + assert.ok(node.depth <= 6, '`depth` should be lte `6`') |
109 | 128 | }
|
110 | 129 |
|
111 | 130 | function code(node) {
|
112 |
| - unist.text(node); |
| 131 | + unist.text(node) |
113 | 132 |
|
114 | 133 | if (node.lang != null) {
|
115 |
| - assert.strictEqual(typeof node.lang, 'string', '`lang` must be `string`'); |
| 134 | + assert.strictEqual(typeof node.lang, 'string', '`lang` must be `string`') |
116 | 135 | }
|
117 | 136 | }
|
118 | 137 |
|
119 | 138 | function footnoteDefinition(node) {
|
120 |
| - parent(node); |
| 139 | + parent(node) |
121 | 140 |
|
122 |
| - assert.strictEqual(typeof node.identifier, 'string', '`footnoteDefinition` must have `identifier`'); |
| 141 | + assert.strictEqual( |
| 142 | + typeof node.identifier, |
| 143 | + 'string', |
| 144 | + '`footnoteDefinition` must have `identifier`' |
| 145 | + ) |
123 | 146 | }
|
124 | 147 |
|
125 | 148 | function definition(node) {
|
126 |
| - unist.void(node); |
| 149 | + unist.void(node) |
127 | 150 |
|
128 |
| - assert.strictEqual(typeof node.identifier, 'string', '`identifier` must be `string`'); |
| 151 | + assert.strictEqual( |
| 152 | + typeof node.identifier, |
| 153 | + 'string', |
| 154 | + '`identifier` must be `string`' |
| 155 | + ) |
129 | 156 |
|
130 | 157 | if (node.url != null) {
|
131 |
| - assert.strictEqual(typeof node.url, 'string', '`url` must be `string`'); |
| 158 | + assert.strictEqual(typeof node.url, 'string', '`url` must be `string`') |
132 | 159 | }
|
133 | 160 |
|
134 | 161 | if (node.title != null) {
|
135 |
| - assert.strictEqual(typeof node.title, 'string', '`title` must be `string`'); |
| 162 | + assert.strictEqual(typeof node.title, 'string', '`title` must be `string`') |
136 | 163 | }
|
137 | 164 | }
|
138 | 165 |
|
139 | 166 | function link(node) {
|
140 |
| - parent(node); |
| 167 | + parent(node) |
141 | 168 |
|
142 | 169 | if (node.url != null) {
|
143 |
| - assert.strictEqual(typeof node.url, 'string', '`url` must be `string`'); |
| 170 | + assert.strictEqual(typeof node.url, 'string', '`url` must be `string`') |
144 | 171 | }
|
145 | 172 |
|
146 | 173 | if (node.title != null) {
|
147 |
| - assert.strictEqual(typeof node.title, 'string', '`title` must be `string`'); |
| 174 | + assert.strictEqual(typeof node.title, 'string', '`title` must be `string`') |
148 | 175 | }
|
149 | 176 | }
|
150 | 177 |
|
151 | 178 | function image(node) {
|
152 |
| - unist.void(node); |
| 179 | + unist.void(node) |
153 | 180 |
|
154 | 181 | if (node.url != null) {
|
155 |
| - assert.strictEqual(typeof node.url, 'string', '`url` must be `string`'); |
| 182 | + assert.strictEqual(typeof node.url, 'string', '`url` must be `string`') |
156 | 183 | }
|
157 | 184 |
|
158 | 185 | if (node.alt != null) {
|
159 |
| - assert.strictEqual(typeof node.alt, 'string', '`alt` must be `string`'); |
| 186 | + assert.strictEqual(typeof node.alt, 'string', '`alt` must be `string`') |
160 | 187 | }
|
161 | 188 |
|
162 | 189 | if (node.title != null) {
|
163 |
| - assert.strictEqual(typeof node.title, 'string', '`title` must be `string`'); |
| 190 | + assert.strictEqual(typeof node.title, 'string', '`title` must be `string`') |
164 | 191 | }
|
165 | 192 | }
|
166 | 193 |
|
167 | 194 | function linkReference(node) {
|
168 |
| - parent(node); |
| 195 | + parent(node) |
169 | 196 |
|
170 |
| - assert.strictEqual(typeof node.identifier, 'string', '`identifier` must be `string`'); |
| 197 | + assert.strictEqual( |
| 198 | + typeof node.identifier, |
| 199 | + 'string', |
| 200 | + '`identifier` must be `string`' |
| 201 | + ) |
171 | 202 |
|
172 | 203 | if (node.referenceType != null) {
|
173 | 204 | assert.notStrictEqual(
|
174 | 205 | ['shortcut', 'collapsed', 'full'].indexOf(node.referenceType),
|
175 | 206 | -1,
|
176 | 207 | '`referenceType` must be `shortcut`, `collapsed`, or `full`'
|
177 |
| - ); |
| 208 | + ) |
178 | 209 | }
|
179 | 210 | }
|
180 | 211 |
|
181 | 212 | function imageReference(node) {
|
182 |
| - unist.void(node); |
| 213 | + unist.void(node) |
183 | 214 |
|
184 | 215 | assert.strictEqual(
|
185 | 216 | typeof node.identifier,
|
186 | 217 | 'string',
|
187 | 218 | '`identifier` must be `string`'
|
188 |
| - ); |
| 219 | + ) |
189 | 220 |
|
190 | 221 | if (node.alt != null) {
|
191 |
| - assert.strictEqual(typeof node.alt, 'string', '`alt` must be `string`'); |
| 222 | + assert.strictEqual(typeof node.alt, 'string', '`alt` must be `string`') |
192 | 223 | }
|
193 | 224 |
|
194 | 225 | if (node.referenceType != null) {
|
195 | 226 | assert.notStrictEqual(
|
196 | 227 | ['shortcut', 'collapsed', 'full'].indexOf(node.referenceType),
|
197 | 228 | -1,
|
198 | 229 | '`referenceType` must be `shortcut`, `collapsed`, or `full`'
|
199 |
| - ); |
| 230 | + ) |
200 | 231 | }
|
201 | 232 | }
|
202 | 233 |
|
203 | 234 | function footnoteReference(node) {
|
204 |
| - unist.void(node); |
| 235 | + unist.void(node) |
205 | 236 |
|
206 |
| - assert.strictEqual(typeof node.identifier, 'string', '`identifier` must be `string`'); |
| 237 | + assert.strictEqual( |
| 238 | + typeof node.identifier, |
| 239 | + 'string', |
| 240 | + '`identifier` must be `string`' |
| 241 | + ) |
207 | 242 | }
|
208 | 243 |
|
209 | 244 | function table(node) {
|
210 |
| - var align; |
211 |
| - var val; |
212 |
| - var length; |
213 |
| - var index; |
| 245 | + var align |
| 246 | + var val |
| 247 | + var length |
| 248 | + var index |
214 | 249 |
|
215 |
| - parent(node); |
| 250 | + parent(node) |
216 | 251 |
|
217 |
| - align = node.align; |
| 252 | + align = node.align |
218 | 253 |
|
219 | 254 | if (align != null) {
|
220 |
| - assert.ok(array(align), '`align` must be `array`'); |
| 255 | + assert.ok(array(align), '`align` must be `array`') |
221 | 256 |
|
222 |
| - length = align.length; |
223 |
| - index = -1; |
| 257 | + length = align.length |
| 258 | + index = -1 |
224 | 259 |
|
225 | 260 | while (++index < length) {
|
226 |
| - val = align[index]; |
| 261 | + val = align[index] |
227 | 262 |
|
228 | 263 | if (val != null) {
|
229 | 264 | assert.notStrictEqual(
|
230 | 265 | ['left', 'right', 'center'].indexOf(val),
|
231 | 266 | -1,
|
232 |
| - 'each align in table must be `null, \'left\', \'right\', \'center\'`' |
233 |
| - ); |
| 267 | + "each align in table must be `null, 'left', 'right', 'center'`" |
| 268 | + ) |
234 | 269 | }
|
235 | 270 | }
|
236 | 271 | }
|
|
0 commit comments