Convert Markdown files, selections, or clipboard text into OneNote-optimized rich text (preserving syntax-highlighted code boxes, tables, local images, and inline math).
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Convert Markdown documents, editor selections, or clipboard text in VS Code into OneNote Desktop-optimized rich text (CF_HTML) with one click. Runs 100% locally and offline—no administrator privileges or external tools required. Menus, commands, and notifications automatically follow your VS Code display language (English and 简体中文).
Key Features
Boxed Syntax-Highlighted Code Blocks: Wraps fenced code blocks in a 1×1 light-gray table cell (solving OneNote's limitation of stripping <pre> backgrounds) with built-in highlight.js inline syntax highlighting and Consolas + Microsoft YaHei hybrid fonts.
Local Image Resolution & Auto-Scaling: Resolves relative image paths (e.g., image/xxx.png) and VS Code preview URLs into local file:/// URIs, proportionally scaling oversized images down to 760px (configurable via md2onenote.maxImageWidth).
Styled Tables & Blockquote Callouts: Renders clean borders, header shading, and zebra striping for Markdown tables; converts > blockquotes into light-blue callout boxes.
Inline Math & Task Lists: Formats common inline math expressions (such as $O(N)$, $B \ll N$, superscripts, and subscripts) and - [ ] / - [x] checkboxes, while preventing OneNote from tinting list bullets with inline code/bold styles.
Mermaid Diagrams as Images: Renders ```mermaid blocks to high-resolution PNG images (via mermaid-cli) and embeds them as pictures, matching VS Code's Markdown Preview. Uses your locally installed Edge or Chrome — no bundled browser. If rendering fails, the source block is preserved as a fallback.
Clean Paste Without Source Footer: Generates UTF-8 CF_HTML without SourceURL, so OneNote will not append From: file:///... at the bottom.
Usage
Editor Title Bar Button: Open any .md file and click the purple OneNote icon in the top-right editor toolbar.
Copy Selection or Full Document: Select any section in a .md editor (or leave unselected for the entire file) -> Right-click -> Copy to OneNote (Rich Text).
Keyboard Shortcut: Press Ctrl + Alt + C (Cmd + Alt + C on macOS) inside a .md editor.
Explorer Context Menu: Right-click any .md file in the Explorer sidebar -> Copy to OneNote (Rich Text).
Convert Clipboard Markdown: Open the Command Palette (Ctrl + Shift + P) and run Markdown -> OneNote: Convert Clipboard Markdown to Rich Text.
Then switch to OneNote and press Ctrl + V to paste.
Configuration
Setting
Default
Description
md2onenote.maxImageWidth
760
Maximum width (in pixels) for local images when pasting into OneNote. Larger images are scaled down proportionally.
Installation & Development
Install from Marketplace: Open the Extensions view (Ctrl + Shift + X), search for Markdown to OneNote (Rich Text), then click Install — or open the Marketplace page.
Install from VSIX: Download the latest .vsix from GitHub Releases, then open Extensions (Ctrl + Shift + X) -> ... -> Install from VSIX... and select the file.
Build & Package:
npm test # Run unit tests
npm run package # Bundle and package into .vsix
Automated Release (GitHub Actions): Push a version tag (e.g. git tag v1.0.7 && git push --tags) or trigger the Release VSIX workflow in GitHub Actions to automatically build the .vsix, attach it to a new GitHub Release, and publish to the VS Code Marketplace via Trusted Publishing (OIDC).
一键将 VS Code 中的 Markdown 文档、选中片段或剪贴板文本转换为专为 Windows 桌面版 OneNote 优化的富文本(CF_HTML)。纯本地离线转换,无需管理员权限,无需安装第三方外部工具。插件菜单、命令与提示信息自动跟随 VS Code 界面语言(支持 English 与 简体中文)。