def export_xhtml(html, filename, image_tag=None):
    """ Export the contents of the ConsoleWidget as XHTML with inline SVGs.

    Parameters:
    -----------
    html : str,
        A utf-8 encoded Python string containing the Qt HTML to export.

    filename : str
        The file to be saved.

    image_tag : callable, optional (default None)
        Used to convert images. See ``default_image_tag()`` for information.
    """
    if image_tag is None:
        image_tag = default_image_tag
    else:
        image_tag = ensure_utf8(image_tag)

    with open(filename, 'w') as f:
        # Hack to make xhtml header -- note that we are not doing any check for
        # valid XML.
        offset = html.find("<html>")
        assert offset > -1, 'Invalid HTML string: no <html> tag.'
        html = ('<html xmlns="http://www.w3.org/1999/xhtml">\n'+
                html[offset+6:])

        html = fix_html(html)
        f.write(IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"),
                           html))
Export the contents of the ConsoleWidget as XHTML with inline SVGs.

    Parameters:
    -----------
    html : str,
        A utf-8 encoded Python string containing the Qt HTML to export.

    filename : str
        The file to be saved.

    image_tag : callable, optional (default None)
        Used to convert images. See ``default_image_tag()`` for information.