From 72c97cc750d7eebba65133e22dc066ec8777c00e Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 6 Jan 2021 18:13:22 -0500 Subject: [PATCH 1/3] update component gen for MDN update Jan 2021 --- scripts/extract-attributes.js | 2 +- scripts/extract-elements.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/extract-attributes.js b/scripts/extract-attributes.js index 8409d58f..ec4e1a85 100644 --- a/scripts/extract-attributes.js +++ b/scripts/extract-attributes.js @@ -55,7 +55,7 @@ const attributeMap = supportedAttributes.reduce((map, reactAttribute) => { * descriptions and supported elements. */ function extractAttributes($) { - const $table = $('#Attribute_list').parent().find('table'); + const $table = $('#Attribute_list,#attribute_list').parent().find('table'); if($table.length !== 1) { throw new Error('page structure changed at ' + htmlURL); } diff --git a/scripts/extract-elements.js b/scripts/extract-elements.js index 14863e55..f2062cf7 100644 --- a/scripts/extract-elements.js +++ b/scripts/extract-elements.js @@ -13,6 +13,9 @@ const dataPath = './data/elements.txt'; function extractElements($) { const excludeElements = [ 'html', 'head', 'body', 'style', 'h1–h6', 'input', + // out of scope, different namespaces - but Mozilla added these to the + // above reference page Jan 2021 so we need to exclude them now. + 'svg', 'math', // obsolete, non-standard, or deprecated tags 'image', 'dir', 'tt', 'applet', 'noembed', 'bgsound', 'menu', 'menuitem', 'noframes' From aea3d2be3a2528d0773cc71f76d1428b23ae95e5 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 6 Jan 2021 18:20:02 -0500 Subject: [PATCH 2/3] error message if element count changes from expectation --- scripts/extract-elements.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/extract-elements.js b/scripts/extract-elements.js index f2062cf7..93ba47e7 100644 --- a/scripts/extract-elements.js +++ b/scripts/extract-elements.js @@ -6,6 +6,7 @@ const request = require('request'); const refUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element'; const dataPath = './data/elements.txt'; +const expectedElCount = 131; /** * From the MDN HTML elements reference, extract a list of elements. @@ -59,6 +60,12 @@ request(refUrl, (error, response, html) => { } const $ = cheerio.load(html); const elements = extractElements($); + if (elements.length !== expectedElCount) { + throw new Error( + 'Unexpected number of elements extracted from ' + refUrl + + ' Check the output and edit expectedElCount if this is intended.' + ); + } const out = elements.join('\n'); fs.writeFileSync(dataPath, out); From 08c4ce14390210d7f8104152fabda40668c9effe Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 6 Jan 2021 19:45:14 -0500 Subject: [PATCH 3/3] add reference to MDN PR with the math & svg addition --- scripts/extract-elements.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/extract-elements.js b/scripts/extract-elements.js index 93ba47e7..d7a5f4f8 100644 --- a/scripts/extract-elements.js +++ b/scripts/extract-elements.js @@ -16,6 +16,7 @@ function extractElements($) { 'html', 'head', 'body', 'style', 'h1–h6', 'input', // out of scope, different namespaces - but Mozilla added these to the // above reference page Jan 2021 so we need to exclude them now. + // see https://github.com/mdn/content/pull/410 'svg', 'math', // obsolete, non-standard, or deprecated tags 'image', 'dir', 'tt', 'applet', 'noembed', 'bgsound', 'menu', 'menuitem',