Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 26, 2021
1 parent f78d73f commit f84811c
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 195 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DS_Store
*.log
coverage/
node_modules/
html-tag-names.js
html-tag-names.min.js
yarn.lock
4 changes: 0 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.nyc_output/
coverage/
*.md
*.json
html-tag-names.js
html-tag-names.min.js
40 changes: 22 additions & 18 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'

var fs = require('fs')
var https = require('https')
var concat = require('concat-stream')
var bail = require('bail')
var unified = require('unified')
var html = require('rehype-parse')
var selectAll = require('hast-util-select').selectAll
var toString = require('hast-util-to-string')
var list = require('.')
import fs from 'fs'
import https from 'https'
import concat from 'concat-stream'
import bail from 'bail'
import unified from 'unified'
import html from 'rehype-parse'
import select from 'hast-util-select'
import toString from 'hast-util-to-string'
import {htmlTagNames} from './index.js'

var proc = unified().use(html)

Expand All @@ -24,15 +22,15 @@ function onw3c(response) {
response.pipe(concat(onconcat)).on('error', bail)

function onconcat(buf) {
var nodes = selectAll('[scope="row"] code', proc.parse(buf))
var nodes = select.selectAll('[scope="row"] code', proc.parse(buf))
var index = -1
var data

while (++index < nodes.length) {
data = toString(nodes[index])

if (data && !/\s/.test(data) && !list.includes(data)) {
list.push(data)
if (data && !/\s/.test(data) && !htmlTagNames.includes(data)) {
htmlTagNames.push(data)
}
}

Expand All @@ -44,7 +42,7 @@ function onwhatwg(response) {
response.pipe(concat(onconcat)).on('error', bail)

function onconcat(buf) {
var nodes = selectAll('tbody th code', proc.parse(buf))
var nodes = select.selectAll('tbody th code', proc.parse(buf))
var index = -1
var id
var data
Expand All @@ -56,9 +54,9 @@ function onwhatwg(response) {
if (
id &&
id.slice(0, 'elements-3:'.length) === 'elements-3:' &&
!list.includes(data)
!htmlTagNames.includes(data)
) {
list.push(data)
htmlTagNames.push(data)
}
}

Expand All @@ -70,6 +68,12 @@ function done() {
count++

if (count === 2) {
fs.writeFile('index.json', JSON.stringify(list.sort(), 0, 2) + '\n', bail)
fs.writeFile(
'index.js',
'export var htmlTagNames = ' +
JSON.stringify(htmlTagNames.sort(), null, 2) +
'\n',
bail
)
}
}
150 changes: 150 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
export var htmlTagNames = [
'a',
'abbr',
'acronym',
'address',
'applet',
'area',
'article',
'aside',
'audio',
'b',
'base',
'basefont',
'bdi',
'bdo',
'bgsound',
'big',
'blink',
'blockquote',
'body',
'br',
'button',
'canvas',
'caption',
'center',
'cite',
'code',
'col',
'colgroup',
'command',
'content',
'data',
'datalist',
'dd',
'del',
'details',
'dfn',
'dialog',
'dir',
'div',
'dl',
'dt',
'element',
'em',
'embed',
'fieldset',
'figcaption',
'figure',
'font',
'footer',
'form',
'frame',
'frameset',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'head',
'header',
'hgroup',
'hr',
'html',
'i',
'iframe',
'image',
'img',
'input',
'ins',
'isindex',
'kbd',
'keygen',
'label',
'legend',
'li',
'link',
'listing',
'main',
'map',
'mark',
'marquee',
'math',
'menu',
'menuitem',
'meta',
'meter',
'multicol',
'nav',
'nextid',
'nobr',
'noembed',
'noframes',
'noscript',
'object',
'ol',
'optgroup',
'option',
'output',
'p',
'param',
'picture',
'plaintext',
'pre',
'progress',
'q',
'rb',
'rbc',
'rp',
'rt',
'rtc',
'ruby',
's',
'samp',
'script',
'section',
'select',
'shadow',
'slot',
'small',
'source',
'spacer',
'span',
'strike',
'strong',
'style',
'sub',
'summary',
'sup',
'svg',
'table',
'tbody',
'td',
'template',
'textarea',
'tfoot',
'th',
'thead',
'time',
'title',
'tr',
'track',
'tt',
'u',
'ul',
'var',
'video',
'wbr',
'xmp'
]
150 changes: 0 additions & 150 deletions index.json

This file was deleted.

Loading

0 comments on commit f84811c

Please sign in to comment.