Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
mdn reference page changed again...
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Jul 1, 2021
1 parent 51ac388 commit 1a7dd06
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions scripts/extract-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function extractElements($) {
'portal'
];
// `<section>` is for some reason missing from the reference tables.
// `<command>` 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
// `<command>`, `<element>`, `<isindex>`, `<listing>`, `<multicol>`, `<nextid>`
// 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',
Expand All @@ -39,7 +39,11 @@ function extractElements($) {
'h4',
'h5',
'h6',
'iframe'
'iframe',
'isindex',
'listing',
'multicol',
'nextid'
];

return $('td:first-child')
Expand Down Expand Up @@ -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 +
Expand Down

0 comments on commit 1a7dd06

Please sign in to comment.