reffy 7.2.6 → 7.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reffy",
3
- "version": "7.2.6",
3
+ "version": "7.2.9",
4
4
  "description": "W3C/WHATWG spec dependencies exploration companion. Features a short set of tools to study spec references as well as WebIDL term definitions and references found in W3C specifications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,9 +34,9 @@
34
34
  "abortcontroller-polyfill": "1.7.3",
35
35
  "commander": "9.3.0",
36
36
  "fetch-filecache-for-crawling": "4.1.0",
37
- "puppeteer": "15.3.1",
37
+ "puppeteer": "15.3.2",
38
38
  "semver": "^7.3.5",
39
- "web-specs": "2.15.0",
39
+ "web-specs": "2.17.0",
40
40
  "webidl2": "24.2.2"
41
41
  },
42
42
  "devDependencies": {
@@ -45,7 +45,7 @@
45
45
  "nock": "13.2.8",
46
46
  "respec": "32.1.10",
47
47
  "respec-hljs": "2.1.1",
48
- "rollup": "2.75.7"
48
+ "rollup": "2.76.0"
49
49
  },
50
50
  "scripts": {
51
51
  "test": "mocha --recursive tests/"
@@ -225,6 +225,12 @@ const extractValueSpaces = doc => {
225
225
  }
226
226
  };
227
227
 
228
+ // Regular expression to use to split production rules:
229
+ // Split on the space that precedes a term immediately before an equal sign
230
+ // that is not wrapped in quotes (an equal sign wrapped in quotes is part of
231
+ // actual value syntax)
232
+ const reSplitRules = /\s(?=[^\s]+?\s*?=[^'])/;
233
+
228
234
  // Extract all dfns with data-dfn-type="type" or data-dfn-type="function"
229
235
  // but ignore definitions in <pre> as they do not always use dfns, as in
230
236
  // https://drafts.csswg.org/css-values-4/#calc-syntax
@@ -246,7 +252,15 @@ const extractValueSpaces = doc => {
246
252
  const text = parent.textContent.trim();
247
253
  if (text.match(/\s?=\s/)) {
248
254
  // Definition appears in a "prod = foo" text, that's all good
249
- parseProductionRule(text, { pureSyntax: true });
255
+ // ... except in css-easing-2 draft where text also contains another
256
+ // production rule as a child of the first one:
257
+ // https://drafts.csswg.org/css-easing-2/#typedef-step-easing-function
258
+ const prod = text.split(reSplitRules)
259
+ .find(p => p.trim().startsWith(dfn.textContent.trim()));
260
+ if (!prod) {
261
+ throw new Error(`Production rule for ${dfn.textContent.trim()} found has unexpected format`);
262
+ }
263
+ parseProductionRule(prod, { pureSyntax: true });
250
264
  }
251
265
  else if (dfn.textContent.trim().match(/^[a-zA-Z_][a-zA-Z0-9_\-]+\([^\)]+\)$/)) {
252
266
  // Definition is "prod(foo bar)", create a "prod() = prod(foo bar)" entry
@@ -323,7 +337,7 @@ const extractValueSpaces = doc => {
323
337
  })
324
338
  .map(el => el.textContent)
325
339
  .map(val => val.replace(/\/\*[^]*?\*\//gm, '')) // Drop comments
326
- .map(val => val.split(/\n(?=[^\n]*\s?=\s)/m)) // Separate definitions
340
+ .map(val => val.split(reSplitRules)) // Separate definitions
327
341
  .flat()
328
342
  .filter(text => text.match(/\s?=\s/))
329
343
  .map(text => parseProductionRule(text, { pureSyntax: true }));