-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
68 additions
and
51 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 @@ | ||
svg-tag-names.js | ||
svg-tag-names.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,43 +1,49 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var fs = require('fs') | ||
var https = require('https') | ||
var bail = require('bail') | ||
var concat = require('concat-stream') | ||
var unified = require('unified') | ||
var parse = require('rehype-parse') | ||
var selectAll = require('hast-util-select').selectAll | ||
var toString = require('hast-util-to-string') | ||
var list = require('.') | ||
|
||
var urls = [ | ||
'https://www.w3.org/TR/SVG11/eltindex.html', | ||
'https://www.w3.org/TR/SVGTiny12/elementTable.html', | ||
'https://www.w3.org/TR/SVG2/eltindex.html' | ||
] | ||
|
||
var fs = require('fs'); | ||
var https = require('https'); | ||
var bail = require('bail'); | ||
var concat = require('concat-stream'); | ||
var unified = require('unified'); | ||
var parse = require('rehype-parse'); | ||
var selectAll = require('hast-util-select').selectAll; | ||
var toString = require('hast-util-to-string'); | ||
var list = require('.'); | ||
var proc = unified().use(parse) | ||
|
||
var proc = unified().use(parse); | ||
var count = 0 | ||
|
||
var count = 0; | ||
urls.forEach(each) | ||
|
||
[ | ||
"https://www.w3.org/TR/SVG11/eltindex.html", | ||
"https://www.w3.org/TR/SVGTiny12/elementTable.html", | ||
"https://www.w3.org/TR/SVG2/eltindex.html" | ||
].forEach(function (url, c, all) { | ||
https.get(url, function (res) { | ||
res.pipe(concat(onconcat)).on("error", bail); | ||
function each(url) { | ||
https.get(url, onconnection) | ||
} | ||
|
||
function onconnection(res) { | ||
res.pipe(concat(onconcat)).on("error", bail) | ||
} | ||
|
||
function onconcat(buf) { | ||
selectAll(".element-name", proc.parse(buf)).forEach(each); | ||
function onconcat(buf) { | ||
selectAll(".element-name", proc.parse(buf)).forEach(add) | ||
|
||
count++; | ||
count++ | ||
|
||
if (count === all.length) { | ||
fs.writeFile("index.json", JSON.stringify(list.sort(), 0, 2) + "\n", bail); | ||
} | ||
if (count === urls.length) { | ||
fs.writeFile("index.json", JSON.stringify(list.sort(), 0, 2) + "\n", bail) | ||
} | ||
|
||
function each(node) { | ||
var data = toString(node).slice(1, -1); | ||
function add(node) { | ||
var data = toString(node).slice(1, -1) | ||
|
||
if (data && list.indexOf(data) === -1) { | ||
list.push(data); | ||
} | ||
} | ||
if (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,14 +1,14 @@ | ||
"use strict"; | ||
"use strict" | ||
|
||
var test = require("tape"); | ||
var svgTagNames = require("."); | ||
var test = require("tape") | ||
var svgTagNames = require(".") | ||
|
||
test("svgTagNames", function (t) { | ||
t.ok(Array.isArray(svgTagNames), "should be an `array`"); | ||
test("svgTagNames", function(t) { | ||
t.ok(Array.isArray(svgTagNames), "should be an `array`") | ||
|
||
svgTagNames.forEach(function (tagName) { | ||
t.equal(typeof tagName, "string", "`" + tagName + "` should be a string"); | ||
}); | ||
svgTagNames.forEach(function(tagName) { | ||
t.equal(typeof tagName, "string", "`" + tagName + "` should be a string") | ||
}) | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |