From 1a7dd064f0a98e46f57630bbfa136213c678f07f Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 30 Jun 2021 23:11:16 -0400 Subject: [PATCH] mdn reference page changed again... --- scripts/extract-elements.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/extract-elements.js b/scripts/extract-elements.js index 9292f5a9..c49c1582 100644 --- a/scripts/extract-elements.js +++ b/scripts/extract-elements.js @@ -25,9 +25,9 @@ function extractElements($) { 'portal' ]; // `
` is for some reason missing from the reference tables. - // `` and `element` are obsolete and has been removed from the - // reference table, but we had them in the past so we should wait for a - // major to remove + // ``, ``, ``, ``, ``, `` + // are obsolete and has been removed from the reference table, but we had + // them in the past so we should wait for a major to remove const addElements = [ 'base', 'command', @@ -39,7 +39,11 @@ function extractElements($) { 'h4', 'h5', 'h6', - 'iframe' + 'iframe', + 'isindex', + 'listing', + 'multicol', + 'nextid' ]; return $('td:first-child') @@ -69,6 +73,19 @@ request(refUrl, (error, response, html) => { const $ = cheerio.load(html); const elements = extractElements($); if (elements.length !== expectedElCount) { + try { + const prevEls = fs.readFileSync(dataPath, 'utf8').split('\n'); + const added = elements.filter(n => prevEls.indexOf(n) === -1); + const removed = prevEls.filter(n => elements.indexOf(n) === -1); + + throw new Error( + 'Found extra elements: [' + added.join(',') + + '] and did not find elements: [' + removed.join(',') + ']' + ); + } + catch(e) { + console.log('no previous elements found'); + } throw new Error( 'Unexpected number of elements extracted from ' + refUrl + ' - Found ' + elements.length + ' but expected ' + expectedElCount +