def _clean_markdown_formatting(self, text: str) -> str:
        """
        Uses regex to clean up markdown formatting, ensuring symbols don't surround whitespace.
        This will fix issues with bold (** or __) and italic (* or _) markdown where there may be
        spaces between the markers and the text.
        """
        patterns = [
            (
                r"(\*\*|__)\s+",
                r"\1",
            ),  # Remove space after opening bold or italic marker
            (
                r"\s+(\*\*|__)",
                r"\1",
            ),  # Remove space before closing bold or italic marker
            (r"(\*|_)\s+", r"\1"),  # Remove space after opening italic marker
            (r"\s+(\*|_)", r"\1"),  # Remove space before closing italic marker
            (
                r"(\*\*|__)(\*\*|__)",
                r"\1 \2",
            ),  # Add a space between adjacent identical markers
        ]

        cleaned_text = text
        for pattern, replacement in patterns:
            cleaned_text = re.sub(pattern, replacement, cleaned_text)

        return cleaned_text

        Uses regex to clean up markdown formatting, ensuring symbols don't surround whitespace.
        This will fix issues with bold (** or __) and italic (* or _) markdown where there may be
        spaces between the markers and the text.
        
src/openparse/schemas.py