@@ -6,13 +6,18 @@ const request = require('request');
6
6
7
7
const refUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element' ;
8
8
const dataPath = './data/elements.txt' ;
9
+ const expectedElCount = 131 ;
9
10
10
11
/**
11
12
* From the MDN HTML elements reference, extract a list of elements.
12
13
*/
13
14
function extractElements ( $ ) {
14
15
const excludeElements = [
15
16
'html' , 'head' , 'body' , 'style' , 'h1–h6' , 'input' ,
17
+ // out of scope, different namespaces - but Mozilla added these to the
18
+ // above reference page Jan 2021 so we need to exclude them now.
19
+ // see https://github.com/mdn/content/pull/410
20
+ 'svg' , 'math' ,
16
21
// obsolete, non-standard, or deprecated tags
17
22
'image' , 'dir' , 'tt' , 'applet' , 'noembed' , 'bgsound' , 'menu' , 'menuitem' ,
18
23
'noframes'
@@ -56,6 +61,12 @@ request(refUrl, (error, response, html) => {
56
61
}
57
62
const $ = cheerio . load ( html ) ;
58
63
const elements = extractElements ( $ ) ;
64
+ if ( elements . length !== expectedElCount ) {
65
+ throw new Error (
66
+ 'Unexpected number of elements extracted from ' + refUrl +
67
+ ' Check the output and edit expectedElCount if this is intended.'
68
+ ) ;
69
+ }
59
70
const out = elements . join ( '\n' ) ;
60
71
61
72
fs . writeFileSync ( dataPath , out ) ;
0 commit comments