microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.68k stars 29.07k forks source link

Add run in terminal button to markdown viewer when a code block's language is a shell language #209876

Open Tyriar opened 6 months ago

mjbvz commented 6 months ago

We need to be very careful that we don't allow markdown previews to run shell scripts without user interaction or allow running script in a potentially confusing way. In untrusted workspaces we should either disable this entirely or at least get user confirmation with a preview of the script to be run

I suggest adding the button using a script that runs after the markdown has been rendered. You can add the script here:

https://github.com/microsoft/vscode/blob/8c363b460b5f6a1e2a153bac71ad7c581929011f/extensions/markdown-language-features/package.json#L743

Checkout https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/markdownPreview/index.ts for a more complete example of a script that runs on init and after updates to the md preview