@@ -553,6 +553,8 @@ or removing a command fails until the table changes in the same commit.
553553| ` markdown.render ` | Renders and sanitizes shared Markdown |
554554| ` markdown.outline ` | Outlines the headings of shared Markdown as a document-symbol tree |
555555| ` markdown.resolveReference ` | Decides what a link or an image of a rendered Markdown document points at |
556+ | ` htmlPreview.site ` | Names the folder an HTML file is previewed from and the file's address in it |
557+ | ` htmlPreview.resolveRequest ` | Decides what one request of an HTML preview serves |
556558| ` keymap.parseContext ` | Compile a bounded boolean shortcut context (from ` lithe-core-rules ` ) |
557559| ` keymap.evaluateContext ` | Evaluate a precompiled shortcut context (from ` lithe-core-rules ` ) |
558560| ` keymap.analyzeConflicts ` | Find conflicts among the final layered shortcut bindings (from ` lithe-core-rules ` ) |
@@ -5596,6 +5598,61 @@ the preview's.
55965598
55975599Shared examples: ` rust/fixtures/editor/markdown-outline-v1.json ` .
55985600
5601+ ## HTML file preview
5602+
5603+ An HTML file is previewed as a static site, so a page loads its stylesheets,
5604+ scripts, images, fonts, media and neighbouring pages the way a static web server
5605+ would serve them. Both commands accept:
5606+
5607+ ``` json
5608+ {
5609+ "documentPath" : " /workspace/site/index.html" ,
5610+ "workspaceRoot" : " /workspace"
5611+ }
5612+ ```
5613+
5614+ ` workspaceRoot ` is optional and sets the site's root exactly as it sets the
5615+ scope of ` markdown.resolveReference ` : the workspace for a document inside it,
5616+ otherwise the document's folder. ` htmlPreview.site ` returns
5617+ ` { "root": "/workspace", "address": "site/index.html", "mime": "text/html; charset=utf-8" } ` ;
5618+ ` address ` is the document's path from the root with each segment
5619+ percent-encoded, which the frontend appends to the address it serves the site
5620+ from, and ` mime ` is the content type the document is served as, by its
5621+ extension like the site's other files. A ` documentPath ` that is not absolute is
5622+ ` invalid_request ` .
5623+
5624+ ` htmlPreview.resolveRequest ` adds ` "path" ` , the requested path from the root as
5625+ the web engine reports it: percent-decoded, ` / ` -separated, without query or
5626+ fragment, and empty for the root. Core does not decode it again. The response is
5627+ tagged by ` kind ` :
5628+
5629+ | kind | fields | the frontend serves |
5630+ | --- | --- | --- |
5631+ | ` document ` | — | The editor's text of the document as the site's ` mime ` , so unsaved edits show |
5632+ | ` file ` | ` path ` , ` mime ` | The canonical file ` path ` , read without following another link, as ` mime ` |
5633+ | ` directory ` | — | A page that sends the browser on to the folder's ` index.html ` |
5634+ | ` denied ` | — | HTTP 403 |
5635+ | ` none ` | — | HTTP 404 |
5636+
5637+ The path resolves lexically from the root and must stay inside it before and
5638+ after Core resolves symbolic links; a segment holding ` \ ` , ` : ` or NUL is
5639+ ` none ` . A path that reaches the document, under any name, is ` document ` . A
5640+ hidden name (one starting with ` . ` ) is ` denied ` , except the leading folders the
5641+ document's own folder shares, so a page inside ` .github/pages ` can load its
5642+ neighbours but not ` .git/config ` . A file with a key or certificate extension
5643+ (` jks ` , ` key ` , ` keystore ` , ` p12 ` , ` pem ` , ` pfx ` ) is ` denied ` . Otherwise an
5644+ existing regular file is ` file ` , a folder whose ` index.html ` is a regular file
5645+ inside the root is ` directory ` , and anything else is ` none ` . ` mime ` comes from
5646+ the file's extension, with text types in UTF-8 and
5647+ ` application/octet-stream ` for an unknown one.
5648+
5649+ The page runs the document's scripts, so frontends trust nothing it requests:
5650+ they serve only what this command answers, never write through the site, and
5651+ handle top-level navigation away from it with the link policy of
5652+ ` markdown.resolveReference ` .
5653+
5654+ Shared examples: ` rust/fixtures/editor/html-preview-v1.json ` .
5655+
55995656### Structured logging of recoverable LSP maintenance warnings
56005657
56015658` lsp.pollEvents ` log observations may carry the existing ` error ` object even at
0 commit comments