How to programmatically open Markdown preview?

Is there a programmatic API to automatically open a Markdown file in preview mode, that can be used by a VSCode extension running in Theia?

I’ve seen a similar question here, but don’t know how the answer given there would apply to a VSCode extension. I need something equivalent to VSCode’s markdown.showPreview command.

@t1m0thyj in your vscode extension, it should be possible to simply execute the markdown.showPreview command given that your application includes the vscode-builtin-markdown and vscode-builtin-markdown-language-features extension. You can re-use commands contributed by other extensions if needed.

For example, this custom extension I wrote uses the markdown.showPreview command to render a located at the root of the workspace.

1 Like