Reputation: 357
I'm developing a Visual Studio Code extension and I would like to have some sort of Release Notes open up when the user uses a command.
I wrote the markdown file I would like to show
export const activate = (context: vscode.ExtensionContext) => {
vscode.commands.registerCommand('my.command', () => {
let uri = vscode.Uri.file(path.join(__dirname, '..', 'RELEASE_NOTES.md'))
vscode.window.showTextDocument(uri, {
viewColumn: 1,
preview: true
});
})
}
This opens up the .md file but I would like to have the formatted md file being shown.
How do I do this in vscode?
Thanks.
Upvotes: 0
Views: 748
Reputation: 65273
You can use markdown.showPreview
from VS Code's built-in markdown extension to open a normal md preview of the file:
vscode.commands.registerCommand('my.command', () => {
let uri = vscode.Uri.file(path.join(__dirname, '..', 'RELEASE_NOTES.md'))
vscode.commands.executeCommand('markdown.showPreview', uri)
})
Alternatively, use the same extension's markdown.api.render
command to pass in a string of md content and get back html that you can use in your own extension's webview
Upvotes: 1