import re


def format_cell_delimiters(text: str) -> str:
    """Ensure single space between hash and double-percent.

    --- before ---
    #   %%
    #%%
    --- after ---
    # %%
    # %%
    """
    return re.sub(r"(?m)^#\s*%%", r"# %%", text)