Skip to content

doc example on to_formatted_text #742

Open
@2sn

Description

@2sn

The example on https://python-prompt-toolkit.readthedocs.io/en/2.0.5/pages/printing_text.html

from prompt_toolkit.formatted_text import to_formatted_text, HTML
from prompt_toolkit import print_formatted_text

html = HTML('<aaa>Hello</aaa> <bbb>world</bbb>!')
text = to_formatted_text(html, style='class:my_html bg:#00ff00 italic')

print_formatted_text(text)

produces just the output

[('class:my_html bg:#00ff00 italic class:aaa', 'Hello'), ('class:my_html bg:#00ff00 italic ', ' '), ('class:my_html bg:#00ff00 italic class:bbb', 'world'), ('class:my_html bg:#00ff00 italic ', '!')].

I assume this is not what was intended? So it is less clear what it is intended to show and how. It also does not accept a prompt_toolkit.styles.Style object as style, as one would have expected or hoped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions