File tree 3 files changed +69
-61
lines changed
__snapshots__/test_snapshots
3 files changed +69
-61
lines changed Original file line number Diff line number Diff line change 19
19
from rich ._wrap import divide_line
20
20
from rich .cells import set_cell_size
21
21
from rich .console import OverflowMethod
22
+ from rich .errors import MissingStyle
22
23
from rich .segment import Segment , Segments
23
24
from rich .terminal_theme import TerminalTheme
24
25
from rich .text import Text
@@ -744,9 +745,12 @@ def render(
744
745
745
746
@lru_cache (maxsize = 1024 )
746
747
def get_style (style : str , / ) -> Style :
747
- visual_style = Style .from_rich_style (
748
- app .console .get_style (style ), app .ansi_theme
749
- )
748
+ try :
749
+ visual_style = Style .from_rich_style (
750
+ app .console .get_style (style ), app .ansi_theme
751
+ )
752
+ except MissingStyle :
753
+ visual_style = Style ()
750
754
return visual_style
751
755
752
756
else :
Original file line number Diff line number Diff line change @@ -3316,12 +3316,16 @@ def compose(self) -> ComposeResult:
3316
3316
def test_static_markup (snap_compare ):
3317
3317
"""Check that markup may be disabled.
3318
3318
3319
- You should see two labels, the first uses markup.
3320
- The second has markup disabled, and tags should be visible.
3319
+ You should see 3 labels.
3320
+
3321
+ This first label contains an invalid style, and should have tags removed.
3322
+ The second label should have the word "markup" boldened.
3323
+ The third label has markup disabled, and should show tags without styles.
3321
3324
"""
3322
3325
3323
3326
class LabelApp (App ):
3324
3327
def compose (self ) -> ComposeResult :
3328
+ yield Label ("There should be no [foo]tags or style[/foo]" )
3325
3329
yield Label ("This allows [bold]markup[/bold]" )
3326
3330
yield Label ("This does not allow [bold]markup[/bold]" , markup = False )
3327
3331
You can’t perform that action at this time.
0 commit comments