Fuckingbase commited on
Commit
dd69588
·
verified ·
1 Parent(s): c563354

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +13 -21
index.html CHANGED
@@ -235,7 +235,6 @@
235
  cursor: grab;
236
  }
237
 
238
- /* --- انیمیشن جدید راهنما --- */
239
  #send-button-container::after {
240
  content: '';
241
  position: absolute;
@@ -575,28 +574,21 @@ class ChatInterface {
575
  return '';
576
  });
577
 
578
- let contentHtml = '';
579
- let lastIndex = 0;
580
-
581
- // Create a temporary container to parse the text and handle nested elements
582
- const tempDiv = document.createElement('div');
583
- tempDiv.innerText = processedText; // Safely set text content first
584
-
585
- // Now process for links and code blocks
586
- let processedHtml = tempDiv.innerHTML.replace(markdownLinkRegex, '<a href="$2" target="_blank">$1</a>');
587
-
588
- processedHtml = processedHtml.replace(codeBlockRegex, (match, lang, code) => {
589
- const uniqueId = `code-${Date.now()}-${Math.random()}`;
590
- return `</div><div class="code-block-wrapper">
591
- <div class="code-block-header">
592
- <button class="copy-code-btn" data-target="${uniqueId}">کپی</button>
593
- </div>
594
- <pre><code id="${uniqueId}">${escapeHTML(code.trim())}</code></pre>
595
- </div><div class="message-content">`;
596
- });
597
 
598
  bubble.innerHTML = `
599
- <div class="message-content">${processedHtml.trim()}</div>
600
  ${buttonsHtml ? `<div class="interactive-buttons">${buttonsHtml}</div>` : ''}
601
  `;
602
 
 
235
  cursor: grab;
236
  }
237
 
 
238
  #send-button-container::after {
239
  content: '';
240
  position: absolute;
 
574
  return '';
575
  });
576
 
577
+ let contentHtml = escapeHTML(processedText)
578
+ .replace(markdownLinkRegex, '<a href="$2" target="_blank">$1</a>')
579
+ .replace(codeBlockRegex, (match, lang, code) => {
580
+ const uniqueId = `code-${Date.now()}-${Math.random()}`;
581
+ // Note: The code inside is already escaped from the main escapeHTML call.
582
+ return `<div class="code-block-wrapper">
583
+ <div class="code-block-header">
584
+ <button class="copy-code-btn" data-target="${uniqueId}">کپی</button>
585
+ </div>
586
+ <pre><code id="${uniqueId}">${code.trim()}</code></pre>
587
+ </div>`;
588
+ });
 
 
 
 
 
 
 
589
 
590
  bubble.innerHTML = `
591
+ <div class="message-content">${contentHtml.trim()}</div>
592
  ${buttonsHtml ? `<div class="interactive-buttons">${buttonsHtml}</div>` : ''}
593
  `;
594