md-to-html

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Markdown to HTML

Markdown 转 HTML

Converts markdown files to self-contained, styled HTML optimized for copying into Google Docs. Tables get proper borders, code blocks are styled, and images are embedded.
将Markdown文件转换为独立的、经过样式优化的HTML,便于复制到Google Docs中。表格会添加合适的边框,代码块会被设置样式,图片会被嵌入。

Usage

使用方法

Run the script via bunx:
bash
bunx ~/nixos-config/modules/programs/claude-code/skills/md-to-html/md-to-html.ts "<markdown-file>"
通过bunx运行脚本:
bash
bunx ~/nixos-config/modules/programs/claude-code/skills/md-to-html/md-to-html.ts "<markdown-file>"

What it does

功能说明

  1. Converts markdown to HTML via pandoc (uses
    nix run
    if not installed)
  2. Applies clean, modern CSS (system fonts, bordered tables, styled code blocks)
  3. Embeds all images as base64 (self-contained)
  4. Opens the result in the default browser
  5. User can then Cmd+A, Cmd+C, paste into Google Docs
  1. 通过pandoc将Markdown转换为HTML(若未安装则使用
    nix run
    作为备选)
  2. 应用简洁现代的CSS(系统字体、带边框表格、样式化代码块)
  3. 将所有图片以base64格式嵌入(独立文件,无需外部依赖)
  4. 在默认浏览器中打开结果
  5. 用户随后可使用Cmd+A、Cmd+C复制,粘贴到Google Docs中

Output

输出

  • Creates
    /tmp/<filename>.html
  • Opens in browser automatically
  • 生成
    /tmp/<filename>.html
    文件
  • 自动在浏览器中打开

CSS Features

CSS特性

  • System fonts (SF Pro, Segoe UI, etc.)
  • Tables: auto-width, 1px borders, grey headers
  • Code blocks: light grey background, rounded corners
  • Blockquotes: left border accent
  • Images: max-width 100%
  • Reasonable max-width container (900px)
  • 系统字体(SF Pro、Segoe UI等)
  • 表格:自动宽度、1px边框、灰色表头
  • 代码块:浅灰色背景、圆角
  • 引用块:左侧强调边框
  • 图片:最大宽度100%
  • 合理的容器最大宽度(900px)

Notes

注意事项

  • Requires pandoc (script will use
    nix run nixpkgs#pandoc
    as fallback)
  • Images in markdown must be accessible from the markdown file's directory
  • Best results when copying from Safari/Chrome to Google Docs
  • 需要pandoc(脚本会使用
    nix run nixpkgs#pandoc
    作为备选方案)
  • Markdown中的图片必须能从Markdown文件所在目录访问到
  • 从Safari/Chrome复制到Google Docs时效果最佳