Repository navigation
Markdown rendering for .md files (in-house, zero dependencies) - #5
Merged
Merged
Conversation
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
Markdown rendering: .md and .markdown files open as a formatted preview with a source toggle, written in-house with no dependencies. CommonMark core plus GFM tables, task lists, strikethrough and autolinks; highlighted fenced code; repo-relative links, heading fragments and local images. Output is built with createElement/textContent only, raw HTML is shown as text, link schemes are allowlisted, remote images never load, and the parser is linear with hard limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Markdown files (
.md,.markdown, case-insensitive) open as a formatted preview instead of highlighted source. View source in the preview (or Preview in source) flips between the two, using the same button and position as the SVG toggle. A palette command, Toggle Markdown Preview, does the same.Why
Reading a README or a design doc as raw Markdown is slow. The constraint is that the product has zero runtime dependencies and treats repo content as untrusted, so the parser and renderer are written in this repo, and the output is built only with
createElementandtextContent.How the expert panel shaped it
Four panelists reviewed the design before planning. Full record: DESIGN.md §14.
asSourcetoggle; a line target (search hit,file:line, Go to line) forces source; Find in the preview switches to source; no outline or in-preview find in v1.innerHTML); raw HTML shown as text; onesafeHrefallowlist; relative images only through the authenticated raw endpoint as blob URLs; the CSP is not loosened.lexLinehighlighting with no file-wide state.markdown.ts(no DOM),mdrender.ts, andMarkdownViewmirroringCodeView;editor.tsandapp.tsexcluded from line coverage as in Round 4; a seeded fuzz test of the safety invariants.AC to commit
tab.codeguards)2fe4682feat(markdown): render Markdown files as a preview with a source togglec641ab8fix(markdown): leave the preview when a Markdown tab turns binary or a directoryba843e6feat(markdown): CommonMark block and inline core with hard limits43b6609feat(markdown): safe links, repo-relative navigation and heading fragments7b12127feat(markdown): GFM tables, task lists and strikethroughc8766c3feat(markdown): highlighted fenced code and visible hidden characters8dccd33feat(markdown): images, size gate, palette command and docs6640dc7fix(markdown): let the Preview toggle render a file over the size gateCommits are on this branch since
04780fb(release 1.4.0).How to test
on*orstyleattributes, noidwithout themd-prefix, no disallowedhreforsrcschemes).*, 100k[, 1 MB single line, and similar) must finish under a time bound, and doubling the input must not triple the time.src/client/app.tsandsrc/client/editor.tsare not measured, as in earlier rounds..mdfile, flip the toggle, edit the file on disk (scroll and mode should hold), click a relative link and a#headinglink, and open a file over 1 MiB.Assumptions
editor.tsandapp.tscannot load under the fake DOM and are excluded from coverage; their logic is kept thin.test/helpers/fakedom.tslive under the test path.serialize().imageMimetable.lexLineandlanguageForinhighlight.tsare reused unchanged.Known minors
R-01(review): a link to/api/files?xresolves as the repo pathapi/filesand shows as a repo link. Harmless: it only calls stat or the open callback.markdown.ts,mdimage.ts,mdrender.tsandmdview.tshave no test (listed inlast-check.json). Diff coverage is 99.1%, above the 80% floor.🤖 Generated with Claude Code