lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
39.91k stars 9.08k forks source link

[Bug] 写代码时,渲染了react代码,影响观看 #217

Closed GiantappMan closed 11 months ago

GiantappMan commented 11 months ago

💻 系统环境 | Operating System

Windows

🌐 浏览器 | Browser

Chrome

🐛 问题描述 | Bug Description

image

🚦 期望结果 | Expected Behavior

返回代码就行,不要渲染UI

📷 复现步骤 | Recurrence Steps

No response

📝 补充信息 | Additional Information

No response

canisminor1990 commented 11 months ago

是因为没有使用 markdown codeblock 么

GiantappMan commented 11 months ago

我用的全栈 Web 开发人员这个模板。提问:用react写一个修改密码界面 image

canisminor1990 commented 11 months ago

你那段渲染出错的文本能否提供一下,方便复现,我这边复现不出来

image
GiantappMan commented 11 months ago

我刚才刷新了下网页,重现不了。我再试试

GiantappMan commented 11 months ago

重现了。提问:

参考这个代码```其他react代码```,用react写一个修改密码界面 

只要加了```就会出问题

GiantappMan commented 11 months ago

写代码的时候经常会问,参考这个代码

```参考代码```
leeyiding commented 11 months ago
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>test</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
      background-color: #f2f2f2;
    }
    button {
      padding: 10px 20px;
      font-size: 16px;
      background-color: #4CAF50;
      color: white;
      border: none;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    button:hover {
      background-color: #45a049;
    }
  </style>
</head>
<body>
  <button onclick="redirect()">跳转</button>
  <script>
    function redirect() {
      window.location.href = "https://baidu.com";
    }
  </script>
</body>
</html>

我也复现了一下,把这串html代码不加代码块,直接发送,会直接渲染

canisminor1990 commented 11 months ago

直接发不用代码块是会被解析的 因为加了remark对应的html解析能力 但代码块里面的不应该 实在不行只能把解析关了

arvinxx commented 11 months ago

直接发不用代码块是会被解析的 因为加了remark对应的html解析能力 但代码块里面的不应该 实在不行只能把解析关了

我存在稳定复现的情况:

异常被解析:

image

步骤:

  1. 找一个存在 shiki 高亮的代码块,等待其从未加载变成已加载;
  2. 切换到相应的 html 代码块

er

canisminor1990 commented 11 months ago

fixed