{"id":50126296,"url":"https://github.com/ztxtech/md2office","last_synced_at":"2026-05-23T20:04:03.285Z","repository":{"id":358911047,"uuid":"1243645702","full_name":"ztxtech/md2office","owner":"ztxtech","description":"一个面向 Office 粘贴体验的Markdown 富文本转换工具。 粘贴 Markdown 或拖入 `.md` 文件，点击按钮，把格式化后的 HTML 富文本复制到剪贴板。","archived":false,"fork":false,"pushed_at":"2026-05-19T14:47:56.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-19T17:52:30.047Z","etag":null,"topics":["markdown","office","power-point"],"latest_commit_sha":null,"homepage":"https://ztxtech.github.io/md2office/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ztxtech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-19T14:29:11.000Z","updated_at":"2026-05-19T15:03:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ztxtech/md2office","commit_stats":null,"previous_names":["ztxtech/md2office"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ztxtech/md2office","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztxtech%2Fmd2office","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztxtech%2Fmd2office/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztxtech%2Fmd2office/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztxtech%2Fmd2office/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ztxtech","download_url":"https://codeload.github.com/ztxtech/md2office/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztxtech%2Fmd2office/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33410353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T18:09:33.147Z","status":"ssl_error","status_checked_at":"2026-05-23T18:09:31.380Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown","office","power-point"],"created_at":"2026-05-23T20:03:54.079Z","updated_at":"2026-05-23T20:04:03.278Z","avatar_url":"https://github.com/ztxtech.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markdown to Office Pasteboard\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"GitHub Pages\" src=\"https://img.shields.io/badge/GitHub%20Pages-ready-222222?style=for-the-badge\u0026logo=githubpages\u0026logoColor=white\"\u003e\n  \u003cimg alt=\"Static HTML\" src=\"https://img.shields.io/badge/Static%20HTML-single%20file-E34F26?style=for-the-badge\u0026logo=html5\u0026logoColor=white\"\u003e\n  \u003cimg alt=\"No Build\" src=\"https://img.shields.io/badge/No%20Build-zero%20setup-00A67E?style=for-the-badge\u0026logo=githubactions\u0026logoColor=white\"\u003e\n  \u003cimg alt=\"Office\" src=\"https://img.shields.io/badge/Office-paste%20ready-2563EB?style=for-the-badge\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Markdown\" src=\"https://img.shields.io/badge/Markdown-GFM-111111?style=flat-square\u0026logo=markdown\u0026logoColor=white\"\u003e\n  \u003cimg alt=\"Tables\" src=\"https://img.shields.io/badge/Tables-supported-146C5F?style=flat-square\"\u003e\n  \u003cimg alt=\"MathJax\" src=\"https://img.shields.io/badge/Math-MathJax-1F4E79?style=flat-square\u0026logo=mathworks\u0026logoColor=white\"\u003e\n  \u003cimg alt=\"Marked\" src=\"https://img.shields.io/badge/Parser-marked-2F855A?style=flat-square\"\u003e\n  \u003cimg alt=\"DOMPurify\" src=\"https://img.shields.io/badge/Sanitize-DOMPurify-6B46C1?style=flat-square\"\u003e\n  \u003cimg alt=\"Clipboard\" src=\"https://img.shields.io/badge/Clipboard-rich%20HTML-F59E0B?style=flat-square\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  一个面向 Office 粘贴体验的 Markdown 富文本转换工具。\n  \u003cbr\u003e\n  粘贴 Markdown 或拖入 `.md` 文件，点击按钮，把格式化后的 HTML 富文本复制到剪贴板。\n\u003c/p\u003e\n\n---\n\n## 功能亮点\n\n- 支持直接粘贴 Markdown 文本。\n- 支持拖拽 `.md`、`.markdown`、`.txt` 文件。\n- 支持标题、段落、加粗、斜体、链接、引用、分隔线、列表、代码块。\n- 支持 GFM 风格表格，并为 Office 粘贴做了边框和单元格样式。\n- 支持行内公式 `$E=mc^2$` 和块级公式 `$$...$$`。\n- 公式默认通过 MathJax 转为 Presentation MathML，优先让 Word、PowerPoint 识别为 Office 公式。\n- 默认不复制纯文本，只把富文本作为主要粘贴内容；需要兜底文本时可手动勾选。\n\n## 快速使用\n\n直接打开：\n\n```text\nmd2office.html\n```\n\n或者用本地静态服务器打开，剪贴板权限会更稳定：\n\n```bash\npython3 -m http.server 8765\n```\n\n然后访问：\n\n```text\nhttp://localhost:8765/md2office.html\n```\n\n使用流程：\n\n1. 在左侧文本框粘贴 Markdown，或拖入 Markdown 文件。\n2. 检查右侧预览。\n3. 点击“复制到剪贴板”。\n4. 切到 Office，直接粘贴。\n\n## GitHub Pages 部署\n\n仓库已经配好 GitHub Actions 工作流：\n\n```text\n.github/workflows/pages.yml\n```\n\n推荐部署方式：\n\n1. 在 GitHub 创建一个新仓库。\n2. 把本项目文件推送到默认分支，例如 `main`。\n3. 打开仓库的 `Settings` -\u003e `Pages`。\n4. 在 `Build and deployment` 中选择 `GitHub Actions`。\n5. 推送到 `main` 后，工作流会自动部署。\n\n部署完成后，GitHub Actions 会在日志和部署摘要里显示站点 URL。\n\n## 文件结构\n\n```text\n.\n├── .github/\n│   └── workflows/\n│       └── pages.yml\n├── .gitignore\n├── .nojekyll\n├── README.md\n├── index.html\n└── md2office.html\n```\n\n## 转换策略\n\n这个工具复制的是 `text/html` 富文本剪贴板内容，并同时准备一个可选的 `text/plain` 兜底。\n\nOffice 对 HTML 粘贴的支持比对 Markdown 源码更好，所以工具会先把 Markdown 转成适合 Office 粘贴的 HTML：\n\n- Markdown 解析：`marked`\n- HTML 清理：`DOMPurify`\n- 公式渲染：`MathJax`\n- 粘贴格式：Clipboard API 的 `text/html`\n\n## 已知限制\n\n- 浏览器不能直接控制 Office 粘贴动作，所以需要手动切到 Office 后粘贴。\n- 公式会以标准 Presentation MathML 写入 HTML 剪贴板；Office 是否转成原生可编辑公式仍取决于具体版本和粘贴通道。\n- 如果网络无法访问 CDN，页面会退回到内置基础 Markdown 转换，复杂公式渲染会受影响。\n- 不同版本的 Office 对 HTML、SVG、表格边框的粘贴支持可能略有差异。\n\n## 开发\n\n这是纯静态项目，不需要安装依赖。\n\n本地预览：\n\n```bash\npython3 -m http.server 8765\n```\n\n静态检查可以用：\n\n```bash\nnode -e \"const fs=require('fs'); const html=fs.readFileSync('md2office.html','utf8'); for (const m of html.matchAll(/\u003cscript(?![^\u003e]*\\\\bsrc=)[^\u003e]*\u003e([\\\\s\\\\S]*?)\u003c\\\\/script\u003e/g)) new Function(m[1]); console.log('ok')\"\n```\n\n## 致谢\n\n- [marked](https://marked.js.org/)：Markdown 解析\n- [DOMPurify](https://github.com/cure53/DOMPurify)：HTML 清理\n- [MathJax](https://www.mathjax.org/)：公式渲染\n- [GitHub Pages](https://pages.github.com/)：静态站点托管\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztxtech%2Fmd2office","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fztxtech%2Fmd2office","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztxtech%2Fmd2office/lists"}