def METHOD_NAME():
    html = HTML("<i>hello</i>")
    assert to_formatted_text(html) == [("class:i", "hello")]
    html = HTML("<i><b>hello</b></i>")
    assert to_formatted_text(html) == [("class:i,b", "hello")]
    html = HTML("<i><b>hello</b>world<strong>test</strong></i>after")
    assert to_formatted_text(html) == [
        ("class:i,b", "hello"),
        ("class:i", "world"),
        ("class:i,strong", "test"),
        ("", "after"),
    ]
    # It's important that `to_formatted_text` returns a `FormattedText`
    # instance. Otherwise, `print_formatted_text` won't recognise it and will
    # print a list literal instead.
    assert isinstance(to_formatted_text(html), FormattedText)