Repository navigation
IDE: Markdown preview to the side (#179) - #239
Merged
Merged
Conversation
Ctrl/Cmd+K V renders the active Markdown file in a pane beside the editor groups: live while typing, scroll-synced, theme colours, code blocks coloured by Monaco. Sanitised with DOMPurify; folder images inlined by the main process (raster only), remote images become links, relative links open files, only http(s)/mailto leave the IDE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #179 (epic #163).
What
Open Preview to the Side (
Ctrl/Cmd+K V, also in the tab menu of a Markdown file) opens a pane to the right of the editor groups that renders the active Markdown file. It supports GitHub-flavoured Markdown: headings, lists, task lists, tables, images, and code blocks coloured by Monaco's tokenizer.Safety
The preview is the only place in the renderer that inserts parsed markup, so it is fenced in several ways:
<script>,<style>, thestyleattribute, forms and frames, and prefixes document ids (SANITIZE_NAMED_PROPS). The config is passed on every call, because DOMPurify ignores per-call options oncesetConfighas been used. Task-list checkboxes are kept, disabled.workspace.readImage. It is checked against the folder, limited to raster formats (no SVG) and 8 MB, and inlined as adata:URL.#headinglink scrolls the preview, and a relative link opens the file in the IDE. Only http, https and mailto links leave the IDE, through the newworkspace.openExternalLink, whose scheme the main process checks. Nothing navigates the window.New dependencies for the IDE workspace:
marked14.0.0 anddompurify3.4.15. Both were already in the lock file as Monaco's dependencies, so the lock only gains the workspace entries. Both are added toTHIRD_PARTY_NOTICES.md.Plugin: no change. VS Code previews Markdown natively.
Verified
npm testat the root passes: 1,286 extension tests and 616 IDE tests. The newmarkdown.test.tscovers block lines, reference links, link and image classification, slugs,readImage(folder only, no SVG) andisOpenableExternalLink.npm run ide:smokepasses.<script>,<img onerror>,<style>body{display:none}</style>and ajavascript:link. No flag was set and the page stayed visible.docs/api.md, and the preview followed it.One thing found during testing: an
<img>with an invalidsrcand anonerrorhandler makes Chromium report ascript-src-attrCSP violation while DOMPurify parses it in its inert document. Nothing executes. The CSP is the backstop it is meant to be.Not implemented: the preview is not part of the saved tab session.