Last active
March 16, 2020 18:55
-
-
Save zpao/4f5ce1d96b11b8a70e07 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const jsdom = require('jsdom'); | |
const makeKey = (attr) => { | |
return attr.split(/[-:]/).map((s, i) => { | |
return i === 0 ? s : s[0].toUpperCase() + s.slice(1); | |
}).join(''); | |
} | |
const EXCLUDE = [ | |
'class', | |
'color', | |
'height', | |
'id', | |
'lang', | |
'max', | |
'media', | |
'method', | |
'min', | |
'name', | |
'style', | |
'target', | |
'type', | |
'width', | |
] | |
jsdom.env({ | |
url: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute', | |
done: function (err, window) { | |
const all = | |
[].slice.call(window.document.querySelector('#wikiArticle > div') | |
.querySelectorAll('li a')) | |
.map(a => a.textContent) | |
.filter(attr => EXCLUDE.indexOf(attr) === -1) | |
.sort(); | |
const map = {}; | |
let attrs = ''; | |
let names = ''; | |
all.forEach((attr) => { | |
var key = makeKey(attr); | |
var val = '0'; | |
if (key !== attr || attr !== attr.toLowerCase()) { | |
val = `'${attr}'`; | |
} | |
attrs += `${key}: ${val},\n`; | |
// if (key !== attr || key !== key.toLowerCase()) { | |
// names += `${key}: '${attr}',\n` | |
// } | |
}); | |
console.log(attrs, '\n\n\n', names); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment