NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

[Bug] markdown 代码块里含 `$数字`时 的错误转义

Open falconchen opened this issue 1 year ago • 8 comments

Bug Description

当GPT回复的代码块中含有 $数字 时,比如 $0$1 , ChatGPT-Next-Web 会在其前面加上 \ ,如 \$0\$1

Steps to Reproduce

可以用这条提示语来检查它返回的结果:

写一个shell脚本,接受一个目录为参数,检查这个目录下是否有空目录,并打印结果,请使用中文回答。

或者看这条 ShareGPT的结果:https://sharegpt.com/c/qEjWO15

Expected Behavior

$数字 正确的转义,不需要添加 \

Screenshots

https://photo.cellmean.com/i/2024/04/18/rb0ulf-0.png

Deployment Method

  • [ ] Docker
  • [X] Vercel
  • [ ] Server

Desktop OS

MacOS

Desktop Browser

Chrome

Desktop Browser Version

124.0.6367.62

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

falconchen avatar Apr 18 '24 08:04 falconchen

Bot detected the issue body's language is not English, translate it automatically.


Title: [Bug] Error escaping when markdown code block contains $number

Issues-translate-bot avatar Apr 18 '24 08:04 Issues-translate-bot

日经了属于是,主线版本依旧没有修复?

daiaji avatar Apr 18 '24 09:04 daiaji

Bot detected the issue body's language is not English, translate it automatically.


Nikkei is yes, the mainline version is still not repaired?

Issues-translate-bot avatar Apr 18 '24 09:04 Issues-translate-bot

Unless the maintainers come up with a solution, I recommend you use my workaround I made in this fork: https://github.com/Algorithm5838/NextChat/tree/dollar-sign

You can try it here: https://nextchat-git-dollar-sign-algorithm5838s-projects.vercel.app/

Algorithm5838 avatar Apr 18 '24 10:04 Algorithm5838

Unless the maintainers come up with a solution, I recommend you use my workaround I made in this fork: https://github.com/Algorithm5838/NextChat/tree/dollar-sign

You can try it here: https://nextchat-git-dollar-sign-algorithm5838s-projects.vercel.app/

Thank you , I have tried this one in vercel , but it seems still not fixed ...🥶

falconchen avatar Apr 19 '24 03:04 falconchen

I see. I've discovered the reason why this happens. It occurs when the first set of triple backticks (```) is immediately followed by a word, such as 'bash' in this case. If you remove the 'bash' part, it should render correctly. I'll work on fixing this issue later.

Algorithm5838 avatar Apr 19 '24 03:04 Algorithm5838

This bug is complicated by the fact that the ReactMarkdown component, which was used in our project, does not support Latex syntax well. We've gone through several rounds of optimization with contributors in the community to solve this issue. However, unfortunately, the current solution does not cover all scenarios.We will continue to optimize as soon as possible to finally solve this problem

Dean-YZG avatar Apr 19 '24 05:04 Dean-YZG

This bug is complicated by the fact that the ReactMarkdown component, which was used in our project, does not support Latex syntax well. We've gone through several rounds of optimization with contributors in the community to solve this issue. However, unfortunately, the current solution does not cover all scenarios.We will continue to optimize as soon as possible to finally solve this problem

It seems there are issues not only with supporting Latex syntax but also with bash support, as this problem occurred in BASH.

Moreover, this component has other problems; for any URL, regardless of the language, it always returns <http://example.com>, which actually does not need the < > around it.

for example in this demo: https://shareg.pt/ze7RikV

Perhaps it might be worth considering switching to a different Markdown component library.

falconchen avatar May 12 '24 04:05 falconchen