Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
html-void-elements.js | ||
html-void-elements.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var fs = require('fs'); | ||
var https = require('https'); | ||
var concat = require('concat-stream'); | ||
var unified = require('unified'); | ||
var html = require('rehype-parse'); | ||
var q = require('hast-util-select'); | ||
var toString = require('hast-util-to-string'); | ||
var bail = require('bail'); | ||
var list = require('.'); | ||
var fs = require('fs') | ||
var https = require('https') | ||
var concat = require('concat-stream') | ||
var unified = require('unified') | ||
var html = require('rehype-parse') | ||
var q = require('hast-util-select') | ||
var toString = require('hast-util-to-string') | ||
var bail = require('bail') | ||
var list = require('.') | ||
|
||
https.get('https://html.spec.whatwg.org/multipage/syntax.html#elements-2', function (res) { | ||
res.pipe(concat(onconcat)).on('error', bail); | ||
var proc = unified().use(html) | ||
|
||
function onconcat(buf) { | ||
var dl = q.select('#elements-2 ~ dl dd', unified().use(html).parse(buf)); | ||
https.get('https://html.spec.whatwg.org/multipage/syntax.html', onconnection) | ||
|
||
q.selectAll('code', dl).forEach(each); | ||
function onconnection(res) { | ||
res.pipe(concat(onconcat)).on('error', bail) | ||
} | ||
|
||
fs.writeFile('index.json', JSON.stringify(list.sort(), 0, 2) + '\n', bail); | ||
function onconcat(buf) { | ||
var dl = q.select('#elements-2 ~ dl dd', proc.parse(buf)) | ||
|
||
function each(node) { | ||
var data = toString(node); | ||
q.selectAll('code', dl).forEach(each) | ||
|
||
if (data && !/\s/.test(data) && list.indexOf(data) === -1) { | ||
list.push(data); | ||
} | ||
} | ||
fs.writeFile('index.json', JSON.stringify(list.sort(), 0, 2) + '\n', bail) | ||
} | ||
|
||
function each(node) { | ||
var data = toString(node) | ||
|
||
if (data && !/\s/.test(data) && list.indexOf(data) === -1) { | ||
list.push(data) | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var test = require('tape'); | ||
var htmlVoidElements = require('.'); | ||
var test = require('tape') | ||
var htmlVoidElements = require('.') | ||
|
||
test('htmlVoidElements', function (t) { | ||
t.ok( | ||
Array.isArray(htmlVoidElements), | ||
'should be an `array`' | ||
); | ||
test('htmlVoidElements', function(t) { | ||
t.ok(Array.isArray(htmlVoidElements), 'should be an `array`') | ||
|
||
htmlVoidElements.forEach(function (tagName) { | ||
t.equal( | ||
typeof tagName, | ||
'string', | ||
'`' + tagName + '` should be a string' | ||
); | ||
}); | ||
htmlVoidElements.forEach(function(tagName) { | ||
t.equal(typeof tagName, 'string', '`' + tagName + '` should be a string') | ||
}) | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |