包含脱机 HTML 的 Visual Studio Code 扩展 [英] Visual Studio Code extension that includes offline HTML

查看:37
本文介绍了包含脱机 HTML 的 Visual Studio Code 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VSCode 扩展是否有可能包含在安装扩展时写入磁盘某处(与何处无关)的 HTML,以便我可以从链接打开该 HTML?

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.

推荐答案

是的,您的扩展程序可以使用标准节点 API 下载文件.然后你可以:

Yes, your extension can use the standard node apis to download the files. Then you can:

  • 使用标准的 VS Code apis 将文件作为文本文档打开
  • 使用 markdown.showPreview 命令在 VS Code 中打开文件作为 html 预览:

  • 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'));

  • 使用 node apis 在用户的标准 Web 浏览器中打开文件(再次使用 file: uri)

    这篇关于包含脱机 HTML 的 Visual Studio Code 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆