问题
Is it possible for a VSCode extension to include HTML that are written to disk somewhere (doesn't matter where) when the extension is installed, so that I can then open that HTML from links?
E.g. I want a link to the offline documentation for a function in its tooltip.
回答1:
Yes, your extension can use the standard node apis to download the files. Then you can:
- Use the standard VS Code apis to open the file as a text document
Use the
markdown.showPreview
command to open the file as a html preview in VS Code:import * as vscode from 'vscode'; vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.parse('file:///Users/you/path/to/file.html'));
Use node apis to open the file in the user's standard web browser (again using the
file:
uri)
来源:https://stackoverflow.com/questions/51046906/visual-studio-code-extension-that-includes-offline-html