File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
prompt_toolkit/formatted_text Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 27
27
fragment_list_to_text ,
28
28
fragment_list_width ,
29
29
split_lines ,
30
+ to_plain_text ,
30
31
)
31
32
32
33
__all__ = [
49
50
"fragment_list_width" ,
50
51
"fragment_list_to_text" ,
51
52
"split_lines" ,
53
+ "to_plain_text" ,
52
54
]
Original file line number Diff line number Diff line change 8
8
9
9
from prompt_toolkit .utils import get_cwidth
10
10
11
- from .base import OneStyleAndTextTuple , StyleAndTextTuples
11
+ from .base import (
12
+ AnyFormattedText ,
13
+ OneStyleAndTextTuple ,
14
+ StyleAndTextTuples ,
15
+ to_formatted_text ,
16
+ )
12
17
13
18
__all__ = [
19
+ "to_plain_text" ,
14
20
"fragment_list_len" ,
15
21
"fragment_list_width" ,
16
22
"fragment_list_to_text" ,
17
23
"split_lines" ,
18
24
]
19
25
20
26
27
+ def to_plain_text (value : AnyFormattedText ) -> str :
28
+ """
29
+ Turn any kind of formatted text back into plain text.
30
+ """
31
+ return fragment_list_to_text (to_formatted_text (value ))
32
+
33
+
21
34
def fragment_list_len (fragments : StyleAndTextTuples ) -> int :
22
35
"""
23
36
Return the amount of characters in this text fragment list.
You can’t perform that action at this time.
0 commit comments