case_text.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CaseText = void 0;
  4. const semantic_meaning_js_1 = require("../semantic_tree/semantic_meaning.js");
  5. const abstract_enrich_case_js_1 = require("./abstract_enrich_case.js");
  6. const EnrichMathml = require("./enrich_mathml.js");
  7. const enrich_attr_js_1 = require("./enrich_attr.js");
  8. class CaseText extends abstract_enrich_case_js_1.AbstractEnrichCase {
  9. static test(semantic) {
  10. return (semantic.type === semantic_meaning_js_1.SemanticType.PUNCTUATED &&
  11. (semantic.role === semantic_meaning_js_1.SemanticRole.TEXT ||
  12. semantic.contentNodes.every((x) => x.role === semantic_meaning_js_1.SemanticRole.DUMMY)));
  13. }
  14. constructor(semantic) {
  15. super(semantic);
  16. this.mml = semantic.mathmlTree;
  17. }
  18. getMathml() {
  19. const children = [];
  20. const collapsed = EnrichMathml.collapsePunctuated(this.semantic, children);
  21. this.mml = EnrichMathml.introduceNewLayer(children, this.semantic);
  22. (0, enrich_attr_js_1.setAttributes)(this.mml, this.semantic);
  23. this.mml.removeAttribute(enrich_attr_js_1.Attribute.CONTENT);
  24. EnrichMathml.addCollapsedAttribute(this.mml, collapsed);
  25. return this.mml;
  26. }
  27. }
  28. exports.CaseText = CaseText;