from bs4 import BeautifulSoup


def fix_pre(html: str, prefix: str = "") -> str:
    """Fixes an individual <pre> tag from Gnome.

    Optionally prepends a given prefix to each line in the returned output.
    """
    soup = BeautifulSoup(html, "html.parser")

    for pre in soup.find_all("pre"):
        for tag in pre.find_all("font"):
            # <font color=xxx> -> <span style="color: xxx">
            tag.name = "span"
            color = tag.attrs.pop("color")
            tag["style"] = f"color: {color}"

    return "".join(prefix + line for line in str(soup).splitlines(keepends=True))