Skip to content

Commit d096a9e

Browse files
committed
Update dependencies, dev-dependencies
1 parent 5f97b61 commit d096a9e

File tree

9 files changed

+61
-160
lines changed

9 files changed

+61
-160
lines changed

.jscs.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
"mdast-zone.js",
88
"mdast-zone.min.js"
99
],
10-
"preset": "yandex",
11-
"requireQuotedKeysInObjects": true,
12-
"disallowQuotedKeysInObjects": false,
10+
"preset": "crockford",
11+
"requireMultipleVarDecl": false,
12+
"requireVarDeclFirst": false,
13+
"disallowDanglingUnderscores": false,
1314
"maximumLineLength": {
1415
"value": 79,
1516
"allExcept": [
1617
"regex",
17-
"urlComments"
18+
"urlComments",
19+
"require"
1820
]
1921
},
22+
"requireQuotedKeysInObjects": true,
23+
"disallowKeywords": [
24+
"with"
25+
],
2026
"jsDoc": {
2127
"checkAnnotations": "jsdoc3",
2228
"checkParamExistence": true,

index.js

Lines changed: 17 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Dependencies.
1515
*/
1616

17+
var trim = require('trim');
18+
var commentMarker = require('mdast-comment-marker');
1719
var visit = require('unist-util-visit');
1820

1921
/*
@@ -22,111 +24,6 @@ var visit = require('unist-util-visit');
2224

2325
var splice = [].splice;
2426

25-
/*
26-
* Expression for parsing parameters.
27-
*/
28-
29-
var PARAMETERS = new RegExp(
30-
'\\s*' +
31-
'(' +
32-
'[-a-z09_]+' +
33-
')' +
34-
'(?:' +
35-
'=' +
36-
'(?:' +
37-
'"' +
38-
'(' +
39-
'(?:' +
40-
'\\\\[\\s\\S]' +
41-
'|' +
42-
'[^"]' +
43-
')+' +
44-
')' +
45-
'"' +
46-
'|' +
47-
'\'' +
48-
'(' +
49-
'(?:' +
50-
'\\\\[\\s\\S]' +
51-
'|' +
52-
'[^\']' +
53-
')+' +
54-
')' +
55-
'\'' +
56-
'|' +
57-
'(' +
58-
'(?:' +
59-
'\\\\[\\s\\S]' +
60-
'|' +
61-
'[^"\'\\s]' +
62-
')+' +
63-
')' +
64-
')' +
65-
')?' +
66-
'\\s*',
67-
'gi'
68-
);
69-
70-
/**
71-
* Create an expression which matches a marker.
72-
*
73-
* @param {string} name - Plug-in name.
74-
* @return {RegExp} - Expression.
75-
*/
76-
function marker(name) {
77-
return new RegExp(
78-
'(' +
79-
'\\s*' +
80-
'<!--' +
81-
'\\s*' +
82-
'(' +
83-
name +
84-
')' +
85-
'\\s*' +
86-
'(' +
87-
'start' +
88-
'|' +
89-
'end' +
90-
')?' +
91-
'\\s*' +
92-
'(' +
93-
'[\\s\\S]*?' +
94-
')' +
95-
'\\s*' +
96-
'-->' +
97-
'\\s*' +
98-
')'
99-
);
100-
}
101-
102-
/**
103-
* Parse `value` into an object.
104-
*
105-
* @param {string} value - HTML comment.
106-
* @return {Object} - Parsed parameters.
107-
*/
108-
function parameters(value) {
109-
var attributes = {};
110-
111-
value.replace(PARAMETERS, function ($0, $1, $2, $3, $4) {
112-
var result = $2 || $3 || $4 || '';
113-
114-
if (result === 'true' || result === '') {
115-
result = true;
116-
} else if (result === 'false') {
117-
result = false;
118-
} else if (!isNaN(result)) {
119-
result = Number(result);
120-
}
121-
122-
attributes[$1] = result;
123-
124-
return '';
125-
});
126-
127-
return attributes;
128-
}
129-
13027
/**
13128
* Factory to test if `node` matches `settings`.
13229
*
@@ -137,7 +34,6 @@ function parameters(value) {
13734
*/
13835
function testFactory(settings, callback) {
13936
var name = settings.name;
140-
var expression = marker(name);
14137

14238
/**
14339
* Test if `node` matches the bound settings.
@@ -147,37 +43,30 @@ function testFactory(settings, callback) {
14743
* @return {Object?} - Whether `node` matches.
14844
*/
14945
function test(node, context) {
150-
var value;
151-
var match;
152-
var result;
46+
var marker = commentMarker(node);
47+
var attributes;
48+
var head;
15349

154-
if (!node || node.type !== 'html') {
50+
if (!marker || marker.name !== name) {
15551
return null;
15652
}
15753

158-
value = node.value;
159-
match = value.match(expression);
54+
attributes = marker.attributes;
55+
head = attributes.match(/(start|end)\b/);
16056

161-
if (
162-
!match ||
163-
match[1].length !== value.length ||
164-
match[2] !== settings.name
165-
) {
166-
return null;
57+
if (head) {
58+
head = head[0];
59+
marker.attributes = trim.left(attributes.slice(head.length));
60+
marker.parameters[head] = undefined;
16761
}
16862

169-
result = {
170-
'type': match[3] || 'marker',
171-
'attributes': match[4] || '',
172-
'parameters': parameters(match[4] || ''),
173-
'node': node
174-
};
63+
marker.type = head || 'marker';
17564

17665
if (callback) {
177-
callback(result, context);
66+
callback(marker, context);
17867
}
17968

180-
return result;
69+
return marker;
18170
}
18271

18372
return test;
@@ -331,11 +220,11 @@ function attacher(mdast, options) {
331220
var parser = mdast.Parser.prototype;
332221
var blockTokenizers = parser.blockTokenizers;
333222
var inlineTokenizers = parser.inlineTokenizers;
334-
var stringifiers = mdast.Compiler.prototype;
223+
var stringifiers = mdast.Compiler.prototype.visitors;
335224

336225
if (options.onparse) {
337226
blockTokenizers.html = parse(blockTokenizers.html, options);
338-
inlineTokenizers.tag = parse(inlineTokenizers.tag, options);
227+
inlineTokenizers.html = parse(inlineTokenizers.html, options);
339228
}
340229

341230
if (options.onstringify) {

package.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,37 @@
1313
"mdast"
1414
],
1515
"dependencies": {
16+
"mdast-comment-marker": "^1.0.1",
17+
"trim": "0.0.1",
1618
"unist-util-visit": "^1.0.0"
1719
},
1820
"repository": {
1921
"type": "git",
2022
"url": "https://github.com/wooorm/mdast-zone.git"
2123
},
2224
"bugs": "https://github.com/wooorm/mdast-zone/issues",
23-
"author": "Titus Wormer <tituswormer@gmail.com>",
25+
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
26+
"contributors": [
27+
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
28+
],
2429
"files": [
2530
"index.js"
2631
],
2732
"devDependencies": {
2833
"browserify": "^13.0.0",
29-
"eslint": "^1.0.0",
34+
"eslint": "^2.0.0",
3035
"esmangle": "^1.0.0",
3136
"istanbul": "^0.4.0",
32-
"jscs": "^2.0.0",
33-
"jscs-jsdoc": "^1.0.0",
34-
"remark": "^3.0.0",
35-
"remark-github": "^3.0.0",
36-
"remark-lint": "^2.0.0",
37-
"remark-toc": "^2.0.0",
38-
"remark-usage": "^2.0.0",
39-
"remark-validate-links": "^2.0.0",
40-
"remark-yaml-config": "^2.0.0",
37+
"jscs": "^3.0.0",
38+
"jscs-jsdoc": "^2.0.0",
39+
"remark": "^5.0.0",
40+
"remark-cli": "^1.0.0",
41+
"remark-github": "^5.0.0",
42+
"remark-lint": "^4.0.0",
43+
"remark-toc": "^3.0.0",
44+
"remark-usage": "^4.0.0",
45+
"remark-validate-links": "^4.0.0",
46+
"remark-yaml-config": "^3.0.0",
4147
"tape": "^4.4.0"
4248
},
4349
"scripts": {

test/fixture/attributes-boolean-false/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function assertion(zone, t) {
3030
/**
3131
* Plug-in.
3232
*
33-
* @param {Remark} remark - Processor.
33+
* @param {Unified} processor - Processor.
3434
*/
35-
function plugin(remark) {
36-
remark.use(zone({
35+
function plugin(processor) {
36+
processor.use(zone({
3737
'name': 'foo',
3838
'onparse': onparse
3939
}));

test/fixture/attributes-boolean-true/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function assertion(zone, t) {
3030
/**
3131
* Plug-in.
3232
*
33-
* @param {Remark} remark - Processor.
33+
* @param {Unified} processor - Processor.
3434
*/
35-
function plugin(remark) {
36-
remark.use(zone({
35+
function plugin(processor) {
36+
processor.use(zone({
3737
'name': 'foo',
3838
'onparse': onparse
3939
}));

test/fixture/attributes-empty/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function assertion(zone, t) {
3030
/**
3131
* Plug-in.
3232
*
33-
* @param {Remark} remark - Processor.
33+
* @param {Unified} processor - Processor.
3434
*/
35-
function plugin(remark) {
36-
remark.use(zone({
35+
function plugin(processor) {
36+
processor.use(zone({
3737
'name': 'foo',
3838
'onparse': onparse
3939
}));

test/fixture/attributes-number/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ function assertion(zone, t) {
4242
/**
4343
* Plug-in.
4444
*
45-
* @param {Remark} remark - Processor.
45+
* @param {Unified} processor - Processor.
4646
*/
47-
function plugin(remark) {
48-
remark.use(zone({
47+
function plugin(processor) {
48+
processor.use(zone({
4949
'name': 'foo',
5050
'onparse': onparse
5151
}));

test/fixture/attributes-quoted-double/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function assertion(zone, t) {
3030
/**
3131
* Plug-in.
3232
*
33-
* @param {Remark} remark - Processor.
33+
* @param {Unified} processor - Processor.
3434
*/
35-
function plugin(remark) {
36-
remark.use(zone({
35+
function plugin(processor) {
36+
processor.use(zone({
3737
'name': 'foo',
3838
'onparse': onparse
3939
}));

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ test('Fixtures', function (t) {
4747
fixtures.forEach(function (fixture) {
4848
var processor = remark().use(fixture.test(zone, t));
4949

50-
processor.process(fixture.input, function (err, file, doc) {
50+
processor.process(fixture.input, function (err, file) {
5151
t.ifError(err, 'should not fail (' + fixture.name + ')');
5252

5353
if (fixture.output) {
5454
t.equal(
55-
doc,
55+
String(file),
5656
fixture.output,
5757
'should stringify ' + fixture.name
5858
);

0 commit comments

Comments
 (0)