rebuildRows method

List<List<LatexNode>> rebuildRows(
  1. List<List<LatexNode>> originalRows,
  2. List<LatexNode> newChildren
)

Generic implementation to rebuild rows based on the original row structure. Shared by Matrix/Array/Aligned/Split/Eqnarray/Tabular/Substack.

Implementation

List<List<LatexNode>> rebuildRows(
  List<List<LatexNode>> originalRows,
  List<LatexNode> newChildren,
) {
  final result = <List<LatexNode>>[];
  var idx = 0;

  for (final row in originalRows) {
    result.add(List.generate(row.length, (_) => newChildren[idx++]));
  }

  return result;
}