Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从chat.openai.com复制的代码会带上不必要的语言类型和复制按钮文字 #2

Closed
TonyYanOnFire opened this issue Mar 15, 2023 · 2 comments

Comments

@TonyYanOnFire
Copy link

从chat.openai.com复制的代码会带上这些不必要的内容

javascript
Copy code
...

原因应该是因为这些内容放到了pre标签下. 可以考虑增加域名的判断做特殊处理.

@icelam
Copy link
Owner

icelam commented Mar 15, 2023

Try right-clicking on the code itself instead of the header of the code block. OpenAI has a nested <pre> and <code> in their code block UI, illustrated below:

Screen.Recording.2023-03-15.at.7.16.20.PM.mov

Illustration

Since the <pre> tag is usually used for preformatted text according to HTML Living Standard, it's more reasonable to assume that the content wrapped inside is a code fragment - however, I'm working on a feature suggestion in issue #1 which may allow users to filter out unnecessary content.

@TonyYanOnFire
Copy link
Author

确实, 复制的结果和鼠标点击位置有关, 在代码元素之外点击实际上触发的是pre元素的事件, 因此带上了header的内容. 我们可以在code元素上增加outline样式再观察, 如下图. 只有在outline包裹的地方进行复制, 结果才符合预期

image

看起来这个问题可以通过改变使用方式来解决, 插件本身无需改动.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants