vscode-webview-ui-toolkit icon indicating copy to clipboard operation
vscode-webview-ui-toolkit copied to clipboard

feat: syntax highlighting component

Open mattrothenberg opened this issue 3 years ago • 2 comments

Feature/component description

It'd be awesome if there were a syntax highlighting component that users could put in their web view. We (GitHub Next) have already run into a few cases where we've needed this functionality, and ultimately hand-rolled it with https://highlightjs.org/. This works but it's a pretty heavyweight solution. It was also difficult to match the user's VSCode syntax highlighting theme perfectly.

<vscode-syntax-highlight lang="js">
  const foo = 'bar';
</vscode-syntax-highlight>

Use case

In our case, we have one particular web view that displays the user's currently selected text (from VSCode). We take that text, pass it through Highlight.js, and render it out with a React component. This works fine, but again isn't ideal. And our web view bundle size suffers dramatically with the inclusion of Highlight.js

Ideally, VSCode could pass to the web view (assuming there's an API for this) information about the current syntax highlighting theme, such that we could apply those colors/tokens to the code snippet that is being stuck inside of the component.

Let me know what you think!

mattrothenberg avatar Jan 13 '22 22:01 mattrothenberg

+1, not sure https://github.com/shikijs/shiki is a good solution here.

Symbolk avatar Nov 09 '22 00:11 Symbolk

This would be really useful to us to us too!

charisk avatar Mar 01 '23 11:03 charisk