case_proof.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CaseProof = 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 CaseProof extends abstract_enrich_case_js_1.AbstractEnrichCase {
  9. static test(semantic) {
  10. return (!!semantic.mathmlTree &&
  11. (semantic.type === semantic_meaning_js_1.SemanticType.INFERENCE ||
  12. semantic.type === semantic_meaning_js_1.SemanticType.PREMISES));
  13. }
  14. constructor(semantic) {
  15. super(semantic);
  16. this.mml = semantic.mathmlTree;
  17. }
  18. getMathml() {
  19. if (!this.semantic.childNodes.length) {
  20. return this.mml;
  21. }
  22. this.semantic.contentNodes.forEach(function (x) {
  23. EnrichMathml.walkTree(x);
  24. (0, enrich_attr_js_1.setAttributes)(x.mathmlTree, x);
  25. });
  26. this.semantic.childNodes.forEach(function (x) {
  27. EnrichMathml.walkTree(x);
  28. });
  29. (0, enrich_attr_js_1.setAttributes)(this.mml, this.semantic);
  30. if (this.mml.getAttribute('data-semantic-id') ===
  31. this.mml.getAttribute('data-semantic-parent')) {
  32. this.mml.removeAttribute('data-semantic-parent');
  33. }
  34. return this.mml;
  35. }
  36. }
  37. exports.CaseProof = CaseProof;