pre-publish.js 891 B

1234567891011121314151617181920212223242526272829
  1. var cheerio = require('cheerio')
  2. , http = require('http');
  3. http.get('http://www.w3.org/html/wg/drafts/html/master/syntax.html', function (res) {
  4. var str = '';
  5. res.setEncoding('utf8');
  6. res.on('data', function (buf) {
  7. str += buf;
  8. }).on('end', function () {
  9. var $ = cheerio.load(str);
  10. var codes = $('dfn#void-elements')
  11. .parent()
  12. .next()
  13. .text()
  14. .replace(/\s/gm,'')
  15. .split(",")
  16. .reduce(function (obj, code) {
  17. obj[code] = true;
  18. return obj;
  19. }, {});
  20. console.log('/**');
  21. console.log(' * This file automatically generated from `pre-publish.js`.');
  22. console.log(' * Do not manually edit.');
  23. console.log(' */');
  24. console.log();
  25. console.log('module.exports = %s;', JSON.stringify(codes, null, 2));
  26. });
  27. });