reffy 18.6.2 → 18.7.0

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": "18.6.2",
3
+ "version": "18.7.0",
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",
@@ -35,24 +35,23 @@
35
35
  "dependencies": {
36
36
  "ajv": "8.17.1",
37
37
  "ajv-formats": "3.0.1",
38
- "commander": "13.1.0",
38
+ "commander": "14.0.0",
39
39
  "fetch-filecache-for-crawling": "5.1.1",
40
- "puppeteer": "24.8.2",
40
+ "puppeteer": "24.9.0",
41
41
  "semver": "^7.3.5",
42
- "web-specs": "3.50.0",
42
+ "web-specs": "3.51.0",
43
43
  "webidl2": "24.4.1"
44
44
  },
45
45
  "devDependencies": {
46
- "mocha": "11.2.2",
47
- "respec": "35.3.1",
46
+ "respec": "35.4.0",
48
47
  "respec-hljs": "2.1.1",
49
- "rollup": "4.40.2",
48
+ "rollup": "4.41.0",
50
49
  "undici": "^7.0.0"
51
50
  },
52
51
  "overrides": {
53
52
  "puppeteer": "$puppeteer"
54
53
  },
55
54
  "scripts": {
56
- "test": "mocha --recursive tests/"
55
+ "test": "node --test"
57
56
  }
58
57
  }
@@ -12,7 +12,8 @@
12
12
  "href": { "$ref": "../common.json#/$defs/url" },
13
13
  "title": { "type": "string" },
14
14
  "level": { "type": "integer" },
15
- "number": { "$ref": "../common.json#/$defs/headingNumber" }
15
+ "number": { "$ref": "../common.json#/$defs/headingNumber" },
16
+ "alternateIds": { "type": "array", "items": { "$ref": "../common.json#/$defs/id"} }
16
17
  }
17
18
  }
18
19
  }
@@ -41,13 +41,15 @@ export default function (spec, idToHeading) {
41
41
  href,
42
42
  title: n.textContent.trim()
43
43
  };
44
-
45
44
  const res = {
46
45
  id: heading.id,
47
46
  href: heading.href,
48
47
  level: parseInt(headingEl.tagName.slice(1), 10),
49
48
  title: heading.title
50
49
  };
50
+ if (heading.alternateIds?.length) {
51
+ res.alternateIds = heading.alternateIds;
52
+ }
51
53
  if (heading.number) {
52
54
  res.number = heading.number;
53
55
  }
@@ -86,23 +86,23 @@ export default function () {
86
86
  let href = nodeid;
87
87
 
88
88
  if (parentSection) {
89
- let id;
89
+ const ids = [];
90
90
 
91
91
  const heading = parentSection.heading;
92
92
  if (heading.id) {
93
- id = heading.id;
93
+ ids.push(heading.id);
94
94
  href = getAbsoluteUrl(heading, { singlePage });
95
95
  }
96
96
  else {
97
97
  const anchor = heading.querySelector('a[name]');
98
98
  if (anchor) {
99
- id = anchor.getAttribute('name');
99
+ ids.push(anchor.getAttribute('name'));
100
100
  href = getAbsoluteUrl(anchor, { singlePage, attribute: 'name' });
101
101
  }
102
102
  }
103
103
 
104
104
  if (parentSection.root && parentSection.root.id) {
105
- id = parentSection.root.id;
105
+ ids.push(parentSection.root.id);
106
106
  href = getAbsoluteUrl(parentSection.root, { singlePage });
107
107
  }
108
108
 
@@ -111,11 +111,14 @@ export default function () {
111
111
  const number = match ? match[1] : null;
112
112
 
113
113
  const mapping = {};
114
- if (id) {
115
- mapping.id = id;
114
+ if (ids.length) {
115
+ mapping.id = ids.pop();
116
116
  }
117
117
  mapping.href = href;
118
118
  mapping.title = trimmedText.replace(reNumber, '');
119
+ if (ids.length) {
120
+ mapping.alternateIds = ids;
121
+ }
119
122
  mappingTable[nodeid] = mapping;
120
123
 
121
124
  if (number) {