diff --git a/src/pipecat/utils/text/markdown_text_filter.py b/src/pipecat/utils/text/markdown_text_filter.py index 76c739c4b..2344d3779 100644 --- a/src/pipecat/utils/text/markdown_text_filter.py +++ b/src/pipecat/utils/text/markdown_text_filter.py @@ -40,8 +40,8 @@ class MarkdownTextFilter(BaseTextFilter): def filter(self, text: str) -> str: if self._settings.enable_text_filter: - # Remove newlines only when there's no text before or after - filtered_text = re.sub(r"^\s*\n", "", text, flags=re.MULTILINE) + # Remove newlines and replace with a space only when there's no text before or after + filtered_text = re.sub(r"^\s*\n", " ", text, flags=re.MULTILINE) # Remove backticks from inline code, but not from code blocks filtered_text = re.sub(r"(?