File size: 3,603 Bytes
f56a29b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
export function menclose(element, targetParent, previousSibling, nextSibling, ancestors) {
  const type = element.attribs?.notation?.split(' ')[0] || 'longdiv'

  const targetElement = {
    type: 'tag',
    name: 'm:e',
    attribs: {},
    children: []
  }

  if (type === 'longdiv') {
    targetParent.children.push({
      type: 'tag',
      name: 'm:rad',
      attribs: {},
      children: [
        {
          type: 'tag',
          name: 'm:radPr',
          attribs: {},
          children: [{ type: 'tag', name: 'm:degHide', attribs: { 'm:val': 'on' }, children: [] }]
        },
        { type: 'tag', name: 'm:deg', attribs: {}, children: [] },
        targetElement
      ]
    })
  } else {
    const hide = {
      t: { type: 'tag', name: 'm:hideTop', attribs: { 'm:val': 'on' }, children: [] },
      b: { type: 'tag', name: 'm:hideBot', attribs: { 'm:val': 'on' }, children: [] },
      l: { type: 'tag', name: 'm:hideLeft', attribs: { 'm:val': 'on' }, children: [] },
      r: { type: 'tag', name: 'm:hideRight', attribs: { 'm:val': 'on' }, children: [] }
    }
    const borderBoxPr = { type: 'tag', name: 'm:borderBoxPr', attribs: {}, children: [] }

    const containerElement = {
      type: 'tag',
      name: 'm:borderBox',
      attribs: {},
      children: []
    }
    switch (type) {
      case 'actuarial':
      case 'radical':
      case 'box':
        containerElement.children = [targetElement]
        break
      case 'left':
      case 'roundedbox':
        borderBoxPr.children = [hide.t, hide.b, hide.r]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'right':
      case 'circle':
        borderBoxPr.children = [hide.t, hide.b, hide.l]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'top':
        borderBoxPr.children = [hide.b, hide.l, hide.r]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'bottom':
        borderBoxPr.children = [hide.t, hide.l, hide.r]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'updiagonalstrike':
        borderBoxPr.children = [
          hide.t,
          hide.b,
          hide.l,
          hide.r,
          { type: 'tag', name: 'm:strikeBLTR', attribs: { 'm:val': 'on' }, children: [] }
        ]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'downdiagonalstrike':
        borderBoxPr.children = [
          hide.t,
          hide.b,
          hide.l,
          hide.r,
          { type: 'tag', name: 'm:strikeTLBR', attribs: { 'm:val': 'on' }, children: [] }
        ]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'verticalstrike':
        borderBoxPr.children = [
          hide.t,
          hide.b,
          hide.l,
          hide.r,
          { type: 'tag', name: 'm:strikeV', attribs: { 'm:val': 'on' }, children: [] }
        ]
        containerElement.children = [borderBoxPr, targetElement]
        break
      case 'horizontalstrike':
        borderBoxPr.children = [
          hide.t,
          hide.b,
          hide.l,
          hide.r,
          { type: 'tag', name: 'm:strikeH', attribs: { 'm:val': 'on' }, children: [] }
        ]
        containerElement.children = [borderBoxPr, targetElement]
        break
      default:
        borderBoxPr.children = [hide.t, hide.b, hide.l, hide.r]
        containerElement.children = [borderBoxPr, targetElement]
        break
    }
    targetParent.children.push(containerElement)
  }
  return targetElement
}