def addmargins(blocks):
    """Adds empty blocks for vertical spacing.

    This groups bullets, options, and definitions together with no vertical
    space between them, and adds an empty block between all other blocks.
    """
    i = 1
    while i < len(blocks):
        if blocks[i][b'type'] == blocks[i - 1][b'type'] and blocks[i][
            b'type'
        ] in (
            b'bullet',
            b'option',
            b'field',
        ):
            i += 1
        elif not blocks[i - 1][b'lines']:
            # no lines in previous block, do not separate
            i += 1
        else:
            blocks.insert(
                i, {b'lines': [b''], b'indent': 0, b'type': b'margin'}
            )
            i += 2
    return blocks