fix: Escape backticks in error text using Unicode sequence

This commit is contained in:
Bobby Abellana (aider) 2025-02-18 09:44:55 -08:00
parent c162248348
commit 48f03f89f9

View File

@ -526,11 +526,14 @@ if st.session_state.error_log:
copy_button = st.button("Copy Error Log")
if copy_button:
# Create a JavaScript function to copy the text
# Escape any backticks in the error text first
escaped_error_text = error_text.replace('`', '\u0060')
js_code = f"""
<script>
// Create a temporary textarea element
const textarea = document.createElement('textarea');
textarea.value = `{error_text.replace('`', '\\`')}`; // Escape backticks
textarea.value = `{escaped_error_text}`;
document.body.appendChild(textarea);
// Select and copy the text