def grid_boxes(box):
    """Remove and add boxes according to the grid model.

    Take and return a ``Box`` object.

    See https://drafts.csswg.org/css-grid-2/#grid-item

    """
    if not isinstance(box, boxes.ParentBox) or box.is_running():
        return box

    # Do recursion.
    children = [grid_boxes(child) for child in box.children]
    box.children = grid_children(box, children)
    return box
Remove and add boxes according to the grid model.

Take and return a ``Box`` object.

See https://drafts.csswg.org/css-grid-2/#grid-item
weasyprint/formatting_structure/build.py