from rich.console import Console
from rich.markdown import Markdown
from rich.syntax import Syntax


def process_syntax(code, lang, theme, line_numbers, code_width, word_wrap):
    syntax = Syntax(
        code,
        lang,
        theme=theme,
        line_numbers=line_numbers,
        code_width=code_width,
        word_wrap=word_wrap,
    )
    return syntax


def display_markdown(code):
    try:
        markdown = Markdown(code)
        console = Console()
        console.print(markdown)  # noqa
        return True  # Success
    except Exception:
        return False  # Failure


def display_code(code):
    try:
        console = Console()
        console.print(code)  # noqa
        return True  # Success
    except Exception:
        return False  # Failure


def fix_emoji_spacing(code):
    try:
        # Fix the display width of certain emojis that take up two spaces
        double_width_emojis = ["🗺️", "🖼️", "🗄️", "⏺️", "♻️", "🗂️", "🖥️"]
        for emoji in double_width_emojis:
            if emoji in code:
                code = code.replace(emoji, emoji + " ")
    except Exception:
        pass
    return code

@@ -914,16 +914,29 @@
 ojis = %5B
+%0A            
 %22%F0%9F%97%BA%EF%B8%8F%22, %22%F0%9F%96%BC
@@ -967,16 +967,37 @@
 %EF%B8%8F%22, %22%F0%9F%96%A5%EF%B8%8F%22
+, %22%F0%9F%95%B9%EF%B8%8F%22, %22%F0%9F%8E%9E%EF%B8%8F%22%0A        
 %5D%0A      

Update double_width_emojis list to improve "rich" printing