Reality123b commited on
Commit
d359198
·
verified ·
1 Parent(s): 2b844de

Update application/static/js/components/renderSymbols.js

Browse files
application/static/js/components/renderSymbols.js CHANGED
@@ -1,4 +1,3 @@
1
- // application/static/js/components/renderSymbols.js
2
  class RenderSymbols{
3
  constructor(){
4
 
@@ -7,13 +6,13 @@ class RenderSymbols{
7
  this.renderText(elem);
8
  this.renderCode(elem);
9
  this.renderMath(elem);
10
- // elem.scrollIntoView({behavior: "smooth", block: "end"}); // Remove auto-scroll
11
  }
12
  renderMath(elem) {
13
  let content = elem.innerHTML;
14
  MathJax.typesetPromise([elem])
15
  .then(() => {
16
-
17
  })
18
  .catch((err) => {
19
 
@@ -28,18 +27,18 @@ class RenderSymbols{
28
  }
29
  renderCode(element) {
30
  let content = element.innerHTML;
31
-
32
  if (content.includes("```") && content.split("```").length >= 3) {
33
  content = content.replace(/```(\w*)<br>([\s\S]*?)```/g, (match, language, code) => {
34
  code = code.replace(/<br>/g, '\n').trim();
35
- language = language.trim() || 'text';
36
  code = this.escapeHTML(code);
37
-
38
  return `<pre class="code-block"><code class="language-${language}">${code}</code></pre>`;
39
  });
40
-
41
  element.innerHTML = content;
42
-
43
  element.querySelectorAll('code:not(.hljs)').forEach(block => {
44
  hljs.highlightElement(block);
45
  });
@@ -48,15 +47,15 @@ class RenderSymbols{
48
  escapeHTML(str) {
49
  return str.replace(/[&<>"']/g, function (char) {
50
  const map = {
51
- '&': '🔒', // Lock emoji for ampersand
52
- '<': '◀️', // Left arrow for less-than
53
- '>': '▶️', // Right arrow for greater-than
54
- '"': '💬', // Speech balloon for double quote
55
- "'": '📝' // Memo/pencil for single quote
56
  };
57
  return map[char] || char;
58
  });
59
  }
60
-
61
  }
62
  export default RenderSymbols
 
 
1
  class RenderSymbols{
2
  constructor(){
3
 
 
6
  this.renderText(elem);
7
  this.renderCode(elem);
8
  this.renderMath(elem);
9
+ elem.scrollIntoView({behavior: "smooth", block: "end"});
10
  }
11
  renderMath(elem) {
12
  let content = elem.innerHTML;
13
  MathJax.typesetPromise([elem])
14
  .then(() => {
15
+
16
  })
17
  .catch((err) => {
18
 
 
27
  }
28
  renderCode(element) {
29
  let content = element.innerHTML;
30
+
31
  if (content.includes("```") && content.split("```").length >= 3) {
32
  content = content.replace(/```(\w*)<br>([\s\S]*?)```/g, (match, language, code) => {
33
  code = code.replace(/<br>/g, '\n').trim();
34
+ language = language.trim() || 'text';
35
  code = this.escapeHTML(code);
36
+
37
  return `<pre class="code-block"><code class="language-${language}">${code}</code></pre>`;
38
  });
39
+
40
  element.innerHTML = content;
41
+
42
  element.querySelectorAll('code:not(.hljs)').forEach(block => {
43
  hljs.highlightElement(block);
44
  });
 
47
  escapeHTML(str) {
48
  return str.replace(/[&<>"']/g, function (char) {
49
  const map = {
50
+ '&': '&amp;',
51
+ '<': '&lt;',
52
+ '>': '&gt;',
53
+ '"': '&quot;',
54
+ "'": '&#39;',
55
  };
56
  return map[char] || char;
57
  });
58
  }
59
+
60
  }
61
  export default RenderSymbols