Markdown Diff for AI is a VS Code extension designed to visually compare the changes between two Markdown files in a fully rendered HTML state. It helps you quickly and intuitively grasp the differences in document structure, paragraphs, code blocks, and images, making it especially effective for reviewing revisions generated by AI or collaborative editing.
Features
UI Optimized for AI Agent Revisions: When AI agents autonomously update markdown files, frequent and tedious diff checking is required. This tool provides a highly optimized UI that intelligently compares changes at the block level (paragraphs, lists, code blocks, etc.) rather than generating noisy, raw line-by-line diffs, allowing humans to intuitively grasp the AI's intent.
Rich Webview Rendering: Displays the diff as fully rendered HTML within VS Code. Added text is highlighted in green, and removed text in red with a strikethrough.
🚀 [NEW] Powerful Git Integration:
Simply right-click a file in the explorer and select "Git: Compare with HEAD..." or "Compare with Previous Change..." to instantly preview diffs against Git history.
Select Commits or Branches: Use the interactive QuickPick menu to seamlessly select specific past commits or local branches to compare your current file against.
Fine-grained Diff: Major changes are displayed as block replacements, while minor tweaks are highlighted word-by-word. Code blocks are compared line-by-line.
Image Content Comparison: Automatically calculates the hash of local image files. If an image is modified (even if the file path remains the same), it is accurately detected and displayed with a top-and-bottom split comparison layout.
Auto-Pairing: When you select one file (After or Before), the extension can infer and automatically select the corresponding file based on relative directory paths.
Auto-Diff: The comparison starts automatically as soon as both "After" and "Before" files are selected.
Clear Selection: Reset your file selections and UI state instantly with the "Clear" button.
Sensitivity Adjustment: Adjust the sensitivity of the diff engine in real-time.
Multilingual Support: Supports natural word segmentation for multi-language text including Japanese and English. UI is localized for both English and Japanese based on your VS Code settings.
Context Persistence: The extension preserves the diff view state even when you switch to other tabs.
HTML Sanitization: Prevents execution of arbitrary code within Markdown for security.
Usage
Open the VS Code Explorer.
Right-click the modified Markdown file and select "Select as After".
Right-click the original Markdown file and select "Select as Before".
The Webview panel will automatically open and display the rendered diff.
You can also trigger these actions from the Command Palette (Markdown Diff for AI: Select as After / Markdown Diff for AI: Select as Before).
If necessary, adjust the Sensitivity slider at the top to change the sensitivity used by the diff calculation.
Sensitivity
Sensitivity adjusts the sensitivity used by the diff calculation. It can be set from 0.0 to 1.0 in increments of 0.1 and adjusted according to the Markdown content or comparison purpose.
Extension Settings
This extension contributes the following settings:
markdownDiffForAi.defaultSensitivity: The default sensitivity value applied when a new comparison panel is opened. Accepts a number between 0 and 1. (Default: 0.7).
Note: Changing the sensitivity slider in the Webview panel only affects the current session and does not overwrite this global defaultSensitivity setting.
License
This project is licensed under the MIT License - see the LICENSE file for details.