Skip to content

Instantly share code, notes, and snippets.

@zpao
Last active March 16, 2020 18:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zpao/4f5ce1d96b11b8a70e07 to your computer and use it in GitHub Desktop.
Save zpao/4f5ce1d96b11b8a70e07 to your computer and use it in GitHub Desktop.
'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