UNPKG

speech-rule-engine

Version:

A standalone speech rule engine for XML structures, based on the original engine from ChromeVox.

23 lines 1.01 kB
import { AbstractEnrichCase } from './abstract_enrich_case.js'; import { introduceNewLayer, walkTree } from './enrich_mathml.js'; import { setAttributes } from './enrich_attr.js'; export class CaseCollapsedScript extends AbstractEnrichCase { static test(semantic) { var _a, _b; const ann = semantic.getAnnotation('collapsed'); if (!ann.length) { return false; } return ((_b = (_a = semantic.mathmlTree) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.childNodes.length) > 2; } getMathml() { walkTree(this.semantic.childNodes[0]); walkTree(this.semantic.childNodes[1]); const collapsed = this.semantic.mathmlTree; const script = this.semantic.childNodes[0].mathmlTree; const newNode = introduceNewLayer([script, collapsed], this.semantic); setAttributes(newNode, this.semantic); return newNode; } } //# sourceMappingURL=case_collapsed_script.js.map