Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
e91da60
1
Parent(s):
6f70034
fix: 解决仅供查看历史记录的代码块多出空行的问题
Browse files但是解决办法是删除了gradio提供的复制按钮。workaround吧。
- assets/custom.js +4 -0
- modules/utils.py +1 -0
assets/custom.js
CHANGED
|
@@ -443,9 +443,13 @@ function loadHistoryHtml() {
|
|
| 443 |
var tempDiv = document.createElement('div');
|
| 444 |
tempDiv.innerHTML = historyHtml;
|
| 445 |
var buttons = tempDiv.querySelectorAll('button.chuanhu-btn');
|
|
|
|
| 446 |
for (var i = 0; i < buttons.length; i++) {
|
| 447 |
buttons[i].parentNode.removeChild(buttons[i]);
|
| 448 |
}
|
|
|
|
|
|
|
|
|
|
| 449 |
var fakeHistory = document.createElement('div');
|
| 450 |
fakeHistory.classList.add('history-message');
|
| 451 |
fakeHistory.innerHTML = tempDiv.innerHTML;
|
|
|
|
| 443 |
var tempDiv = document.createElement('div');
|
| 444 |
tempDiv.innerHTML = historyHtml;
|
| 445 |
var buttons = tempDiv.querySelectorAll('button.chuanhu-btn');
|
| 446 |
+
var gradioCopyButtons = tempDiv.querySelectorAll('button.copy_code_button');
|
| 447 |
for (var i = 0; i < buttons.length; i++) {
|
| 448 |
buttons[i].parentNode.removeChild(buttons[i]);
|
| 449 |
}
|
| 450 |
+
for (var i = 0; i < gradioCopyButtons.length; i++) {
|
| 451 |
+
gradioCopyButtons[i].parentNode.removeChild(gradioCopyButtons[i]);
|
| 452 |
+
}
|
| 453 |
var fakeHistory = document.createElement('div');
|
| 454 |
fakeHistory.classList.add('history-message');
|
| 455 |
fakeHistory.innerHTML = tempDiv.innerHTML;
|
modules/utils.py
CHANGED
|
@@ -231,6 +231,7 @@ def escape_markdown(text):
|
|
| 231 |
Escape Markdown special characters to HTML-safe equivalents.
|
| 232 |
"""
|
| 233 |
escape_chars = {
|
|
|
|
| 234 |
'_': '_',
|
| 235 |
'*': '*',
|
| 236 |
'[': '[',
|
|
|
|
| 231 |
Escape Markdown special characters to HTML-safe equivalents.
|
| 232 |
"""
|
| 233 |
escape_chars = {
|
| 234 |
+
' ': ' ',
|
| 235 |
'_': '_',
|
| 236 |
'*': '*',
|
| 237 |
'[': '[',
|