@willwade/aac-processors 0.3.4 → 0.3.5
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/README.md
CHANGED
|
@@ -90,7 +90,7 @@ NB: Please use [https://aactools.co.uk](https://aactools.co.uk) for a far more c
|
|
|
90
90
|
|
|
91
91
|
## Documentation
|
|
92
92
|
|
|
93
|
-
- API reference (TypeDoc): https://
|
|
93
|
+
- API reference (TypeDoc): https://aactools.github.io/AACProcessors-nodejs/
|
|
94
94
|
- Metrics guide: `src/utilities/analytics/docs/AAC_METRICS_GUIDE.md`
|
|
95
95
|
- Vocabulary analysis guide: `src/utilities/analytics/docs/VOCABULARY_ANALYSIS_GUIDE.md`
|
|
96
96
|
|
|
@@ -3,6 +3,13 @@ import { AACTree, AACPage, AACButton, AACSemanticIntent } from '../core/treeStru
|
|
|
3
3
|
import { XMLParser, XMLValidator, XMLBuilder } from 'fast-xml-parser';
|
|
4
4
|
import { ValidationFailureError, buildValidationResultFromMessage, } from '../validation/validationTypes';
|
|
5
5
|
import { getBasename, encodeText } from '../utils/io';
|
|
6
|
+
function sanitizeOutlineId(text) {
|
|
7
|
+
const slug = text.replace(/[^a-zA-Z0-9]/g, '_');
|
|
8
|
+
if (slug === '__proto__' || slug === 'prototype' || slug === 'constructor') {
|
|
9
|
+
return `_${slug}`;
|
|
10
|
+
}
|
|
11
|
+
return slug;
|
|
12
|
+
}
|
|
6
13
|
class OpmlProcessor extends BaseProcessor {
|
|
7
14
|
constructor(options) {
|
|
8
15
|
super(options);
|
|
@@ -24,7 +31,7 @@ class OpmlProcessor extends BaseProcessor {
|
|
|
24
31
|
return { page: null, childPages: [] };
|
|
25
32
|
}
|
|
26
33
|
const page = new AACPage({
|
|
27
|
-
id: text
|
|
34
|
+
id: sanitizeOutlineId(text),
|
|
28
35
|
name: text,
|
|
29
36
|
grid: [],
|
|
30
37
|
buttons: [],
|
|
@@ -40,7 +47,7 @@ class OpmlProcessor extends BaseProcessor {
|
|
|
40
47
|
id: `nav_${page.id}_${childText}`,
|
|
41
48
|
label: childText,
|
|
42
49
|
message: '',
|
|
43
|
-
targetPageId: childText
|
|
50
|
+
targetPageId: sanitizeOutlineId(childText),
|
|
44
51
|
});
|
|
45
52
|
// Load path: do not record as a user mutation
|
|
46
53
|
page._loadButton(button);
|
|
@@ -6,6 +6,13 @@ const treeStructure_1 = require("../core/treeStructure");
|
|
|
6
6
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
7
7
|
const validationTypes_1 = require("../validation/validationTypes");
|
|
8
8
|
const io_1 = require("../utils/io");
|
|
9
|
+
function sanitizeOutlineId(text) {
|
|
10
|
+
const slug = text.replace(/[^a-zA-Z0-9]/g, '_');
|
|
11
|
+
if (slug === '__proto__' || slug === 'prototype' || slug === 'constructor') {
|
|
12
|
+
return `_${slug}`;
|
|
13
|
+
}
|
|
14
|
+
return slug;
|
|
15
|
+
}
|
|
9
16
|
class OpmlProcessor extends baseProcessor_1.BaseProcessor {
|
|
10
17
|
constructor(options) {
|
|
11
18
|
super(options);
|
|
@@ -27,7 +34,7 @@ class OpmlProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
27
34
|
return { page: null, childPages: [] };
|
|
28
35
|
}
|
|
29
36
|
const page = new treeStructure_1.AACPage({
|
|
30
|
-
id: text
|
|
37
|
+
id: sanitizeOutlineId(text),
|
|
31
38
|
name: text,
|
|
32
39
|
grid: [],
|
|
33
40
|
buttons: [],
|
|
@@ -43,7 +50,7 @@ class OpmlProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
43
50
|
id: `nav_${page.id}_${childText}`,
|
|
44
51
|
label: childText,
|
|
45
52
|
message: '',
|
|
46
|
-
targetPageId: childText
|
|
53
|
+
targetPageId: sanitizeOutlineId(childText),
|
|
47
54
|
});
|
|
48
55
|
// Load path: do not record as a user mutation
|
|
49
56
|
page._loadButton(button);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "A comprehensive TypeScript library for processing AAC (Augmentative and Alternative Communication) file formats with translation support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/browser/index.browser.js",
|