Timmmm
Timmmm

Reputation: 96556

Visual Studio Code extension that includes offline 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.

Upvotes: 2

Views: 1168

Answers (1)

Matt Bierner
Matt Bierner

Reputation: 65223

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)

Upvotes: 2

Related Questions