mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-18 10:44:33 +08:00
Fixes chatbot does not display code blocks correctly (#3816)
* fix * changelog * Update CHANGELOG.md * style code blocks * next beta version for release --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
9f4f851d68
commit
c772c6ae57
@ -14,8 +14,8 @@ with gr.Blocks() as demo:
|
||||
```
|
||||
|
||||
## Bug Fixes:
|
||||
- Fix code markdown support in `gr.Chatbot()` component by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3816](https://github.com/gradio-app/gradio/pull/3816)
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
## Documentation Changes:
|
||||
|
||||
|
@ -4364,8 +4364,12 @@ class Chatbot(Changeable, Selectable, IOComponent, JSONSerializable):
|
||||
"is_file": True,
|
||||
}
|
||||
elif isinstance(chat_message, str):
|
||||
chat_message = chat_message.replace("\n", "<br>")
|
||||
return self.md.renderInline(chat_message)
|
||||
children = self.md.parseInline(chat_message)[0].children
|
||||
if children and any("code" in child.tag for child in children):
|
||||
return self.md.render(chat_message)
|
||||
else:
|
||||
chat_message = chat_message.replace("\n", "<br>")
|
||||
return self.md.renderInline(chat_message)
|
||||
else:
|
||||
raise ValueError(f"Invalid message for Chatbot component: {chat_message}")
|
||||
|
||||
|
@ -1 +1 @@
|
||||
3.25.1b1
|
||||
3.25.1b2
|
||||
|
@ -252,4 +252,8 @@
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.message-wrap :global(pre) {
|
||||
padding: var(--spacing-xl) 0px;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user