case_line.js 841 B

1234567891011121314151617181920212223
  1. import { SemanticType } from '../semantic_tree/semantic_meaning.js';
  2. import { AbstractEnrichCase } from './abstract_enrich_case.js';
  3. import * as EnrichMathml from './enrich_mathml.js';
  4. import { setAttributes } from './enrich_attr.js';
  5. export class CaseLine extends AbstractEnrichCase {
  6. static test(semantic) {
  7. return !!semantic.mathmlTree && semantic.type === SemanticType.LINE;
  8. }
  9. constructor(semantic) {
  10. super(semantic);
  11. this.mml = semantic.mathmlTree;
  12. }
  13. getMathml() {
  14. if (this.semantic.contentNodes.length) {
  15. EnrichMathml.walkTree(this.semantic.contentNodes[0]);
  16. }
  17. if (this.semantic.childNodes.length) {
  18. EnrichMathml.walkTree(this.semantic.childNodes[0]);
  19. }
  20. setAttributes(this.mml, this.semantic);
  21. return this.mml;
  22. }
  23. }