@pie-qti/qti-common 0.1.28 → 1.0.0-beta.1
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 +31 -86
- package/dist/accessibility/index.d.ts +1 -0
- package/dist/accessibility/index.js +1 -0
- package/dist/accessibility/index.js.map +1 -1
- package/dist/accessibility/markup.d.ts +58 -0
- package/dist/accessibility/markup.js +461 -0
- package/dist/accessibility/markup.js.map +1 -0
- package/dist/feedback/visibility.d.ts +12 -0
- package/dist/feedback/visibility.js +22 -0
- package/dist/feedback/visibility.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -41,26 +41,16 @@ const nativeName = mapper.toNative('choiceinteraction');
|
|
|
41
41
|
|
|
42
42
|
### Element Name Mapping
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { Qti2xElementNameMapper, Qti3ElementNameMapper } from '@pie-qti/qti-common';
|
|
48
|
-
|
|
49
|
-
// QTI 2.x (camelCase)
|
|
50
|
-
const qti2Mapper = new Qti2xElementNameMapper();
|
|
51
|
-
qti2Mapper.toCanonical('choiceInteraction'); // → "choiceinteraction"
|
|
52
|
-
qti2Mapper.toNative('choiceinteraction'); // → "choiceinteraction"
|
|
53
|
-
|
|
54
|
-
// QTI 3.0 (kebab-case with qti- prefix)
|
|
55
|
-
const qti3Mapper = new Qti3ElementNameMapper();
|
|
56
|
-
qti3Mapper.toCanonical('qti-choice-interaction'); // → "choiceinteraction"
|
|
57
|
-
qti3Mapper.toNative('choiceinteraction'); // → "qti-choice-interaction"
|
|
58
|
-
```
|
|
44
|
+
Mappers convert between QTI version-specific element names and the canonical internal form, so the
|
|
45
|
+
same processing code handles both versions. One round-trip caveat applies to QTI 2.x:
|
|
59
46
|
|
|
60
47
|
`Qti2xElementNameMapper.toNative()` returns the lowercase canonical spelling because the parser's
|
|
61
48
|
QTI 2.x matching is case-insensitive; it cannot reconstruct the original camelCase from a lowercase
|
|
62
49
|
name. Preserve the source spelling separately when exact XML serialization matters.
|
|
63
50
|
|
|
51
|
+
The full element and attribute naming tables, plus step-by-step migration guidance, are in
|
|
52
|
+
[`docs/QTI-3-MIGRATION-GUIDE.md`](../../docs/QTI-3-MIGRATION-GUIDE.md).
|
|
53
|
+
|
|
64
54
|
### Smart Attribute Accessors
|
|
65
55
|
|
|
66
56
|
The package provides attribute accessors that work with both naming conventions:
|
|
@@ -84,28 +74,14 @@ getBooleanAttribute(element, 'shuffle'); // Returns boolean
|
|
|
84
74
|
|
|
85
75
|
## QTI 2.x vs 3.0 Naming Differences
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
| `itembody` | `itemBody` | `qti-item-body` |
|
|
93
|
-
| `responsedeclaration` | `responseDeclaration` | `qti-response-declaration` |
|
|
94
|
-
| `choiceinteraction` | `choiceInteraction` | `qti-choice-interaction` |
|
|
95
|
-
| `simplechoice` | `simpleChoice` | `qti-simple-choice` |
|
|
96
|
-
| `matchinteraction` | `matchInteraction` | `qti-match-interaction` |
|
|
97
|
-
| `textentryinteraction` | `textEntryInteraction` | `qti-text-entry-interaction` |
|
|
98
|
-
|
|
99
|
-
### Attribute Names
|
|
100
|
-
|
|
101
|
-
| Canonical (Internal) | QTI 2.x | QTI 3.0 |
|
|
102
|
-
|---------------------|---------|---------|
|
|
103
|
-
| `baseType` | `baseType` | `base-type` |
|
|
104
|
-
| `responseIdentifier` | `responseIdentifier` | `response-identifier` |
|
|
105
|
-
| `maxChoices` | `maxChoices` | `max-choices` |
|
|
106
|
-
| `cardinality` | `cardinality` | `cardinality` |
|
|
77
|
+
QTI 2.x uses camelCase element and attribute names (`choiceInteraction`, `baseType`), while QTI 3.0
|
|
78
|
+
uses kebab-case names with a `qti-` prefix (`qti-choice-interaction`, `base-type`). The canonical
|
|
79
|
+
layer hides these differences: extractors and response processing always operate on canonical names,
|
|
80
|
+
and the mappers translate to and from the version-specific spelling. A few simple attributes
|
|
81
|
+
(`identifier`, `shuffle`, `cardinality`) are spelled the same in both versions.
|
|
107
82
|
|
|
108
|
-
|
|
83
|
+
For the complete element and attribute naming tables, see
|
|
84
|
+
[`docs/QTI-3-MIGRATION-GUIDE.md`](../../docs/QTI-3-MIGRATION-GUIDE.md).
|
|
109
85
|
|
|
110
86
|
## Architecture
|
|
111
87
|
|
|
@@ -286,67 +262,36 @@ session.dispose();
|
|
|
286
262
|
|
|
287
263
|
### Transform Integration
|
|
288
264
|
|
|
265
|
+
`@pie-qti/qti-common` also powers the QTI → PIE transformation in `@pie-qti/to-pie`. To transform
|
|
266
|
+
QTI XML directly, use the plugin:
|
|
267
|
+
|
|
289
268
|
```typescript
|
|
290
|
-
import { TransformEngine } from '@pie-qti/transform-core';
|
|
291
269
|
import { QtiToPiePlugin } from '@pie-qti/to-pie';
|
|
292
|
-
import { createQtiParser } from '@pie-qti/qti-common';
|
|
293
270
|
|
|
294
271
|
const xml = `...(QTI 2.x or 3.0)...`;
|
|
295
|
-
const { version } = createQtiParser(xml);
|
|
296
|
-
|
|
297
|
-
const engine = new TransformEngine();
|
|
298
|
-
engine.use(new QtiToPiePlugin());
|
|
299
|
-
|
|
300
|
-
const handle = await engine.transform(xml, {
|
|
301
|
-
sourceFormat: version.startsWith('3') ? 'qti30' : 'qti22',
|
|
302
|
-
targetFormat: 'pie'
|
|
303
|
-
});
|
|
304
|
-
const result = await handle.result();
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
## Migration Guide
|
|
308
|
-
|
|
309
|
-
### From QTI 2.x-only Code
|
|
310
272
|
|
|
311
|
-
|
|
273
|
+
const plugin = new QtiToPiePlugin();
|
|
274
|
+
const result = await plugin.transform(
|
|
275
|
+
{ content: xml, format: 'qti22' }, // format is optional; qti30 is detected the same way
|
|
276
|
+
{ logger: console }
|
|
277
|
+
);
|
|
312
278
|
|
|
313
|
-
|
|
314
|
-
const elements = doc.getElementsByTagName('choiceInteraction');
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
**After** (QTI 2.x + 3.0):
|
|
318
|
-
|
|
319
|
-
```typescript
|
|
320
|
-
import { createQtiParser } from '@pie-qti/qti-common';
|
|
321
|
-
|
|
322
|
-
const { mapper } = createQtiParser(xml);
|
|
323
|
-
const tagName = mapper.toNative('choiceinteraction');
|
|
324
|
-
const elements = doc.getElementsByTagName(tagName);
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
**Even Better** (using existing extraction layer):
|
|
328
|
-
|
|
329
|
-
```typescript
|
|
330
|
-
// No changes needed! Extraction layer already uses mappers internally
|
|
331
|
-
const definition = createAssessmentItemDefinition({ itemXml: xml });
|
|
332
|
-
const session = definition.openSession(); // Works with both QTI 2.x and 3.0
|
|
279
|
+
console.log(result.items); // PIE items
|
|
333
280
|
```
|
|
334
281
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
**Before** (QTI 2.x only):
|
|
282
|
+
For engine-level usage (multi-plugin pipelines and PIE ⇄ QTI round-trips), see
|
|
283
|
+
[`docs/PIE-QTI-TRANSFORMATION-GUIDE.md`](../../docs/PIE-QTI-TRANSFORMATION-GUIDE.md).
|
|
338
284
|
|
|
339
|
-
|
|
340
|
-
const baseType = element.getAttribute('baseType');
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
**After** (QTI 2.x + 3.0):
|
|
285
|
+
## Migration Guide
|
|
344
286
|
|
|
345
|
-
|
|
346
|
-
|
|
287
|
+
Migrating existing QTI 2.x-only code usually means replacing hard-coded `getElementsByTagName`
|
|
288
|
+
lookups and direct `getAttribute` reads with `createQtiParser(...)` plus the mapper and smart
|
|
289
|
+
attribute accessors, so the same code handles QTI 2.x and 3.0. Code that already goes through the
|
|
290
|
+
extraction layer (`createAssessmentItemDefinition`) uses the mappers internally and needs no
|
|
291
|
+
changes.
|
|
347
292
|
|
|
348
|
-
|
|
349
|
-
|
|
293
|
+
See [`docs/QTI-3-MIGRATION-GUIDE.md`](../../docs/QTI-3-MIGRATION-GUIDE.md) for the full naming
|
|
294
|
+
tables and before/after migration examples.
|
|
350
295
|
|
|
351
296
|
## Testing
|
|
352
297
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { APIP_NAMESPACE, type ApipAccessElement, type ApipAccessElementSource, type ApipAccessibilityXml, type ApipContentLink, type ApipWriteOptions, readApipAccessElements, SSML_NAMESPACE, writeApipAccessibility, } from './apip.js';
|
|
2
2
|
export { type AccessibilityCatalog, type CatalogCard, type CatalogCardPayload, clockSeconds, type MediaAssetRef, type MediaFragmentRange, type MediaKind, type MediaSource, mediaKind, mediaMimeType, type TextRange, } from './catalog.js';
|
|
3
3
|
export { type QtiCatalogInfoOptions, writeQtiCatalogInfo } from './catalog-info.js';
|
|
4
|
+
export { type ContentLink, escapeText, HIDING_STYLES, type PreparedMarkup, type PrepareContentMarkupOptions, prepareContentMarkup, SSML_NAMESPACES, } from './markup.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { APIP_NAMESPACE, readApipAccessElements, SSML_NAMESPACE, writeApipAccessibility, } from './apip.js';
|
|
2
2
|
export { clockSeconds, mediaKind, mediaMimeType, } from './catalog.js';
|
|
3
3
|
export { writeQtiCatalogInfo } from './catalog-info.js';
|
|
4
|
+
export { escapeText, HIDING_STYLES, prepareContentMarkup, SSML_NAMESPACES, } from './markup.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accessibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAMd,sBAAsB,EACtB,cAAc,EACd,sBAAsB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIN,YAAY,EAKZ,SAAS,EACT,aAAa,GAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export {\n\tAPIP_NAMESPACE,\n\ttype ApipAccessElement,\n\ttype ApipAccessElementSource,\n\ttype ApipAccessibilityXml,\n\ttype ApipContentLink,\n\ttype ApipWriteOptions,\n\treadApipAccessElements,\n\tSSML_NAMESPACE,\n\twriteApipAccessibility,\n} from './apip.js';\nexport {\n\ttype AccessibilityCatalog,\n\ttype CatalogCard,\n\ttype CatalogCardPayload,\n\tclockSeconds,\n\ttype MediaAssetRef,\n\ttype MediaFragmentRange,\n\ttype MediaKind,\n\ttype MediaSource,\n\tmediaKind,\n\tmediaMimeType,\n\ttype TextRange,\n} from './catalog.js';\nexport { type QtiCatalogInfoOptions, writeQtiCatalogInfo } from './catalog-info.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accessibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAMd,sBAAsB,EACtB,cAAc,EACd,sBAAsB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIN,YAAY,EAKZ,SAAS,EACT,aAAa,GAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAEN,UAAU,EACV,aAAa,EAGb,oBAAoB,EACpB,eAAe,GACf,MAAM,aAAa,CAAC","sourcesContent":["export {\n\tAPIP_NAMESPACE,\n\ttype ApipAccessElement,\n\ttype ApipAccessElementSource,\n\ttype ApipAccessibilityXml,\n\ttype ApipContentLink,\n\ttype ApipWriteOptions,\n\treadApipAccessElements,\n\tSSML_NAMESPACE,\n\twriteApipAccessibility,\n} from './apip.js';\nexport {\n\ttype AccessibilityCatalog,\n\ttype CatalogCard,\n\ttype CatalogCardPayload,\n\tclockSeconds,\n\ttype MediaAssetRef,\n\ttype MediaFragmentRange,\n\ttype MediaKind,\n\ttype MediaSource,\n\tmediaKind,\n\tmediaMimeType,\n\ttype TextRange,\n} from './catalog.js';\nexport { type QtiCatalogInfoOptions, writeQtiCatalogInfo } from './catalog-info.js';\nexport {\n\ttype ContentLink,\n\tescapeText,\n\tHIDING_STYLES,\n\ttype PreparedMarkup,\n\ttype PrepareContentMarkupOptions,\n\tprepareContentMarkup,\n\tSSML_NAMESPACES,\n} from './markup.js';\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility markup
|
|
3
|
+
*
|
|
4
|
+
* The edits that prepare a QTI document's content for PIE conversion and for delivery, so what QTI
|
|
5
|
+
* voices, hides or suppresses stays so for the PIE read-aloud tools. Each content root (`itemBody`,
|
|
6
|
+
* `modalFeedback`, `stimulusBody`, in QTI 2 or QTI 3 spelling) is read as a token stream into an
|
|
7
|
+
* element tree, and rebuilt with the edits applied; markup outside the roots, comments and
|
|
8
|
+
* processing instructions are left as authored. CDATA is edited like the markup around it, since
|
|
9
|
+
* the HTML it wraps is what converts.
|
|
10
|
+
*
|
|
11
|
+
* 1. `qti-hidden` and `qti-visually-hidden` get the inline style the class stands for, since the
|
|
12
|
+
* shared-vocabulary stylesheet has no URL a PIE player can load and players strip `<style>`.
|
|
13
|
+
* Delivery ships that stylesheet and turns this edit off with `hidingStyles: false`.
|
|
14
|
+
* 2. `data-qti-suppress-tts` is restated as `data-tts-suppress`, the only spelling PIE reads.
|
|
15
|
+
* 3. An element with `data-ssml` gets a generated `data-catalog-idref`, and the SSML becomes a
|
|
16
|
+
* `spoken` card under it; an element that already names a catalog adds the card to that one.
|
|
17
|
+
* 4. Each APIP content link docks its access element's idref: on the element whose `id` it names,
|
|
18
|
+
* or on a span around the word or character range its `textLink` counts. Words are counted
|
|
19
|
+
* from 1 over the element's text split on whitespace, punctuation kept with its word, as
|
|
20
|
+
* 1EdTech's APIP-to-QTI 3 migration guide counts them; characters from 1 with whitespace runs
|
|
21
|
+
* collapsed. A range that crosses markup or overlaps another range is not docked.
|
|
22
|
+
* 5. Inline SSML elements are unwrapped with their text kept, and their nearest enclosing element
|
|
23
|
+
* gets a `spoken` card holding its content as SSML: the shape `SSMLExtractor` in pie-players
|
|
24
|
+
* produces from a `<speak>` element, so both reach `TTSService` alike.
|
|
25
|
+
* 6. `xml:lang` is restated as `lang`, the attribute HTML reads for the language of content.
|
|
26
|
+
*
|
|
27
|
+
* Docking puts the idref on the element's start tag, with two exceptions that wrap the element's
|
|
28
|
+
* content instead: a choice, whose attributes the transformers drop along with its tag, and an
|
|
29
|
+
* element that names a catalog already. An idref that cannot dock is left out, and the
|
|
30
|
+
* accessibility audit reports what it would have carried.
|
|
31
|
+
*/
|
|
32
|
+
import type { TextRange } from './catalog.js';
|
|
33
|
+
export declare const HIDING_STYLES: {
|
|
34
|
+
readonly 'qti-hidden': "display:none";
|
|
35
|
+
readonly 'qti-visually-hidden': "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";
|
|
36
|
+
};
|
|
37
|
+
export declare const SSML_NAMESPACES: ReadonlySet<string>;
|
|
38
|
+
/** An idref to dock on the content element whose `id` is `target`, or on a range of its text. */
|
|
39
|
+
export interface ContentLink {
|
|
40
|
+
idref: string;
|
|
41
|
+
target: string;
|
|
42
|
+
range?: TextRange;
|
|
43
|
+
}
|
|
44
|
+
export interface PrepareContentMarkupOptions {
|
|
45
|
+
/** Restate the hiding classes as inline style. Default true. */
|
|
46
|
+
hidingStyles?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface PreparedMarkup {
|
|
49
|
+
xml: string;
|
|
50
|
+
/** The `spoken` cards the content's SSML makes, by the idref each docked under. */
|
|
51
|
+
spoken: Array<{
|
|
52
|
+
identifier: string;
|
|
53
|
+
content: string;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
/** Apply the accessibility edits to a QTI document's content. */
|
|
57
|
+
export declare function prepareContentMarkup(qtiXml: string, links?: ContentLink[], options?: PrepareContentMarkupOptions): PreparedMarkup;
|
|
58
|
+
export declare function escapeText(text: string): string;
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility markup
|
|
3
|
+
*
|
|
4
|
+
* The edits that prepare a QTI document's content for PIE conversion and for delivery, so what QTI
|
|
5
|
+
* voices, hides or suppresses stays so for the PIE read-aloud tools. Each content root (`itemBody`,
|
|
6
|
+
* `modalFeedback`, `stimulusBody`, in QTI 2 or QTI 3 spelling) is read as a token stream into an
|
|
7
|
+
* element tree, and rebuilt with the edits applied; markup outside the roots, comments and
|
|
8
|
+
* processing instructions are left as authored. CDATA is edited like the markup around it, since
|
|
9
|
+
* the HTML it wraps is what converts.
|
|
10
|
+
*
|
|
11
|
+
* 1. `qti-hidden` and `qti-visually-hidden` get the inline style the class stands for, since the
|
|
12
|
+
* shared-vocabulary stylesheet has no URL a PIE player can load and players strip `<style>`.
|
|
13
|
+
* Delivery ships that stylesheet and turns this edit off with `hidingStyles: false`.
|
|
14
|
+
* 2. `data-qti-suppress-tts` is restated as `data-tts-suppress`, the only spelling PIE reads.
|
|
15
|
+
* 3. An element with `data-ssml` gets a generated `data-catalog-idref`, and the SSML becomes a
|
|
16
|
+
* `spoken` card under it; an element that already names a catalog adds the card to that one.
|
|
17
|
+
* 4. Each APIP content link docks its access element's idref: on the element whose `id` it names,
|
|
18
|
+
* or on a span around the word or character range its `textLink` counts. Words are counted
|
|
19
|
+
* from 1 over the element's text split on whitespace, punctuation kept with its word, as
|
|
20
|
+
* 1EdTech's APIP-to-QTI 3 migration guide counts them; characters from 1 with whitespace runs
|
|
21
|
+
* collapsed. A range that crosses markup or overlaps another range is not docked.
|
|
22
|
+
* 5. Inline SSML elements are unwrapped with their text kept, and their nearest enclosing element
|
|
23
|
+
* gets a `spoken` card holding its content as SSML: the shape `SSMLExtractor` in pie-players
|
|
24
|
+
* produces from a `<speak>` element, so both reach `TTSService` alike.
|
|
25
|
+
* 6. `xml:lang` is restated as `lang`, the attribute HTML reads for the language of content.
|
|
26
|
+
*
|
|
27
|
+
* Docking puts the idref on the element's start tag, with two exceptions that wrap the element's
|
|
28
|
+
* content instead: a choice, whose attributes the transformers drop along with its tag, and an
|
|
29
|
+
* element that names a catalog already. An idref that cannot dock is left out, and the
|
|
30
|
+
* accessibility audit reports what it would have carried.
|
|
31
|
+
*/
|
|
32
|
+
import { parse } from 'node-html-parser';
|
|
33
|
+
export const HIDING_STYLES = {
|
|
34
|
+
'qti-hidden': 'display:none',
|
|
35
|
+
'qti-visually-hidden': 'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0',
|
|
36
|
+
};
|
|
37
|
+
export const SSML_NAMESPACES = new Set([
|
|
38
|
+
'http://www.w3.org/2001/10/synthesis',
|
|
39
|
+
'http://www.w3.org/2010/10/synthesis',
|
|
40
|
+
]);
|
|
41
|
+
const GENERATED_IDREF_PREFIX = 'ssml-';
|
|
42
|
+
const CONTENT_ROOT_PATTERN = /<((?:[\w.-]+:)?(?:itemBody|modalFeedback|stimulusBody|qti-item-body|qti-modal-feedback|qti-stimulus-body))\b[\s\S]*?<\/\1\s*>/g;
|
|
43
|
+
const TOKEN_PATTERN = /<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<!\[CDATA\[|\]\]>|<\/([A-Za-z][\w.:-]*)\s*>|<([A-Za-z][\w.:-]*)((?:\s+[^\s=/>]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?)*)\s*(\/?)>/g;
|
|
44
|
+
const ATTRIBUTE_PATTERN = /([^\s=/>]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+))?/g;
|
|
45
|
+
const XMLNS_ATTRIBUTE_PATTERN = /\s+xmlns(?::[\w.-]+)?\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+)/g;
|
|
46
|
+
const SSML_PREFIX_PATTERN = /\bxmlns:([\w.-]+)\s*=\s*(["'])(.*?)\2/g;
|
|
47
|
+
const IDREF_PATTERN = /\bdata-catalog-idref\s*=\s*(["'])(.*?)\1/g;
|
|
48
|
+
const CATALOG_ID_PATTERN = /<(?:[\w.-]+:)?catalog\b[^>]*?\bid\s*=\s*(["'])(.*?)\1/g;
|
|
49
|
+
/** One character of text: an entity or character reference counts as the character it names. */
|
|
50
|
+
const TEXT_UNIT_PATTERN = /&(?:#\d+|#x[\da-f]+|[a-z][\da-z]*);|[\s\S]/gi;
|
|
51
|
+
const XML_WHITESPACE = /^[ \t\r\n]$/;
|
|
52
|
+
/** Choices: the transformers read their content and drop their tags. */
|
|
53
|
+
const CONTENT_WRAPPED = new Set([
|
|
54
|
+
'simpleChoice',
|
|
55
|
+
'simpleAssociableChoice',
|
|
56
|
+
'inlineChoice',
|
|
57
|
+
'gapText',
|
|
58
|
+
'qti-simple-choice',
|
|
59
|
+
'qti-simple-associable-choice',
|
|
60
|
+
'qti-inline-choice',
|
|
61
|
+
'qti-gap-text',
|
|
62
|
+
]);
|
|
63
|
+
const VOID_ELEMENTS = new Set([
|
|
64
|
+
'area',
|
|
65
|
+
'base',
|
|
66
|
+
'br',
|
|
67
|
+
'col',
|
|
68
|
+
'embed',
|
|
69
|
+
'hr',
|
|
70
|
+
'img',
|
|
71
|
+
'input',
|
|
72
|
+
'link',
|
|
73
|
+
'meta',
|
|
74
|
+
'param',
|
|
75
|
+
'source',
|
|
76
|
+
'track',
|
|
77
|
+
'wbr',
|
|
78
|
+
]);
|
|
79
|
+
const BLOCK_ELEMENTS = new Set([
|
|
80
|
+
'address',
|
|
81
|
+
'blockquote',
|
|
82
|
+
'div',
|
|
83
|
+
'dl',
|
|
84
|
+
'figure',
|
|
85
|
+
'h1',
|
|
86
|
+
'h2',
|
|
87
|
+
'h3',
|
|
88
|
+
'h4',
|
|
89
|
+
'h5',
|
|
90
|
+
'h6',
|
|
91
|
+
'hr',
|
|
92
|
+
'ol',
|
|
93
|
+
'p',
|
|
94
|
+
'pre',
|
|
95
|
+
'table',
|
|
96
|
+
'ul',
|
|
97
|
+
]);
|
|
98
|
+
/** Apply the accessibility edits to a QTI document's content. */
|
|
99
|
+
export function prepareContentMarkup(qtiXml, links = [], options = {}) {
|
|
100
|
+
const hidingStyles = options.hidingStyles ?? true;
|
|
101
|
+
const roots = [...qtiXml.matchAll(CONTENT_ROOT_PATTERN)].flatMap((match) => {
|
|
102
|
+
const root = contentTree(match[0], match.index, ssmlPrefixesOf(qtiXml));
|
|
103
|
+
return root ? [root] : [];
|
|
104
|
+
});
|
|
105
|
+
const elements = roots.flatMap(descendants);
|
|
106
|
+
const spoken = [];
|
|
107
|
+
const wraps = [];
|
|
108
|
+
const taken = new Set([
|
|
109
|
+
...[...qtiXml.matchAll(IDREF_PATTERN)].map((match) => match[2]),
|
|
110
|
+
...[...qtiXml.matchAll(CATALOG_ID_PATTERN)].map((match) => match[2]),
|
|
111
|
+
...links.map((link) => link.idref),
|
|
112
|
+
]);
|
|
113
|
+
let generated = 0;
|
|
114
|
+
const nextIdref = () => {
|
|
115
|
+
let identifier;
|
|
116
|
+
do {
|
|
117
|
+
generated += 1;
|
|
118
|
+
identifier = `${GENERATED_IDREF_PREFIX}${generated}`;
|
|
119
|
+
} while (taken.has(identifier));
|
|
120
|
+
taken.add(identifier);
|
|
121
|
+
return identifier;
|
|
122
|
+
};
|
|
123
|
+
const wrap = (span, idref, tag) => {
|
|
124
|
+
wraps.push({ ...span, tag, idref, seq: wraps.length });
|
|
125
|
+
};
|
|
126
|
+
const dock = (element, idref) => {
|
|
127
|
+
if (!element.parent)
|
|
128
|
+
return false;
|
|
129
|
+
if (element.idref === idref)
|
|
130
|
+
return true;
|
|
131
|
+
if (CONTENT_WRAPPED.has(element.local) || element.ssml || element.idref !== undefined) {
|
|
132
|
+
if (!element.close)
|
|
133
|
+
return false;
|
|
134
|
+
const block = element.children.some((child) => child.kind === 'element' && BLOCK_ELEMENTS.has(child.local.toLowerCase()));
|
|
135
|
+
wrap({ start: element.open.end, end: element.close.start }, idref, block ? 'div' : 'span');
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
element.added.push(`data-catalog-idref="${escapeAttribute(idref)}"`);
|
|
139
|
+
}
|
|
140
|
+
element.idref ??= idref;
|
|
141
|
+
return true;
|
|
142
|
+
};
|
|
143
|
+
for (const element of elements) {
|
|
144
|
+
if (element.ssml)
|
|
145
|
+
continue;
|
|
146
|
+
editStartTag(element, hidingStyles);
|
|
147
|
+
const authored = unquote(element.attributes.get('data-catalog-idref')).trim();
|
|
148
|
+
if (authored) {
|
|
149
|
+
if (CONTENT_WRAPPED.has(element.local))
|
|
150
|
+
dock(element, authored);
|
|
151
|
+
element.idref = authored;
|
|
152
|
+
}
|
|
153
|
+
if (element.attributes.has('data-ssml')) {
|
|
154
|
+
const content = decodedAttribute(element.attrs, 'data-ssml')?.trim();
|
|
155
|
+
if (content) {
|
|
156
|
+
const identifier = element.idref ?? nextIdref();
|
|
157
|
+
if (element.idref !== undefined || dock(element, identifier)) {
|
|
158
|
+
spoken.push({ identifier, content });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const ids = new Map();
|
|
164
|
+
for (const element of elements) {
|
|
165
|
+
const id = unquote(element.attributes.get('id')).trim();
|
|
166
|
+
if (id && !ids.has(id))
|
|
167
|
+
ids.set(id, element);
|
|
168
|
+
}
|
|
169
|
+
const ranges = new Map();
|
|
170
|
+
for (const link of links) {
|
|
171
|
+
const element = ids.get(link.target);
|
|
172
|
+
if (!element)
|
|
173
|
+
continue;
|
|
174
|
+
if (!link.range) {
|
|
175
|
+
dock(element, link.idref);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const located = locateRange(element, link.range);
|
|
179
|
+
if (!located)
|
|
180
|
+
continue;
|
|
181
|
+
const docked = ranges.get(located.text) ?? [];
|
|
182
|
+
if (docked.some((span) => crosses(span, located)))
|
|
183
|
+
continue;
|
|
184
|
+
docked.push(located);
|
|
185
|
+
ranges.set(located.text, docked);
|
|
186
|
+
wrap(located, link.idref, 'span');
|
|
187
|
+
}
|
|
188
|
+
const hosts = new Map();
|
|
189
|
+
for (const element of elements) {
|
|
190
|
+
if (!element.ssml || element.parent?.ssml)
|
|
191
|
+
continue;
|
|
192
|
+
let host = element.parent;
|
|
193
|
+
while (host?.ssml)
|
|
194
|
+
host = host.parent;
|
|
195
|
+
// SSML straight inside a content root speaks on its own: a root's tag does not reach PIE.
|
|
196
|
+
if (!host?.parent)
|
|
197
|
+
hosts.set(element, [element]);
|
|
198
|
+
else
|
|
199
|
+
hosts.set(host, host.children);
|
|
200
|
+
}
|
|
201
|
+
for (const [host, nodes] of hosts) {
|
|
202
|
+
const markup = nodes.map(ssmlMarkup).join('').replace(/\s+/g, ' ').trim();
|
|
203
|
+
if (!markup)
|
|
204
|
+
continue;
|
|
205
|
+
const identifier = host.idref ?? nextIdref();
|
|
206
|
+
if (host.idref !== undefined || dock(host, identifier)) {
|
|
207
|
+
spoken.push({ identifier, content: `<speak>${markup}</speak>` });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return { xml: rendered(qtiXml, elements, wraps), spoken };
|
|
211
|
+
}
|
|
212
|
+
function contentTree(markup, offset, ssmlPrefixes) {
|
|
213
|
+
let root;
|
|
214
|
+
const stack = [];
|
|
215
|
+
let cursor = 0;
|
|
216
|
+
const addText = (end) => {
|
|
217
|
+
const parent = stack[stack.length - 1];
|
|
218
|
+
if (parent && end > cursor) {
|
|
219
|
+
parent.children.push({
|
|
220
|
+
kind: 'text',
|
|
221
|
+
start: offset + cursor,
|
|
222
|
+
end: offset + end,
|
|
223
|
+
raw: markup.slice(cursor, end),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
for (const match of markup.matchAll(TOKEN_PATTERN)) {
|
|
228
|
+
addText(match.index);
|
|
229
|
+
cursor = match.index + match[0].length;
|
|
230
|
+
const [, endName, startName, attrs = '', selfClosing] = match;
|
|
231
|
+
if (endName) {
|
|
232
|
+
let at = stack.length - 1;
|
|
233
|
+
while (at >= 0 && stack[at]?.name !== endName)
|
|
234
|
+
at -= 1;
|
|
235
|
+
if (at === -1)
|
|
236
|
+
continue;
|
|
237
|
+
const element = stack[at];
|
|
238
|
+
element.close = { start: offset + match.index, end: offset + cursor };
|
|
239
|
+
stack.length = at;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (!startName)
|
|
243
|
+
continue;
|
|
244
|
+
const parent = stack[stack.length - 1];
|
|
245
|
+
if (!parent && root)
|
|
246
|
+
continue;
|
|
247
|
+
const colon = startName.indexOf(':');
|
|
248
|
+
const prefix = colon === -1 ? undefined : startName.slice(0, colon);
|
|
249
|
+
const local = startName.slice(colon + 1);
|
|
250
|
+
const attributes = new Map([...attrs.matchAll(ATTRIBUTE_PATTERN)].map((attribute) => [
|
|
251
|
+
attribute[1].toLowerCase(),
|
|
252
|
+
attribute[2],
|
|
253
|
+
]));
|
|
254
|
+
const xmlns = attributes.get('xmlns');
|
|
255
|
+
const defaultSsml = xmlns === undefined ? (parent?.defaultSsml ?? false) : SSML_NAMESPACES.has(unquote(xmlns));
|
|
256
|
+
const element = {
|
|
257
|
+
kind: 'element',
|
|
258
|
+
name: startName,
|
|
259
|
+
local,
|
|
260
|
+
attrs,
|
|
261
|
+
attributes,
|
|
262
|
+
selfClosing: Boolean(selfClosing),
|
|
263
|
+
open: { start: offset + match.index, end: offset + cursor },
|
|
264
|
+
...(parent ? { parent } : {}),
|
|
265
|
+
children: [],
|
|
266
|
+
ssml: prefix === undefined ? defaultSsml : ssmlPrefixes.has(prefix),
|
|
267
|
+
editedAttrs: attrs,
|
|
268
|
+
added: [],
|
|
269
|
+
defaultSsml,
|
|
270
|
+
};
|
|
271
|
+
if (parent)
|
|
272
|
+
parent.children.push(element);
|
|
273
|
+
else
|
|
274
|
+
root = element;
|
|
275
|
+
if (!element.selfClosing && !VOID_ELEMENTS.has(local.toLowerCase()))
|
|
276
|
+
stack.push(element);
|
|
277
|
+
}
|
|
278
|
+
return root;
|
|
279
|
+
}
|
|
280
|
+
/** Restate hiding classes, read-aloud suppression and content language in the start tag. */
|
|
281
|
+
function editStartTag(element, hidingStyles) {
|
|
282
|
+
const { attributes } = element;
|
|
283
|
+
const classes = unquote(attributes.get('class')).split(/\s+/);
|
|
284
|
+
const hiding = Object.entries(hidingStyles ? HIDING_STYLES : {})
|
|
285
|
+
.filter(([hidingClass]) => classes.includes(hidingClass))
|
|
286
|
+
.map(([, style]) => style);
|
|
287
|
+
if (hiding.length > 0) {
|
|
288
|
+
const style = attributes.get('style');
|
|
289
|
+
if (style === undefined) {
|
|
290
|
+
element.added.push(`style="${hiding.join(';')}"`);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const quote = style.startsWith("'") ? "'" : '"';
|
|
294
|
+
const current = unquote(style).trim().replace(/;$/, '');
|
|
295
|
+
const merged = [current, ...hiding].filter(Boolean).join(';');
|
|
296
|
+
element.editedAttrs = element.editedAttrs.replace(/(\sstyle\s*=\s*)("[^"]*"|'[^']*'|[^\s"'>]+)/i, `$1${quote}${merged}${quote}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const language = attributes.get('xml:lang');
|
|
300
|
+
if (language !== undefined && !attributes.has('lang')) {
|
|
301
|
+
element.added.push(`lang=${quoted(language)}`);
|
|
302
|
+
}
|
|
303
|
+
const suppress = attributes.get('data-qti-suppress-tts');
|
|
304
|
+
if (suppress !== undefined && !attributes.has('data-tts-suppress')) {
|
|
305
|
+
element.added.push(`data-tts-suppress=${quoted(suppress)}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The span of `element`'s text that `range` counts, when it lies inside one text node. Each
|
|
310
|
+
* whitespace run counts as one character, and whitespace before the first word not at all.
|
|
311
|
+
*/
|
|
312
|
+
function locateRange(element, range) {
|
|
313
|
+
const characters = [];
|
|
314
|
+
let space;
|
|
315
|
+
for (const text of textsOf(element)) {
|
|
316
|
+
for (const unit of text.raw.matchAll(TEXT_UNIT_PATTERN)) {
|
|
317
|
+
const start = text.start + unit.index;
|
|
318
|
+
const span = { text, start, end: start + unit[0].length };
|
|
319
|
+
if (XML_WHITESPACE.test(unit[0])) {
|
|
320
|
+
if (characters.length > 0)
|
|
321
|
+
space ??= span;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (space)
|
|
325
|
+
characters.push({ ...space, space: true });
|
|
326
|
+
space = undefined;
|
|
327
|
+
characters.push({ ...span, space: false });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
let first = range.start - 1;
|
|
331
|
+
let last = range.stop - 1;
|
|
332
|
+
if (range.unit === 'word') {
|
|
333
|
+
const words = [];
|
|
334
|
+
characters.forEach((character, index) => {
|
|
335
|
+
if (character.space)
|
|
336
|
+
return;
|
|
337
|
+
const word = words[words.length - 1];
|
|
338
|
+
if (word && word[1] === index - 1)
|
|
339
|
+
word[1] = index;
|
|
340
|
+
else
|
|
341
|
+
words.push([index, index]);
|
|
342
|
+
});
|
|
343
|
+
first = words[range.start - 1]?.[0] ?? Number.NaN;
|
|
344
|
+
last = words[range.stop - 1]?.[1] ?? Number.NaN;
|
|
345
|
+
}
|
|
346
|
+
const from = characters[first];
|
|
347
|
+
const to = characters[last];
|
|
348
|
+
if (!from || !to || last < first || from.text !== to.text)
|
|
349
|
+
return undefined;
|
|
350
|
+
return { text: from.text, start: from.start, end: to.end };
|
|
351
|
+
}
|
|
352
|
+
/** Two ranges that overlap without one holding the other. */
|
|
353
|
+
function crosses(a, b) {
|
|
354
|
+
const overlap = a.start < b.end && b.start < a.end;
|
|
355
|
+
const nested = (a.start <= b.start && b.end <= a.end) || (b.start <= a.start && a.end <= b.end);
|
|
356
|
+
return overlap && !nested;
|
|
357
|
+
}
|
|
358
|
+
/** Content as SSML: its SSML elements without namespace prefixes, other markup reduced to text. */
|
|
359
|
+
function ssmlMarkup(node) {
|
|
360
|
+
if (node.kind === 'text')
|
|
361
|
+
return escapeText(parse(node.raw).textContent);
|
|
362
|
+
const classes = unquote(node.attributes.get('class')).split(/\s+/);
|
|
363
|
+
if (classes.includes('qti-hidden') ||
|
|
364
|
+
node.attributes.has('data-qti-suppress-tts') ||
|
|
365
|
+
node.attributes.has('data-tts-suppress')) {
|
|
366
|
+
return '';
|
|
367
|
+
}
|
|
368
|
+
const content = node.children.map(ssmlMarkup).join('');
|
|
369
|
+
if (!node.ssml)
|
|
370
|
+
return content;
|
|
371
|
+
const attrs = node.attrs.replace(XMLNS_ATTRIBUTE_PATTERN, '');
|
|
372
|
+
return node.selfClosing
|
|
373
|
+
? `<${node.local}${attrs}/>`
|
|
374
|
+
: `<${node.local}${attrs}>${content}</${node.local}>`;
|
|
375
|
+
}
|
|
376
|
+
/** The document with every edited tag replaced and every wrap inserted. */
|
|
377
|
+
function rendered(qtiXml, elements, wraps) {
|
|
378
|
+
const edits = [];
|
|
379
|
+
for (const element of elements) {
|
|
380
|
+
if (element.ssml) {
|
|
381
|
+
edits.push({ ...element.open, text: '', phase: 2 });
|
|
382
|
+
if (element.close)
|
|
383
|
+
edits.push({ ...element.close, text: '', phase: 2 });
|
|
384
|
+
}
|
|
385
|
+
else if (element.added.length > 0 || element.editedAttrs !== element.attrs) {
|
|
386
|
+
const added = element.added.map((attribute) => ` ${attribute}`).join('');
|
|
387
|
+
const end = element.selfClosing ? ' />' : '>';
|
|
388
|
+
edits.push({
|
|
389
|
+
...element.open,
|
|
390
|
+
text: `<${element.name}${element.editedAttrs}${added}${end}`,
|
|
391
|
+
phase: 2,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
for (const wrap of wraps) {
|
|
396
|
+
edits.push({
|
|
397
|
+
start: wrap.start,
|
|
398
|
+
end: wrap.start,
|
|
399
|
+
text: `<${wrap.tag} data-catalog-idref="${escapeAttribute(wrap.idref)}">`,
|
|
400
|
+
phase: 1,
|
|
401
|
+
wrap,
|
|
402
|
+
});
|
|
403
|
+
edits.push({ start: wrap.end, end: wrap.end, text: `</${wrap.tag}>`, phase: 0, wrap });
|
|
404
|
+
}
|
|
405
|
+
// Wraps nest: at one position the innermost closes first and the outermost opens first.
|
|
406
|
+
edits.sort((a, b) => {
|
|
407
|
+
if (a.start !== b.start)
|
|
408
|
+
return a.start - b.start;
|
|
409
|
+
if (a.phase !== b.phase)
|
|
410
|
+
return a.phase - b.phase;
|
|
411
|
+
if (!a.wrap || !b.wrap)
|
|
412
|
+
return 0;
|
|
413
|
+
if (a.phase === 0)
|
|
414
|
+
return b.wrap.start - a.wrap.start || b.wrap.seq - a.wrap.seq;
|
|
415
|
+
return b.wrap.end - a.wrap.end || a.wrap.seq - b.wrap.seq;
|
|
416
|
+
});
|
|
417
|
+
let xml = '';
|
|
418
|
+
let cursor = 0;
|
|
419
|
+
for (const edit of edits) {
|
|
420
|
+
xml += qtiXml.slice(cursor, edit.start) + edit.text;
|
|
421
|
+
cursor = edit.end;
|
|
422
|
+
}
|
|
423
|
+
return xml + qtiXml.slice(cursor);
|
|
424
|
+
}
|
|
425
|
+
function descendants(element) {
|
|
426
|
+
return [
|
|
427
|
+
element,
|
|
428
|
+
...element.children.flatMap((child) => (child.kind === 'element' ? descendants(child) : [])),
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
function textsOf(element) {
|
|
432
|
+
return element.children.flatMap((child) => (child.kind === 'text' ? [child] : textsOf(child)));
|
|
433
|
+
}
|
|
434
|
+
function ssmlPrefixesOf(qtiXml) {
|
|
435
|
+
const prefixes = new Set(['ssml']);
|
|
436
|
+
for (const match of qtiXml.matchAll(SSML_PREFIX_PATTERN)) {
|
|
437
|
+
if (SSML_NAMESPACES.has(match[3]))
|
|
438
|
+
prefixes.add(match[1]);
|
|
439
|
+
}
|
|
440
|
+
return prefixes;
|
|
441
|
+
}
|
|
442
|
+
/** An attribute's value with its entities decoded, as the markup's readers see it. */
|
|
443
|
+
function decodedAttribute(attrs, name) {
|
|
444
|
+
const element = parse(`<x${attrs}></x>`).firstChild;
|
|
445
|
+
return element?.getAttribute(name);
|
|
446
|
+
}
|
|
447
|
+
function unquote(value) {
|
|
448
|
+
if (!value)
|
|
449
|
+
return '';
|
|
450
|
+
return /^(["']).*\1$/s.test(value) ? value.slice(1, -1) : value;
|
|
451
|
+
}
|
|
452
|
+
function quoted(value) {
|
|
453
|
+
return /^["']/.test(value) ? value : `"${value}"`;
|
|
454
|
+
}
|
|
455
|
+
export function escapeText(text) {
|
|
456
|
+
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
457
|
+
}
|
|
458
|
+
function escapeAttribute(value) {
|
|
459
|
+
return escapeText(value).replace(/"/g, '"');
|
|
460
|
+
}
|
|
461
|
+
//# sourceMappingURL=markup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.js","sourceRoot":"","sources":["../../src/accessibility/markup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAoB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG3D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,YAAY,EAAE,cAAc;IAC5B,qBAAqB,EACpB,6HAA6H;CACrH,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IAC3D,qCAAqC;IACrC,qCAAqC;CACrC,CAAC,CAAC;AA0DH,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,oBAAoB,GACzB,gIAAgI,CAAC;AAClI,MAAM,aAAa,GAClB,sKAAsK,CAAC;AACxK,MAAM,iBAAiB,GAAG,qDAAqD,CAAC;AAChF,MAAM,uBAAuB,GAAG,4DAA4D,CAAC;AAC7F,MAAM,mBAAmB,GAAG,wCAAwC,CAAC;AACrE,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAClE,MAAM,kBAAkB,GAAG,wDAAwD,CAAC;AACpF,gGAAgG;AAChG,MAAM,iBAAiB,GAAG,8CAA8C,CAAC;AACzE,MAAM,cAAc,GAAG,aAAa,CAAC;A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,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/**\n * Accessibility markup\n *\n * The edits that prepare a QTI document's content for PIE conversion and for delivery, so what QTI\n * voices, hides or suppresses stays so for the PIE read-aloud tools. Each content root (`itemBody`,\n * `modalFeedback`, `stimulusBody`, in QTI 2 or QTI 3 spelling) is read as a token stream into an\n * element tree, and rebuilt with the edits applied; markup outside the roots, comments and\n * processing instructions are left as authored. CDATA is edited like the markup around it, since\n * the HTML it wraps is what converts.\n *\n * 1. `qti-hidden` and `qti-visually-hidden` get the inline style the class stands for, since the\n * shared-vocabulary stylesheet has no URL a PIE player can load and players strip `<style>`.\n * Delivery ships that stylesheet and turns this edit off with `hidingStyles: false`.\n * 2. `data-qti-suppress-tts` is restated as `data-tts-suppress`, the only spelling PIE reads.\n * 3. An element with `data-ssml` gets a generated `data-catalog-idref`, and the SSML becomes a\n * `spoken` card under it; an element that already names a catalog adds the card to that one.\n * 4. Each APIP content link docks its access element's idref: on the element whose `id` it names,\n * or on a span around the word or character range its `textLink` counts. Words are counted\n * from 1 over the element's text split on whitespace, punctuation kept with its word, as\n * 1EdTech's APIP-to-QTI 3 migration guide counts them; characters from 1 with whitespace runs\n * collapsed. A range that crosses markup or overlaps another range is not docked.\n * 5. Inline SSML elements are unwrapped with their text kept, and their nearest enclosing element\n * gets a `spoken` card holding its content as SSML: the shape `SSMLExtractor` in pie-players\n * produces from a `<speak>` element, so both reach `TTSService` alike.\n * 6. `xml:lang` is restated as `lang`, the attribute HTML reads for the language of content.\n *\n * Docking puts the idref on the element's start tag, with two exceptions that wrap the element's\n * content instead: a choice, whose attributes the transformers drop along with its tag, and an\n * element that names a catalog already. An idref that cannot dock is left out, and the\n * accessibility audit reports what it would have carried.\n */\n\nimport { type HTMLElement, parse } from 'node-html-parser';\nimport type { TextRange } from './catalog.js';\n\nexport const HIDING_STYLES = {\n\t'qti-hidden': 'display:none',\n\t'qti-visually-hidden':\n\t\t'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0',\n} as const;\n\nexport const SSML_NAMESPACES: ReadonlySet<string> = new Set([\n\t'http://www.w3.org/2001/10/synthesis',\n\t'http://www.w3.org/2010/10/synthesis',\n]);\n\n/** An idref to dock on the content element whose `id` is `target`, or on a range of its text. */\nexport interface ContentLink {\n\tidref: string;\n\ttarget: string;\n\trange?: TextRange;\n}\n\nexport interface PrepareContentMarkupOptions {\n\t/** Restate the hiding classes as inline style. Default true. */\n\thidingStyles?: boolean;\n}\n\nexport interface PreparedMarkup {\n\txml: string;\n\t/** The `spoken` cards the content's SSML makes, by the idref each docked under. */\n\tspoken: Array<{ identifier: string; content: string }>;\n}\n\ninterface Span {\n\tstart: number;\n\tend: number;\n}\n\ninterface ContentElement {\n\tkind: 'element';\n\tname: string;\n\tlocal: string;\n\tattrs: string;\n\tattributes: Map<string, string | undefined>;\n\t/** Written as `<name/>`; a void HTML element without the slash has no close tag either. */\n\tselfClosing: boolean;\n\topen: Span;\n\tclose?: Span;\n\tparent?: ContentElement;\n\tchildren: ContentNode[];\n\tssml: boolean;\n\t/** The element's start tag as edited: its authored attributes, then the added ones. */\n\teditedAttrs: string;\n\tadded: string[];\n\t/** The idref the element's content renders under: authored, or docked by the preparation. */\n\tidref?: string;\n}\n\ninterface ContentText extends Span {\n\tkind: 'text';\n\traw: string;\n}\n\ntype ContentNode = ContentElement | ContentText;\n\ninterface Wrap extends Span {\n\ttag: 'span' | 'div';\n\tidref: string;\n\tseq: number;\n}\n\nconst GENERATED_IDREF_PREFIX = 'ssml-';\nconst CONTENT_ROOT_PATTERN =\n\t/<((?:[\\w.-]+:)?(?:itemBody|modalFeedback|stimulusBody|qti-item-body|qti-modal-feedback|qti-stimulus-body))\\b[\\s\\S]*?<\\/\\1\\s*>/g;\nconst TOKEN_PATTERN =\n\t/<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>|<!\\[CDATA\\[|\\]\\]>|<\\/([A-Za-z][\\w.:-]*)\\s*>|<([A-Za-z][\\w.:-]*)((?:\\s+[^\\s=/>]+(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s\"'>]+))?)*)\\s*(\\/?)>/g;\nconst ATTRIBUTE_PATTERN = /([^\\s=/>]+)(?:\\s*=\\s*(\"[^\"]*\"|'[^']*'|[^\\s\"'>]+))?/g;\nconst XMLNS_ATTRIBUTE_PATTERN = /\\s+xmlns(?::[\\w.-]+)?\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s\"'>]+)/g;\nconst SSML_PREFIX_PATTERN = /\\bxmlns:([\\w.-]+)\\s*=\\s*([\"'])(.*?)\\2/g;\nconst IDREF_PATTERN = /\\bdata-catalog-idref\\s*=\\s*([\"'])(.*?)\\1/g;\nconst CATALOG_ID_PATTERN = /<(?:[\\w.-]+:)?catalog\\b[^>]*?\\bid\\s*=\\s*([\"'])(.*?)\\1/g;\n/** One character of text: an entity or character reference counts as the character it names. */\nconst TEXT_UNIT_PATTERN = /&(?:#\\d+|#x[\\da-f]+|[a-z][\\da-z]*);|[\\s\\S]/gi;\nconst XML_WHITESPACE = /^[ \\t\\r\\n]$/;\n/** Choices: the transformers read their content and drop their tags. */\nconst CONTENT_WRAPPED = new Set([\n\t'simpleChoice',\n\t'simpleAssociableChoice',\n\t'inlineChoice',\n\t'gapText',\n\t'qti-simple-choice',\n\t'qti-simple-associable-choice',\n\t'qti-inline-choice',\n\t'qti-gap-text',\n]);\nconst VOID_ELEMENTS = new Set([\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n]);\nconst BLOCK_ELEMENTS = new Set([\n\t'address',\n\t'blockquote',\n\t'div',\n\t'dl',\n\t'figure',\n\t'h1',\n\t'h2',\n\t'h3',\n\t'h4',\n\t'h5',\n\t'h6',\n\t'hr',\n\t'ol',\n\t'p',\n\t'pre',\n\t'table',\n\t'ul',\n]);\n\n/** Apply the accessibility edits to a QTI document's content. */\nexport function prepareContentMarkup(\n\tqtiXml: string,\n\tlinks: ContentLink[] = [],\n\toptions: PrepareContentMarkupOptions = {}\n): PreparedMarkup {\n\tconst hidingStyles = options.hidingStyles ?? true;\n\tconst roots = [...qtiXml.matchAll(CONTENT_ROOT_PATTERN)].flatMap((match) => {\n\t\tconst root = contentTree(match[0], match.index, ssmlPrefixesOf(qtiXml));\n\t\treturn root ? [root] : [];\n\t});\n\tconst elements = roots.flatMap(descendants);\n\tconst spoken: PreparedMarkup['spoken'] = [];\n\tconst wraps: Wrap[] = [];\n\tconst taken = new Set([\n\t\t...[...qtiXml.matchAll(IDREF_PATTERN)].map((match) => match[2] as string),\n\t\t...[...qtiXml.matchAll(CATALOG_ID_PATTERN)].map((match) => match[2] as string),\n\t\t...links.map((link) => link.idref),\n\t]);\n\tlet generated = 0;\n\tconst nextIdref = (): string => {\n\t\tlet identifier: string;\n\t\tdo {\n\t\t\tgenerated += 1;\n\t\t\tidentifier = `${GENERATED_IDREF_PREFIX}${generated}`;\n\t\t} while (taken.has(identifier));\n\t\ttaken.add(identifier);\n\t\treturn identifier;\n\t};\n\n\tconst wrap = (span: Span, idref: string, tag: Wrap['tag']): void => {\n\t\twraps.push({ ...span, tag, idref, seq: wraps.length });\n\t};\n\tconst dock = (element: ContentElement, idref: string): boolean => {\n\t\tif (!element.parent) return false;\n\t\tif (element.idref === idref) return true;\n\t\tif (CONTENT_WRAPPED.has(element.local) || element.ssml || element.idref !== undefined) {\n\t\t\tif (!element.close) return false;\n\t\t\tconst block = element.children.some(\n\t\t\t\t(child) => child.kind === 'element' && BLOCK_ELEMENTS.has(child.local.toLowerCase())\n\t\t\t);\n\t\t\twrap({ start: element.open.end, end: element.close.start }, idref, block ? 'div' : 'span');\n\t\t} else {\n\t\t\telement.added.push(`data-catalog-idref=\"${escapeAttribute(idref)}\"`);\n\t\t}\n\t\telement.idref ??= idref;\n\t\treturn true;\n\t};\n\n\tfor (const element of elements) {\n\t\tif (element.ssml) continue;\n\t\teditStartTag(element, hidingStyles);\n\t\tconst authored = unquote(element.attributes.get('data-catalog-idref')).trim();\n\t\tif (authored) {\n\t\t\tif (CONTENT_WRAPPED.has(element.local)) dock(element, authored);\n\t\t\telement.idref = authored;\n\t\t}\n\t\tif (element.attributes.has('data-ssml')) {\n\t\t\tconst content = decodedAttribute(element.attrs, 'data-ssml')?.trim();\n\t\t\tif (content) {\n\t\t\t\tconst identifier = element.idref ?? nextIdref();\n\t\t\t\tif (element.idref !== undefined || dock(element, identifier)) {\n\t\t\t\t\tspoken.push({ identifier, content });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst ids = new Map<string, ContentElement>();\n\tfor (const element of elements) {\n\t\tconst id = unquote(element.attributes.get('id')).trim();\n\t\tif (id && !ids.has(id)) ids.set(id, element);\n\t}\n\tconst ranges = new Map<ContentText, Span[]>();\n\tfor (const link of links) {\n\t\tconst element = ids.get(link.target);\n\t\tif (!element) continue;\n\t\tif (!link.range) {\n\t\t\tdock(element, link.idref);\n\t\t\tcontinue;\n\t\t}\n\t\tconst located = locateRange(element, link.range);\n\t\tif (!located) continue;\n\t\tconst docked = ranges.get(located.text) ?? [];\n\t\tif (docked.some((span) => crosses(span, located))) continue;\n\t\tdocked.push(located);\n\t\tranges.set(located.text, docked);\n\t\twrap(located, link.idref, 'span');\n\t}\n\n\tconst hosts = new Map<ContentElement, ContentNode[]>();\n\tfor (const element of elements) {\n\t\tif (!element.ssml || element.parent?.ssml) continue;\n\t\tlet host = element.parent;\n\t\twhile (host?.ssml) host = host.parent;\n\t\t// SSML straight inside a content root speaks on its own: a root's tag does not reach PIE.\n\t\tif (!host?.parent) hosts.set(element, [element]);\n\t\telse hosts.set(host, host.children);\n\t}\n\tfor (const [host, nodes] of hosts) {\n\t\tconst markup = nodes.map(ssmlMarkup).join('').replace(/\\s+/g, ' ').trim();\n\t\tif (!markup) continue;\n\t\tconst identifier = host.idref ?? nextIdref();\n\t\tif (host.idref !== undefined || dock(host, identifier)) {\n\t\t\tspoken.push({ identifier, content: `<speak>${markup}</speak>` });\n\t\t}\n\t}\n\n\treturn { xml: rendered(qtiXml, elements, wraps), spoken };\n}\n\nfunction contentTree(\n\tmarkup: string,\n\toffset: number,\n\tssmlPrefixes: ReadonlySet<string>\n): ContentElement | undefined {\n\tlet root: ContentElement | undefined;\n\tconst stack: Array<ContentElement & { defaultSsml: boolean }> = [];\n\tlet cursor = 0;\n\tconst addText = (end: number): void => {\n\t\tconst parent = stack[stack.length - 1];\n\t\tif (parent && end > cursor) {\n\t\t\tparent.children.push({\n\t\t\t\tkind: 'text',\n\t\t\t\tstart: offset + cursor,\n\t\t\t\tend: offset + end,\n\t\t\t\traw: markup.slice(cursor, end),\n\t\t\t});\n\t\t}\n\t};\n\n\tfor (const match of markup.matchAll(TOKEN_PATTERN)) {\n\t\taddText(match.index);\n\t\tcursor = match.index + match[0].length;\n\t\tconst [, endName, startName, attrs = '', selfClosing] = match;\n\t\tif (endName) {\n\t\t\tlet at = stack.length - 1;\n\t\t\twhile (at >= 0 && stack[at]?.name !== endName) at -= 1;\n\t\t\tif (at === -1) continue;\n\t\t\tconst element = stack[at] as ContentElement;\n\t\t\telement.close = { start: offset + match.index, end: offset + cursor };\n\t\t\tstack.length = at;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!startName) continue;\n\n\t\tconst parent = stack[stack.length - 1];\n\t\tif (!parent && root) continue;\n\t\tconst colon = startName.indexOf(':');\n\t\tconst prefix = colon === -1 ? undefined : startName.slice(0, colon);\n\t\tconst local = startName.slice(colon + 1);\n\t\tconst attributes = new Map(\n\t\t\t[...attrs.matchAll(ATTRIBUTE_PATTERN)].map((attribute) => [\n\t\t\t\t(attribute[1] as string).toLowerCase(),\n\t\t\t\tattribute[2],\n\t\t\t])\n\t\t);\n\t\tconst xmlns = attributes.get('xmlns');\n\t\tconst defaultSsml =\n\t\t\txmlns === undefined ? (parent?.defaultSsml ?? false) : SSML_NAMESPACES.has(unquote(xmlns));\n\t\tconst element = {\n\t\t\tkind: 'element' as const,\n\t\t\tname: startName,\n\t\t\tlocal,\n\t\t\tattrs,\n\t\t\tattributes,\n\t\t\tselfClosing: Boolean(selfClosing),\n\t\t\topen: { start: offset + match.index, end: offset + cursor },\n\t\t\t...(parent ? { parent } : {}),\n\t\t\tchildren: [],\n\t\t\tssml: prefix === undefined ? defaultSsml : ssmlPrefixes.has(prefix),\n\t\t\teditedAttrs: attrs,\n\t\t\tadded: [],\n\t\t\tdefaultSsml,\n\t\t};\n\t\tif (parent) parent.children.push(element);\n\t\telse root = element;\n\t\tif (!element.selfClosing && !VOID_ELEMENTS.has(local.toLowerCase())) stack.push(element);\n\t}\n\treturn root;\n}\n\n/** Restate hiding classes, read-aloud suppression and content language in the start tag. */\nfunction editStartTag(element: ContentElement, hidingStyles: boolean): void {\n\tconst { attributes } = element;\n\tconst classes = unquote(attributes.get('class')).split(/\\s+/);\n\tconst hiding = Object.entries(hidingStyles ? HIDING_STYLES : {})\n\t\t.filter(([hidingClass]) => classes.includes(hidingClass))\n\t\t.map(([, style]) => style);\n\tif (hiding.length > 0) {\n\t\tconst style = attributes.get('style');\n\t\tif (style === undefined) {\n\t\t\telement.added.push(`style=\"${hiding.join(';')}\"`);\n\t\t} else {\n\t\t\tconst quote = style.startsWith(\"'\") ? \"'\" : '\"';\n\t\t\tconst current = unquote(style).trim().replace(/;$/, '');\n\t\t\tconst merged = [current, ...hiding].filter(Boolean).join(';');\n\t\t\telement.editedAttrs = element.editedAttrs.replace(\n\t\t\t\t/(\\sstyle\\s*=\\s*)(\"[^\"]*\"|'[^']*'|[^\\s\"'>]+)/i,\n\t\t\t\t`$1${quote}${merged}${quote}`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst language = attributes.get('xml:lang');\n\tif (language !== undefined && !attributes.has('lang')) {\n\t\telement.added.push(`lang=${quoted(language)}`);\n\t}\n\n\tconst suppress = attributes.get('data-qti-suppress-tts');\n\tif (suppress !== undefined && !attributes.has('data-tts-suppress')) {\n\t\telement.added.push(`data-tts-suppress=${quoted(suppress)}`);\n\t}\n}\n\n/**\n * The span of `element`'s text that `range` counts, when it lies inside one text node. Each\n * whitespace run counts as one character, and whitespace before the first word not at all.\n */\nfunction locateRange(\n\telement: ContentElement,\n\trange: TextRange\n): (Span & { text: ContentText }) | undefined {\n\tconst characters: Array<Span & { text: ContentText; space: boolean }> = [];\n\tlet space: (Span & { text: ContentText }) | undefined;\n\tfor (const text of textsOf(element)) {\n\t\tfor (const unit of text.raw.matchAll(TEXT_UNIT_PATTERN)) {\n\t\t\tconst start = text.start + unit.index;\n\t\t\tconst span = { text, start, end: start + unit[0].length };\n\t\t\tif (XML_WHITESPACE.test(unit[0])) {\n\t\t\t\tif (characters.length > 0) space ??= span;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (space) characters.push({ ...space, space: true });\n\t\t\tspace = undefined;\n\t\t\tcharacters.push({ ...span, space: false });\n\t\t}\n\t}\n\n\tlet first = range.start - 1;\n\tlet last = range.stop - 1;\n\tif (range.unit === 'word') {\n\t\tconst words: Array<[number, number]> = [];\n\t\tcharacters.forEach((character, index) => {\n\t\t\tif (character.space) return;\n\t\t\tconst word = words[words.length - 1];\n\t\t\tif (word && word[1] === index - 1) word[1] = index;\n\t\t\telse words.push([index, index]);\n\t\t});\n\t\tfirst = words[range.start - 1]?.[0] ?? Number.NaN;\n\t\tlast = words[range.stop - 1]?.[1] ?? Number.NaN;\n\t}\n\tconst from = characters[first];\n\tconst to = characters[last];\n\tif (!from || !to || last < first || from.text !== to.text) return undefined;\n\treturn { text: from.text, start: from.start, end: to.end };\n}\n\n/** Two ranges that overlap without one holding the other. */\nfunction crosses(a: Span, b: Span): boolean {\n\tconst overlap = a.start < b.end && b.start < a.end;\n\tconst nested = (a.start <= b.start && b.end <= a.end) || (b.start <= a.start && a.end <= b.end);\n\treturn overlap && !nested;\n}\n\n/** Content as SSML: its SSML elements without namespace prefixes, other markup reduced to text. */\nfunction ssmlMarkup(node: ContentNode): string {\n\tif (node.kind === 'text') return escapeText(parse(node.raw).textContent);\n\tconst classes = unquote(node.attributes.get('class')).split(/\\s+/);\n\tif (\n\t\tclasses.includes('qti-hidden') ||\n\t\tnode.attributes.has('data-qti-suppress-tts') ||\n\t\tnode.attributes.has('data-tts-suppress')\n\t) {\n\t\treturn '';\n\t}\n\tconst content = node.children.map(ssmlMarkup).join('');\n\tif (!node.ssml) return content;\n\tconst attrs = node.attrs.replace(XMLNS_ATTRIBUTE_PATTERN, '');\n\treturn node.selfClosing\n\t\t? `<${node.local}${attrs}/>`\n\t\t: `<${node.local}${attrs}>${content}</${node.local}>`;\n}\n\n/** The document with every edited tag replaced and every wrap inserted. */\nfunction rendered(qtiXml: string, elements: ContentElement[], wraps: Wrap[]): string {\n\tinterface Edit extends Span {\n\t\ttext: string;\n\t\t/** Same-position order: closing wraps, then opening ones, then tag replacements. */\n\t\tphase: 0 | 1 | 2;\n\t\twrap?: Wrap;\n\t}\n\tconst edits: Edit[] = [];\n\tfor (const element of elements) {\n\t\tif (element.ssml) {\n\t\t\tedits.push({ ...element.open, text: '', phase: 2 });\n\t\t\tif (element.close) edits.push({ ...element.close, text: '', phase: 2 });\n\t\t} else if (element.added.length > 0 || element.editedAttrs !== element.attrs) {\n\t\t\tconst added = element.added.map((attribute) => ` ${attribute}`).join('');\n\t\t\tconst end = element.selfClosing ? ' />' : '>';\n\t\t\tedits.push({\n\t\t\t\t...element.open,\n\t\t\t\ttext: `<${element.name}${element.editedAttrs}${added}${end}`,\n\t\t\t\tphase: 2,\n\t\t\t});\n\t\t}\n\t}\n\tfor (const wrap of wraps) {\n\t\tedits.push({\n\t\t\tstart: wrap.start,\n\t\t\tend: wrap.start,\n\t\t\ttext: `<${wrap.tag} data-catalog-idref=\"${escapeAttribute(wrap.idref)}\">`,\n\t\t\tphase: 1,\n\t\t\twrap,\n\t\t});\n\t\tedits.push({ start: wrap.end, end: wrap.end, text: `</${wrap.tag}>`, phase: 0, wrap });\n\t}\n\t// Wraps nest: at one position the innermost closes first and the outermost opens first.\n\tedits.sort((a, b) => {\n\t\tif (a.start !== b.start) return a.start - b.start;\n\t\tif (a.phase !== b.phase) return a.phase - b.phase;\n\t\tif (!a.wrap || !b.wrap) return 0;\n\t\tif (a.phase === 0) return b.wrap.start - a.wrap.start || b.wrap.seq - a.wrap.seq;\n\t\treturn b.wrap.end - a.wrap.end || a.wrap.seq - b.wrap.seq;\n\t});\n\n\tlet xml = '';\n\tlet cursor = 0;\n\tfor (const edit of edits) {\n\t\txml += qtiXml.slice(cursor, edit.start) + edit.text;\n\t\tcursor = edit.end;\n\t}\n\treturn xml + qtiXml.slice(cursor);\n}\n\nfunction descendants(element: ContentElement): ContentElement[] {\n\treturn [\n\t\telement,\n\t\t...element.children.flatMap((child) => (child.kind === 'element' ? descendants(child) : [])),\n\t];\n}\n\nfunction textsOf(element: ContentElement): ContentText[] {\n\treturn element.children.flatMap((child) => (child.kind === 'text' ? [child] : textsOf(child)));\n}\n\nfunction ssmlPrefixesOf(qtiXml: string): Set<string> {\n\tconst prefixes = new Set(['ssml']);\n\tfor (const match of qtiXml.matchAll(SSML_PREFIX_PATTERN)) {\n\t\tif (SSML_NAMESPACES.has(match[3] as string)) prefixes.add(match[1] as string);\n\t}\n\treturn prefixes;\n}\n\n/** An attribute's value with its entities decoded, as the markup's readers see it. */\nfunction decodedAttribute(attrs: string, name: string): string | undefined {\n\tconst element = parse(`<x${attrs}></x>`).firstChild as HTMLElement | null;\n\treturn element?.getAttribute(name);\n}\n\nfunction unquote(value: string | undefined): string {\n\tif (!value) return '';\n\treturn /^([\"']).*\\1$/s.test(value) ? value.slice(1, -1) : value;\n}\n\nfunction quoted(value: string): string {\n\treturn /^[\"']/.test(value) ? value : `\"${value}\"`;\n}\n\nexport function escapeText(text: string): string {\n\treturn text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn escapeText(value).replace(/\"/g, '"');\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback and template visibility
|
|
3
|
+
*
|
|
4
|
+
* A feedback or template element names a variable and an `identifier`. The identifier matches a
|
|
5
|
+
* single value by equality and a container by membership; NULL matches nothing. `showHide="show"`
|
|
6
|
+
* (the default) shows the element on a match, `showHide="hide"` shows it unless there is one.
|
|
7
|
+
* Item feedback, modal feedback, test feedback and template content all use this rule.
|
|
8
|
+
*/
|
|
9
|
+
/** Whether `identifier` matches `value`, the plain value of the variable the element names. */
|
|
10
|
+
export declare function matchesIdentifier(value: unknown, identifier: string): boolean;
|
|
11
|
+
/** Whether an element with this `identifier` and `showHide` is shown for `value`. */
|
|
12
|
+
export declare function isShownByIdentifier(value: unknown, identifier: string, showHide?: string | null): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback and template visibility
|
|
3
|
+
*
|
|
4
|
+
* A feedback or template element names a variable and an `identifier`. The identifier matches a
|
|
5
|
+
* single value by equality and a container by membership; NULL matches nothing. `showHide="show"`
|
|
6
|
+
* (the default) shows the element on a match, `showHide="hide"` shows it unless there is one.
|
|
7
|
+
* Item feedback, modal feedback, test feedback and template content all use this rule.
|
|
8
|
+
*/
|
|
9
|
+
/** Whether `identifier` matches `value`, the plain value of the variable the element names. */
|
|
10
|
+
export function matchesIdentifier(value, identifier) {
|
|
11
|
+
if (Array.isArray(value))
|
|
12
|
+
return value.some((item) => item !== null && String(item) === identifier);
|
|
13
|
+
if (value === null || value === undefined || value === '')
|
|
14
|
+
return false;
|
|
15
|
+
return String(value) === identifier;
|
|
16
|
+
}
|
|
17
|
+
/** Whether an element with this `identifier` and `showHide` is shown for `value`. */
|
|
18
|
+
export function isShownByIdentifier(value, identifier, showHide) {
|
|
19
|
+
const matched = matchesIdentifier(value, identifier);
|
|
20
|
+
return showHide?.trim().toLowerCase() === 'hide' ? !matched : matched;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=visibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.js","sourceRoot":"","sources":["../../src/feedback/visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,UAAkB;IACnE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,CAAC;IACpG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACxE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc,EAAE,UAAkB,EAAE,QAAwB;IAC/F,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACrD,OAAO,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Feedback and template visibility\n *\n * A feedback or template element names a variable and an `identifier`. The identifier matches a\n * single value by equality and a container by membership; NULL matches nothing. `showHide=\"show\"`\n * (the default) shows the element on a match, `showHide=\"hide\"` shows it unless there is one.\n * Item feedback, modal feedback, test feedback and template content all use this rule.\n */\n\n/** Whether `identifier` matches `value`, the plain value of the variable the element names. */\nexport function matchesIdentifier(value: unknown, identifier: string): boolean {\n\tif (Array.isArray(value)) return value.some((item) => item !== null && String(item) === identifier);\n\tif (value === null || value === undefined || value === '') return false;\n\treturn String(value) === identifier;\n}\n\n/** Whether an element with this `identifier` and `showHide` is shown for `value`. */\nexport function isShownByIdentifier(value: unknown, identifier: string, showHide?: string | null): boolean {\n\tconst matched = matchesIdentifier(value, identifier);\n\treturn showHide?.trim().toLowerCase() === 'hide' ? !matched : matched;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMap
|
|
|
6
6
|
export { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';
|
|
7
7
|
export { QTI2_PROMPT_BEARING_INTERACTIONS, QTI3_ATTRIBUTE_TO_QTI2, } from './element-mapper/qti3-attribute-map.js';
|
|
8
8
|
export { convertQti2ToQti3, QTI3_ASI_SCHEMA_LOCATION, QTI3_NAMESPACE, QTI3_RPTEMPLATE_BASE, } from './element-mapper/qti2-to-qti3.js';
|
|
9
|
+
export { isShownByIdentifier, matchesIdentifier } from './feedback/visibility.js';
|
|
9
10
|
export { detectQtiVersion } from './version-detection/detectQtiVersion.js';
|
|
10
11
|
export type { QtiVersion } from './version-detection/detectQtiVersion.js';
|
|
11
12
|
export { getAttribute, getBooleanAttribute, getNumberAttribute, hasAttribute, toCamelCase, toKebabCase, } from './xml/attributes.js';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMap
|
|
|
4
4
|
export { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';
|
|
5
5
|
export { QTI2_PROMPT_BEARING_INTERACTIONS, QTI3_ATTRIBUTE_TO_QTI2, } from './element-mapper/qti3-attribute-map.js';
|
|
6
6
|
export { convertQti2ToQti3, QTI3_ASI_SCHEMA_LOCATION, QTI3_NAMESPACE, QTI3_RPTEMPLATE_BASE, } from './element-mapper/qti2-to-qti3.js';
|
|
7
|
+
// Feedback and template visibility
|
|
8
|
+
export { isShownByIdentifier, matchesIdentifier } from './feedback/visibility.js';
|
|
7
9
|
// Version detection
|
|
8
10
|
export { detectQtiVersion } from './version-detection/detectQtiVersion.js';
|
|
9
11
|
// XML attribute utilities
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAIlF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EACN,gCAAgC,EAChC,sBAAsB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,GACpB,MAAM,kCAAkC,CAAC;AAE1C,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,0BAA0B;AAC1B,OAAO,EACN,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,GACX,MAAM,qBAAqB,CAAC;AAE7B,oDAAoD;AACpD,OAAO,EAAE,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACN,2BAA2B,GAG3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,iBAAiB;AACjB,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,MAAM,EACN,MAAM,GAGN,MAAM,qBAAqB,CAAC","sourcesContent":["// Element name mapping\nexport type { ElementNameMapper } from './element-mapper/ElementNameMapper.js';\nexport { Qti2xElementNameMapper } from './element-mapper/Qti2xElementNameMapper.js';\nexport { Qti3ElementNameMapper } from './element-mapper/Qti3ElementNameMapper.js';\n\n// Attribute name mapping\nexport type { AttributeNameMapper } from './element-mapper/AttributeNameMapper.js';\nexport { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMapper.js';\nexport { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';\nexport {\n\tQTI2_PROMPT_BEARING_INTERACTIONS,\n\tQTI3_ATTRIBUTE_TO_QTI2,\n} from './element-mapper/qti3-attribute-map.js';\nexport {\n\tconvertQti2ToQti3,\n\tQTI3_ASI_SCHEMA_LOCATION,\n\tQTI3_NAMESPACE,\n\tQTI3_RPTEMPLATE_BASE,\n} from './element-mapper/qti2-to-qti3.js';\n\n// Version detection\nexport { detectQtiVersion } from './version-detection/detectQtiVersion.js';\nexport type { QtiVersion } from './version-detection/detectQtiVersion.js';\n\n// XML attribute utilities\nexport {\n\tgetAttribute,\n\tgetBooleanAttribute,\n\tgetNumberAttribute,\n\thasAttribute,\n\ttoCamelCase,\n\ttoKebabCase,\n} from './xml/attributes.js';\n\n// DOM utility helpers shared across player packages\nexport { assignProps, type AssignPropsOptions } from './dom/assignProps.js';\nexport {\n\tcreateSvelteMountController,\n\ttype SvelteMountController,\n\ttype SvelteMountControllerOptions,\n} from './dom/svelteMountController.js';\nexport { touchDrag, touchDragStyles } from './dom/touchDrag.js';\n\n// Parser factory\nexport {\n\tcreateQtiParser,\n\tcreateMapperForVersion,\n\tcreateAttributeMapperForVersion,\n\tisQti2,\n\tisQti3,\n\ttype QtiParserResult,\n\ttype CreateParserOptions,\n} from './parser-factory.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAIlF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EACN,gCAAgC,EAChC,sBAAsB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,GACpB,MAAM,kCAAkC,CAAC;AAE1C,mCAAmC;AACnC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElF,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,0BAA0B;AAC1B,OAAO,EACN,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,GACX,MAAM,qBAAqB,CAAC;AAE7B,oDAAoD;AACpD,OAAO,EAAE,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACN,2BAA2B,GAG3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,iBAAiB;AACjB,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,MAAM,EACN,MAAM,GAGN,MAAM,qBAAqB,CAAC","sourcesContent":["// Element name mapping\nexport type { ElementNameMapper } from './element-mapper/ElementNameMapper.js';\nexport { Qti2xElementNameMapper } from './element-mapper/Qti2xElementNameMapper.js';\nexport { Qti3ElementNameMapper } from './element-mapper/Qti3ElementNameMapper.js';\n\n// Attribute name mapping\nexport type { AttributeNameMapper } from './element-mapper/AttributeNameMapper.js';\nexport { Qti2xAttributeNameMapper } from './element-mapper/Qti2xAttributeNameMapper.js';\nexport { Qti3AttributeNameMapper } from './element-mapper/Qti3AttributeNameMapper.js';\nexport {\n\tQTI2_PROMPT_BEARING_INTERACTIONS,\n\tQTI3_ATTRIBUTE_TO_QTI2,\n} from './element-mapper/qti3-attribute-map.js';\nexport {\n\tconvertQti2ToQti3,\n\tQTI3_ASI_SCHEMA_LOCATION,\n\tQTI3_NAMESPACE,\n\tQTI3_RPTEMPLATE_BASE,\n} from './element-mapper/qti2-to-qti3.js';\n\n// Feedback and template visibility\nexport { isShownByIdentifier, matchesIdentifier } from './feedback/visibility.js';\n\n// Version detection\nexport { detectQtiVersion } from './version-detection/detectQtiVersion.js';\nexport type { QtiVersion } from './version-detection/detectQtiVersion.js';\n\n// XML attribute utilities\nexport {\n\tgetAttribute,\n\tgetBooleanAttribute,\n\tgetNumberAttribute,\n\thasAttribute,\n\ttoCamelCase,\n\ttoKebabCase,\n} from './xml/attributes.js';\n\n// DOM utility helpers shared across player packages\nexport { assignProps, type AssignPropsOptions } from './dom/assignProps.js';\nexport {\n\tcreateSvelteMountController,\n\ttype SvelteMountController,\n\ttype SvelteMountControllerOptions,\n} from './dom/svelteMountController.js';\nexport { touchDrag, touchDragStyles } from './dom/touchDrag.js';\n\n// Parser factory\nexport {\n\tcreateQtiParser,\n\tcreateMapperForVersion,\n\tcreateAttributeMapperForVersion,\n\tisQti2,\n\tisQti3,\n\ttype QtiParserResult,\n\ttype CreateParserOptions,\n} from './parser-factory.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/qti-common",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"node-html-parser": "^9.0.4"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@types/bun": "^1.4.
|
|
9
|
+
"@types/bun": "^1.4.3",
|
|
10
10
|
"@xmldom/xmldom": "^0.9.12",
|
|
11
|
-
"typescript": "^5.9.3"
|
|
12
|
-
"vitest": "^4.1.11"
|
|
11
|
+
"typescript": "^5.9.3"
|
|
13
12
|
},
|
|
14
13
|
"exports": {
|
|
15
14
|
".": {
|