from bs4 import BeautifulSoup
import re


def prettify_with_space(
        s: BeautifulSoup,
        encoding=None,
        formatter="minimal",
        indent: int = 2
):
    """
    Re-indent the BS4 output
    https://stackoverflow.com/questions/15509397/custom-indent-width-for-beautifulsoup-prettify
    """
    r = re.compile(r'^(\s*)', re.MULTILINE)
    return r.sub(r'\1' * indent, s.prettify(encoding, formatter))