From 5eed1cca46af258adc9641e6e023de0abd949caf Mon Sep 17 00:00:00 2001 From: Dawood Date: Wed, 10 May 2023 14:04:19 -0400 Subject: [PATCH 1/8] using marked --- gradio/components.py | 3 -- js/chatbot/package.json | 5 ++- js/chatbot/src/ChatBot.svelte | 26 +++++++++++++- pnpm-lock.yaml | 65 +++++++++++++++++++++++++++++++++-- 4 files changed, 92 insertions(+), 7 deletions(-) diff --git a/gradio/components.py b/gradio/components.py index bc45926cd2172..5cc7ad31f4c88 100644 --- a/gradio/components.py +++ b/gradio/components.py @@ -4599,9 +4599,6 @@ def _postprocess_chat_messages( } elif isinstance(chat_message, str): chat_message = inspect.cleandoc(chat_message) - chat_message = cast(str, self.md.render(chat_message)) - if chat_message.startswith("

") and chat_message.endswith("

\n"): - chat_message = chat_message[3:-5] return chat_message else: raise ValueError(f"Invalid message for Chatbot component: {chat_message}") diff --git a/js/chatbot/package.json b/js/chatbot/package.json index 5db42768d58d5..7bab0e6a98508 100644 --- a/js/chatbot/package.json +++ b/js/chatbot/package.json @@ -10,6 +10,9 @@ "dependencies": { "@gradio/theme": "workspace:^0.0.1", "@gradio/utils": "workspace:^0.0.1", - "@gradio/upload": "workspace:^0.0.1" + "@gradio/upload": "workspace:^0.0.1", + "marked": "^5.0.1", + "marked-highlight":"^1.0.1", + "highlight.js":"^11.8.0" } } diff --git a/js/chatbot/src/ChatBot.svelte b/js/chatbot/src/ChatBot.svelte index 9437d27d352cd..d42978140ca21 100644 --- a/js/chatbot/src/ChatBot.svelte +++ b/js/chatbot/src/ChatBot.svelte @@ -1,4 +1,8 @@