UNPKG

speech-rule-engine

Version:

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

36 lines 1.12 kB
import * as DomUtil from '../common/dom_util.js'; import { EnginePromise } from '../common/engine.js'; import * as Semantic from '../semantic_tree/semantic.js'; import * as EnrichMathml from './enrich_mathml.js'; import './enrich_case_factory.js'; export function semanticMathmlNode(mml, options) { const clone = DomUtil.cloneNode(mml); const tree = Semantic.getTree(clone, options); return EnrichMathml.enrich(clone, tree, options); } export function semanticMathmlSync(expr, options) { const mml = DomUtil.parseInput(expr); try { return semanticMathmlNode(mml, options); } catch (err) { console.error(err); return mml; } } export function semanticMathml(expr, options, callback) { EnginePromise.getall().then(() => { const mml = DomUtil.parseInput(expr); callback(semanticMathmlNode(mml, options)); }); } export function prepareMmlString(expr) { if (!expr.match(/^<math/)) { expr = '<math>' + expr; } if (!expr.match(/\/math>$/)) { expr += '</math>'; } return expr; } //# sourceMappingURL=enrich.js.map