diff --git a/lib/chatmark/widgets.py b/lib/chatmark/widgets.py index 4dedba3..a8c1d90 100644 --- a/lib/chatmark/widgets.py +++ b/lib/chatmark/widgets.py @@ -209,11 +209,11 @@ class TextEditor(Widget): def _handle_block_flag(self, text: str): """convert \\ to \\, and ` to \\`""" - return text.replace("\\", "\\\\").replace("`", "\\`") + return text.replace("```", "\\`\\`\\`") if text else text def _remove_block_flag(self, text: str): """convert \\ to \\, and \\` to `""" - return text.replace("\\`", "`").replace("\\\\", "\\") + return text.replace("\\`\\`\\`", "```") if text else text @property def new_text(self) -> Optional[str]: