addPow method
void
addPow(
- TeXFunction pow
Adds a pow to the current node
If the expression is ^2 instead of ^, we want to set 2 as the argument of the pow function directly.
Implementation
void addPow(TeXFunction pow) {
final posBefore = currentNode.courserPosition - 1;
/// We don't allow having to pow's next to each other (x^2^2), since this
/// is not supported by TeX.
if (currentNode.children.isEmpty ||
currentNode.courserPosition == 0 ||
currentNode.children[posBefore].expression == '^' ||
currentNode.courserPosition < currentNode.children.length &&
currentNode.children[posBefore + 1].expression == '^') {
return;
}
if (pow.expression.endsWith('2')) {
final powCopy = TeXFunction('^', pow.parent, pow.args, pow.argNodes);
powCopy.argNodes.first.addTeX(const TeXLeaf('2'));
currentNode.addTeX(powCopy);
} else {
currentNode.addTeX(pow);
currentNode = pow.argNodes.first;
}
}