Skip to content

Commit 4506fc4

Browse files
committed
Initial commit
0 parents  commit 4506fc4

24 files changed

+1323
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
*.log
3+
.nyc_output/
4+
coverage/
5+
node_modules/
6+
mdast-util-assert.js
7+
mdast-util-assert.min.js

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
node_js:
3+
- '0.11'
4+
- '0.12'
5+
- '4.0'
6+
- '5.0'
7+
- '6.0'
8+
after_success: bash <(curl -s https://codecov.io/bash)
9+
deploy:
10+
- provider: npm
11+
email: tituswormer@gmail.com
12+
api_key:
13+
secure: 2FHE7xThoyqQkEeWdCiJ/19PCcYrY0QK/gBnIWbLdIjCcVgAHziPOrappX2ADHGE+jOZtvddLMKY6hA+1XYxpiVaJy5BnacvjPEC9IypQh2HZO1rbALasecXcEjDYwWHfpR9T4nSGybn5fNrINX4xIYwjhgcsC3T/+OmcNCG6iaXXmsRPtl3zu2ikuQr2wzjJdZgmNxuN1eD4erDTECOiW3WIcGe5oVZgXWq6p0ezGOMO03dZPc8Wn30QOvZh7exMcoJN/GD8fUWobkxM6Wiw9js8DT4VKu/UZK6nMitwzTLlYryMs9XOM3uQUY15P5YJFvZ1JKi2yCdXH1+ddBL8Llrd89Q3S9wqaK2HiMjBDnbyaf4YY+mbfVOIkjkxj9JhE2GXqvzTKu0Ctq/VSV/m3d2Iv5GqwkOTAQZX8hA2JG9FYeryt1VigjOdeeW8Xka4WVfm0ZkY/3MmYvpaFCWPMl7pjOwbWCcRuV5+lcMGYSw9EzNBQmlZKK2xI/KUwhEClu8qShVX52MaIpnEP3vsEHQ4V5HcylPOip+gP3R4Y6Ck5FPCxh9nb1RSpXoj0ks3qk4E2qVE2XKRCimzVNFBt173tJHeI7ghCN4svbrUzZ8keltNTwJ+SuTPMg4lnNNcnSgZAy0vN83xTdt1wZlyrF+gIloLK8yekswi4Z8j1s=
14+
on:
15+
tags: true
16+
node: '5.0'
17+
- provider: releases
18+
api_key:
19+
secure: Kt8bUA2b9u5Iia6Fq3z4FGLIdXR3YRsojLrmWnk0VAUZNsA0oBm/9/K5ehbMrwhhyn+NMsYQQ5tiDCHWk9n45Eb8TVXPJZXCgs5kh64IPp4pqoKITYcArg325GcZfjG/tj7X+cuWVaxVDG5MA7h78DacC9jyV0nK6dIlCcWM3/vlwGJPyvUo53eFPLRudjSmHBLefsr10UBZ4xr7dcklQJ4UJXAVjVX6+3kUH671idH++Ey2/nns/57BYIdXMIt334JSNm0noT5cOG+lzP6Tk1aSMCtSryNpCi6fw/49duelhQNnEqXa7gDy2DIL8eB7wwtZr3rprw319kPirTpxaLEPulC2ZYCJjaFuw3IquTljDBwEc4FfFwOp+Q1cn/OoHAvnkstGTNhFE+8YAX79RF9nNt1XFYDJ8g8VfX7ndYiDuZIVeGE6jIEafd3iPfGhWKdqNTlTUx024SjvT4BwvfASC2pfyZyy4aNYtr+tDrUebBectngzPRt0rf90w5EocSQVwmzls6ESEaHlLnkjYosGXG2ERCUXON7/I32x7k7LlLrilsIRCsbCweZtg4w7y8J9p1jVKlwCoqjJuGbM61u2veQSwuavzwI7aRSSvc5HrxzNUJc4Tzxxj3Ee+f+9WgKh32IOrPz/ozUTwLaigJXslCcxBzz0QTSGQ10iBXs=
20+
file:
21+
- "mdast-util-assert.js"
22+
- "mdast-util-assert.min.js"
23+
on:
24+
tags: true
25+
node: '6.0'

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 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.

history.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--remark setext-->
2+
3+
<!--lint disable no-multiple-toplevel-headings -->
4+
5+
0.0.0 / 2016-07-19
6+
==================

index.js

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2016 Titus Wormer
4+
* @license MIT
5+
* @module mdast-util-assert
6+
* @fileoverview Assert `unist` nodes.
7+
*/
8+
9+
'use strict';
10+
11+
/* eslint-env commonjs */
12+
/* eslint-disable babel/new-cap */
13+
14+
/* Dependencies. */
15+
var assert = require('assert');
16+
var array = require('x-is-array');
17+
var zwitch = require('zwitch');
18+
var mapz = require('mapz');
19+
var unist = require('unist-util-assert');
20+
21+
/* Construct. */
22+
var mdast = zwitch('type');
23+
24+
/* Expose. */
25+
module.exports = exports = unist.wrap(mdast);
26+
27+
exports.parent = unist.wrap(parent);
28+
exports.text = unist.text;
29+
exports.void = unist.void;
30+
exports.wrap = unist.wrap;
31+
exports.all = mapz(exports, {key: 'children', indices: false});
32+
33+
/* Core interface. */
34+
mdast.invalid = mdast.unknown = unknown;
35+
36+
/* Per-type handling. */
37+
mdast.handlers = {
38+
root: unist.wrap(root),
39+
paragraph: exports.parent,
40+
blockquote: exports.parent,
41+
tableRow: exports.parent,
42+
tableCell: exports.parent,
43+
strong: exports.parent,
44+
emphasis: exports.parent,
45+
delete: exports.parent,
46+
listItem: unist.wrap(listItem),
47+
footnote: exports.parent,
48+
heading: unist.wrap(heading),
49+
text: exports.text,
50+
inlineCode: exports.text,
51+
yaml: exports.text,
52+
code: unist.wrap(code),
53+
thematicBreak: exports.void,
54+
break: exports.void,
55+
list: unist.wrap(list),
56+
footnoteDefinition: unist.wrap(footnoteDefinition),
57+
definition: unist.wrap(definition),
58+
link: unist.wrap(link),
59+
image: unist.wrap(image),
60+
linkReference: unist.wrap(linkReference),
61+
imageReference: unist.wrap(imageReference),
62+
footnoteReference: unist.wrap(footnoteReference),
63+
table: unist.wrap(table),
64+
html: exports.text
65+
};
66+
67+
function unknown(node, ancestor) {
68+
unist(node, ancestor);
69+
}
70+
71+
function parent(node) {
72+
unist.parent(node);
73+
exports.all(node);
74+
}
75+
76+
function root(node, ancestor) {
77+
parent(node);
78+
79+
assert.equal(ancestor, undefined, '`root` should not have a parent');
80+
}
81+
82+
function list(node) {
83+
parent(node);
84+
85+
if (node.loose != null) {
86+
assert.equal(typeof node.loose, 'boolean', '`loose` must be `boolean`');
87+
}
88+
89+
if (node.ordered != null) {
90+
assert.equal(typeof node.ordered, 'boolean', '`ordered` must be `boolean`');
91+
}
92+
93+
if (!node.ordered) {
94+
assert.ok(node.start == null, 'unordered lists must not have `start`');
95+
} else if (node.start != null) {
96+
assert.equal(typeof node.start, 'number', 'ordered lists must have `start`');
97+
assert.ok(node.start >= 0, '`start` must be gte `0`');
98+
}
99+
}
100+
101+
function listItem(node) {
102+
parent(node);
103+
104+
if (node.loose != null) {
105+
assert.equal(typeof node.loose, 'boolean', '`loose` must be `boolean`');
106+
}
107+
108+
if (node.checked != null) {
109+
assert.equal(typeof node.checked, 'boolean', '`checked` must be `boolean`');
110+
}
111+
}
112+
113+
function heading(node) {
114+
parent(node);
115+
116+
assert.ok(node.depth > 0, '`depth` should be gte `1`');
117+
assert.ok(node.depth <= 6, '`depth` should be lte `6`');
118+
}
119+
120+
function code(node) {
121+
unist.text(node);
122+
123+
if (node.lang != null) {
124+
assert.equal(typeof node.lang, 'string', '`lang` must be `string`');
125+
}
126+
}
127+
128+
function footnoteDefinition(node) {
129+
parent(node);
130+
131+
assert.equal(typeof node.identifier, 'string', '`footnoteDefinition` must have `identifier`');
132+
}
133+
134+
function definition(node) {
135+
unist.void(node);
136+
137+
assert.equal(typeof node.identifier, 'string', '`identifier` must be `string`');
138+
139+
if (node.url != null) {
140+
assert.equal(typeof node.url, 'string', '`url` must be `string`');
141+
}
142+
143+
if (node.title != null) {
144+
assert.equal(typeof node.title, 'string', '`title` must be `string`');
145+
}
146+
}
147+
148+
function link(node) {
149+
parent(node);
150+
151+
if (node.url != null) {
152+
assert.equal(typeof node.url, 'string', '`url` must be `string`');
153+
}
154+
155+
if (node.title != null) {
156+
assert.equal(typeof node.title, 'string', '`title` must be `string`');
157+
}
158+
}
159+
160+
function image(node) {
161+
unist.void(node);
162+
163+
if (node.url != null) {
164+
assert.equal(typeof node.url, 'string', '`url` must be `string`');
165+
}
166+
167+
if (node.alt != null) {
168+
assert.equal(typeof node.alt, 'string', '`alt` must be `string`');
169+
}
170+
171+
if (node.title != null) {
172+
assert.equal(typeof node.title, 'string', '`title` must be `string`');
173+
}
174+
}
175+
176+
function linkReference(node) {
177+
parent(node);
178+
179+
assert.equal(typeof node.identifier, 'string', '`identifier` must be `string`');
180+
181+
if (node.referenceType != null) {
182+
assert.notEqual(
183+
['shortcut', 'collapsed', 'full'].indexOf(node.referenceType),
184+
-1,
185+
'`referenceType` must be `shortcut`, `collapsed`, or `full`'
186+
);
187+
}
188+
}
189+
190+
function imageReference(node) {
191+
unist.void(node);
192+
193+
assert.equal(
194+
typeof node.identifier,
195+
'string',
196+
'`identifier` must be `string`'
197+
);
198+
199+
if (node.alt != null) {
200+
assert.equal(typeof node.alt, 'string', '`alt` must be `string`');
201+
}
202+
203+
if (node.referenceType != null) {
204+
assert.notEqual(
205+
['shortcut', 'collapsed', 'full'].indexOf(node.referenceType),
206+
-1,
207+
'`referenceType` must be `shortcut`, `collapsed`, or `full`'
208+
);
209+
}
210+
}
211+
212+
function footnoteReference(node) {
213+
unist.void(node);
214+
215+
assert.equal(typeof node.identifier, 'string', '`identifier` must be `string`');
216+
}
217+
218+
function table(node) {
219+
var align;
220+
var val;
221+
var length;
222+
var index;
223+
224+
parent(node);
225+
226+
align = node.align;
227+
228+
if (align != null) {
229+
assert.ok(array(align), '`align` must be `array`');
230+
231+
length = align.length;
232+
index = -1;
233+
234+
while (++index < length) {
235+
val = align[index];
236+
237+
if (val != null) {
238+
assert.notEqual(
239+
['left', 'right', 'center'].indexOf(val),
240+
-1,
241+
'each align in table must be `null, \'left\', \'right\', \'center\'`'
242+
);
243+
}
244+
}
245+
}
246+
}

0 commit comments

Comments
 (0)