diff --git a/rich/prompt.py b/rich/prompt.py index c7cf25bae8..ae94d9bb87 100644 --- a/rich/prompt.py +++ b/rich/prompt.py @@ -262,7 +262,7 @@ def on_validate_error(self, value: str, error: InvalidResponse) -> None: value (str): String entered by user. error (InvalidResponse): Exception instance the initiated the error. """ - self.console.print(error) + self.console.print(error, markup=True) def pre_prompt(self) -> None: """Hook to display something before the prompt.""" diff --git a/tests/test_prompt.py b/tests/test_prompt.py index 11bffa71b0..e254cd4980 100644 --- a/tests/test_prompt.py +++ b/tests/test_prompt.py @@ -111,3 +111,16 @@ def test_prompt_confirm_default(): output = console.file.getvalue() print(repr(output)) assert output == expected + + +def test_prompt_confirm_markup(): + INPUT = "foo\nNO\ny" + console = Console(file=io.StringIO(), markup=False) + answer = Confirm.ask( + "continue", console=console, stream=io.StringIO(INPUT), default=True + ) + assert answer is True + expected = "continue [y/n] (y): Please enter Y or N\ncontinue [y/n] (y): Please enter Y or N\ncontinue [y/n] (y): " + output = console.file.getvalue() + print(repr(output)) + assert output == expected