-
Notifications
You must be signed in to change notification settings - Fork 36k
Improve Katex copy robustness #274194
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
Improve Katex copy robustness #274194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the KaTeX math rendering to use a custom wrapper element (vscode-katex-container) with a data-latex attribute instead of relying on KaTeX's MathML annotation elements for extracting the original LaTeX source.
Key changes:
- Wraps KaTeX-rendered HTML in a
<span class="vscode-katex-container" data-latex="...">element with the escaped LaTeX source - Updates copy and context menu detection logic to use the new wrapper element
- Adds
data-latexto the allowed sanitizer attributes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/markdown/common/markedKatexExtension.ts |
Wraps KaTeX output in custom container with data-latex attribute; adds HTML attribute escaping function |
src/vs/workbench/contrib/markdown/browser/markedKatexSupport.ts |
Adds data-latex to allowed sanitizer attributes |
src/vs/workbench/contrib/chat/browser/chatWidget.ts |
Updates KaTeX element detection from .katex to .vscode-katex-container |
src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.ts |
Updates KaTeX element selection and LaTeX extraction to use data-latex attribute instead of annotation element |
src/vs/workbench/contrib/markdown/common/markedKatexExtension.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/markdown/common/markedKatexExtension.ts
Outdated
Show resolved
Hide resolved
2f3ec6b to
c6b44f8
Compare
f7a32be to
f27da37
Compare
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
Follow up for #271590 (comment)