import re # Conversion from Slack mrkdwn to OpenAI markdown # See also: https://api.slack.com/reference/surfaces/formatting#basics def slack_to_markdown(content: str) -> str: # Split the input string into parts based on code blocks and inline code parts = re.split(r"(```.+?```|`[^`\n]+?`)", content) # Apply the bold, italic, and strikethrough formatting to text not within code result = "" for part in parts: if part.startswith("```") or part.startswith("`"): result += part else: for o, n in [ (r"\*(?!\s)([^\*\n]+?)(? str: # Split the input string into parts based on code blocks and inline code parts = re.split(r"(```.+?```|`[^`\n]+?`)", content) # Apply the bold, italic, and strikethrough formatting to text not within code result = "" for part in parts: if part.startswith("```") or part.startswith("`"): result += part else: for o, n in [ ( r"\*\*\*(?!\s)([^\*\n]+?)(?