Paste Markdown
A powerful VS Code extension that automatically converts HTML content to Markdown format when pasting into markdown files. Supports both desktop and web versions of VS Code.
✨ Features
📝 HTML to Markdown Conversion
Automatically converts HTML content to properly formatted Markdown when pasting into .md
files.
Example:
<h1>Hello World</h1>
<p>This is a <strong>test</strong> paragraph with a <a href="https://example.com">link</a>.</p>
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
Converts to:
# Hello World
This is a **test** paragraph with a [link](https://example.com).
- First item
- Second item
🖼️ Image Paste Support
Smart image handling with multiple fallback options:
- File Copy: Automatically copies image files to your workspace and creates relative path references
- Base64 Encoding: Falls back to base64 encoding when file operations aren't available
- URI References: Supports pasting images from file URIs
📊 Advanced HTML Elements Support
Tables
Converts HTML tables to GitHub Flavored Markdown tables:
<table>
<tr><th>Name</th><th>Age</th></tr>
<tr><td>John</td><td>25</td></tr>
</table>
| Name | Age |
| --- | --- |
| John | 25 |
Code Blocks
Preserves syntax highlighting information:
<div class="highlight-source-javascript">
<pre>console.log('Hello World');</pre>
</div>
```javascript
console.log('Hello World');
#### Task Lists
Converts HTML checkboxes to GitHub-style task lists:
```html
<li><input type="checkbox" checked> Completed task</li>
<li><input type="checkbox"> Pending task</li>
- [x] Completed task
- [ ] Pending task
Text Formatting
- Bold:
<strong>
→ **text**
- Italic:
<em>
→ *text*
- Strikethrough:
<del>
, <s>
, <strike>
→ ~text~
- Links:
<a href="url">text</a>
→ [text](https://github.com/wolfsilver/paste-markdown/blob/HEAD/url)
- Headings:
<h1>
to <h6>
→ #
to ######
🚀 Installation
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X
/ Cmd+Shift+X
)
- Search for "Paste Markdown"
- Click Install
📖 Usage
- Open any
.md
file in VS Code
- Copy HTML content from any source (web pages, emails, documents, etc.)
- Paste (
Ctrl+V
/ Cmd+V
) in your markdown file
- The extension will automatically convert HTML to Markdown format
Smart Detection
The extension intelligently detects:
- Whether the clipboard contains HTML content that should be converted
- If the pasted content is already in Markdown format (skips conversion)
- Image data and handles it appropriately
🌐 Web Support
This extension works in both desktop and web versions of VS Code (including vscode.dev):
- Desktop: Full functionality including file operations
- Web: Core conversion features with base64 image fallback
⚙️ Configuration
The extension works out of the box with sensible defaults:
- Uses ATX-style headings (
# Heading
)
- Fenced code blocks with ```
- Unordered lists with
-
bullets
- Horizontal rules with
---
🛠️ Development
Building from Source
# Clone the repository
git clone https://github.com/wolfsilver/paste-markdown.git
cd paste-markdown
# Install dependencies
npm install
# Build for desktop
npm run compile
# Build for web
npm run compile:web
# Watch mode for development
npm run watch # Desktop
npm run watch:web # Web
Architecture
- Core Engine: Uses Turndown for robust HTML to Markdown conversion
- Custom Rules: Extended with specialized rules for code blocks, tables, task lists, and strikethrough
- Image Handling: Smart file path generation and workspace-aware relative paths
- Cross-Platform: Works in both Node.js (desktop) and browser (web) environments
📄 License
MIT License - see LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
🐛 Issues
Found a bug or have a feature request? Please open an issue on GitHub.
Enjoy seamless HTML to Markdown conversion! 🎉