12 replace($, <msqrt>$</msqrt>)
16 replace($, <mroot><mrow/><mrow>$</mrow></mroot>)
20 when (isa($.parent, "mrow") && isa($.parent.parent, "mroot"))
21 let mroot = $.parent.parent
22 if ($.prev and !$.prev.prev and !$.next) replace($.parent, $.prev)
23 replace(mroot.child[0], $)
27 insert(<munder>[$, <mo>_</mo>]</munder>)
31 insert(<mover>[$, <mo>‾</mo>]</mover>)
35 replace($, <mrow><mo>{</mo><mtable>$</mtable></mrow>)
39 replace($, <mtable>$</mtable>)
43 if isa($.parent, "mrow")
44 replace($.parent, <mfrac>[$.parent, $]</mfrac>)
47 _ if isa($.parent, "mrow")
49 replace($, new(mmultiscripts, [ new mrow, $, new none ]))
50 elseif (isa($.prev, msub))
51 let base = $.prev.children[0]
52 let script = $.prev.children[1]
53 replace($.rev, new(mmultiscripts, [ base, script, new none, $, new none ]))
54 elseif (isa($.prev, msup))
55 let base = $.prev.children[0]
56 let script = $.prev.children[1]
57 replace($.prev, new(msubsup, [ base, $, script ]))
58 elseif (isa($.prev, msubsup))
59 let base = $.prev.children[0]
60 let subscript = $.prev.children[1]
61 let superscript = $.prev.children[2]
62 replace($.prev, new(mmultiscripts, [ base, subscript, superscript, $, new none ]))
63 elseif isa($.prev, mmultiscripts)
64 if ($.prev.children[$.prev.children.size - 2] = null)
65 replace($.prev.children[$.prev.children.size - 2], $)
67 $.prev.children.append([$, new none])
69 replace($.prev, new(msub, [ $.prev, $ ]))
70 else if isa($.parent, msub) and $.parent.children[1] = $
71 let base = $.parent.children[0]
72 replace($.parent, new(munder, [ base, $ ]))
78 if cursor is first child then
79 sub = new mmultiscripts
80 parent.replace(cursor, sub);
81 sub.set_base(new mrow);
82 sub.set_subscript(cursor);
84 elem = element prior to cursor in parent
85 if elem.isa(msub) || elem.isa(msup) || elem.isa(mmultiscripts) then
86 append script to multiscript and/or replace single script with
88 else if elem.isa(munder) || elem.isa(mover) || elem.isa(munderover) then
89 creates another munder
91 parent.replace(elem, sub);
93 sub.set_subscript(cursor);
94 else if (parent.isa(msub) and cursor is subscript) or
95 change msub into a munder
96 cursor in same position
98 replace cursor with msub with empty base
102 symmetric to subscript
106 similar to superscript, but multiple prime superscripts should go
107 together in the same operator
111 replace cursor with mrow, put cursor inside mrow
112 if cursor is inside a table, create a new table row and a new table cell
113 and put the cursor inside the cell
117 remove cursor from mrow
118 mrow.parent.advance(cursor, mrow)
119 if cursor inside a table cell then close table
121 \over,\atop,\above (fraction)
123 if cursor.parent.isa(mrow) then
125 cursor.parent.parent.replace(mrow, frac)
126 numerator is current content of cursor.parent except for the cursor
128 set denominator to cursor
133 similar to fractions, but with stretchable parentheses around
137 parent.replace(cursor, new msqrt)
138 set new msqrt.base to cursor
142 parent.replace(cursor, new mroot)
143 set empty base element
144 set root index to cursor
148 check if cursor.parent is mroot (or mrow inside mroot index)
149 or and cursor is in index position. move the cursor to the base element
153 create munder element with stretchable horizontal line as underscript
154 substitute cursor with munder
155 move the cursor in the base element
163 create an mover with accent=true and the operator has stretchy=false
165 wide accents (\widehat)
167 as accents, but mover has accent=false and the operator has stretchy=true
171 create an appropriate mstyle, the cursor moves in. However, when the
172 subformula ends one has to skip the mstyle
176 create mrow with stretchable brace and emtpy table, put cursor inside
181 create empty table, cursor inside table
185 check that cursor is inside a table cell
186 create a new cell next to it
190 check that cursor is inside a table cell inside a table row
195 create a mphantom element, cursor inside