xqdoo00o / chatgpt-web

Pure Javascript ChatGPT demo based on OpenAI API
https://xqdoo00o.github.io/chatgpt-web/
MIT License
983 stars 369 forks source link

点击复制bug #32

Closed shellalumni closed 1 year ago

shellalumni commented 1 year ago

点击复制内容时候,会复制不完整。 比如gpt给了下面代码:

import re

def send_html(html):
    # 在所有的html标签中添加一个唯一的标记
    html = re.sub(r'<(/?[a-z]+)>', r'{{\1}}', html)
    # 分段处理html
    while len(html) > 2000:
        # 将前2000个字放入一段中
        text = html[:2000]
        # 如果该段的末尾有标签,则将该标签后的内容移动到下一段
        match = re.search(r'{{/?[a-z]+}}$', text)
        if match:
            last_tag = match.group()
            text = text[:match.start()]
            html = last_tag + html[2000:]
        else:
            html = html[2000:]
        # 发送该段
        send(text)
    # 发送剩余的内容
    send(html)

点击复制后会变成这个:


import re

def send_html(html):
    # 在所有的html标签中添加一个唯一的标记
    html = re.sub(r'<(/?[a-z]+)>', r'{{\1}}', html)
    # 分段处理html
    while len(html) > 2000:
        # 将前2000个字放入一段中
        text = html[:2000]
        # 如果该段的末尾有标签,则将该标签后的内容移动到下一段
        match = re.search(r'{{/?[a-z]+}}
, text)
        if match:
            last_tag = match.group()
            text = text[:match.start()]
            html = last_tag + html[2000:]
        else:
            html = html[2000:]
        # 发送该段
        send(text)
    # 发送剩余的内容
    send(html)

漏掉了 $'

xqdoo00o commented 1 year ago

这两天更新修复下

xqdoo00o commented 1 year ago

已修复