Development Guide - Rich Markdown Diff
April 10, 2026 ยท View on GitHub
This document is for developers who want to contribute to the extension or understand its internals.
Technical Architecture
src/extension.ts: Main entry point. Registers commands and the Custom Editor Provider.src/commandTarget.ts: Normalizes Explorer, editor, and SCM command payloads into a consistent comparison target and hint.src/gitDiffResolver.ts: Resolves Git-backed comparisons for working tree, staged, untracked, deleted, andHEAD-based Markdown diffs.src/markdownDiff.ts: Core logic for Markdown parsing (usingmarkdown-it) and diffing (usinghtmldiff-js).images/: Brand assets and screenshots.
Getting Started
- Clone the repository.
- Install dependencies:
pnpm install - Compile the code:
pnpm run compile - Run/Debug:
- Open this project in VS Code.
- Press
F5to launch an "Extension Development Host" instance.
Testing
- Unit Tests:
pnpm run test:unit(Tests the diff logic in isolation). - Integration Tests:
pnpm test(Runs tests within a VS Code instance). - Visual Regression Tests (VRT):
pnpm run test:visual:docker: Run VRT inside a Docker container (recommended for environment consistency).pnpm run test:visual:update: Update baseline screenshots (run this inside Docker).pnpm run test:visual: Run VRT locally (may have anti-aliasing differences compared to CI).
Important
To ensure consistency between local development and CI, always use the Docker-based commands for generating and verifying baseline screenshots.
Local VSIX Smoke Test
- Build a package with
pnpm run package. - Install the generated
.vsixinto a normal VS Code window. - Validate Source Control diffs for unstaged-only, staged-only, mixed staged/unstaged, untracked, and deleted Markdown changes.
- Validate that the editor title action only appears when the active Markdown file has a meaningful Git-backed diff.
- Validate that an already-open SCM diff retargets its labels and baseline correctly when the same file moves between unstaged and staged states.
- Validate rendered diffs for tables, Mermaid, KaTeX, alerts, clipboard comparison, and split/inline view toggling.
- Validate that KaTeX inline and block math renders with correct font metrics (not just raw symbols).
- Validate that the panel remains stable while staging, unstaging, and editing the same Markdown file.
- Validate that split view keeps both panes evenly sized during refreshes.
Quality Control
- Linting:
pnpm run lint(Checks for style and common errors using ESLint 9). - Auto-fix:
pnpm exec eslint src --fix. - Release baseline:
pnpm run compile,pnpm run test:unit,pnpm test, thenpnpm run package.
License
This project is licensed under the MIT License.