Visual Studio Code extension that includes offline HTML

杀马特。学长 韩版系。学妹 提交于 2019-12-11 07:59:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!