GitHub 使用 Markdown 方言,稱為 GitHub 風格的 Markdown (GFM). It’s mostly standard Markdown with a few extras — fenced code blocks with syntax highlighting, task lists, tables, and automatic link detection. If you’re converting a Word document into a GitHub README or wiki page, here’s what you need to know.
什麼是 GitHub 風格的 Markdown?
GFM 是 GitHub 對 CommonMark 的擴充套件。從 Word 轉換時最重要的新增內容是:
- 防護程式碼塊 帶有語言識別符號(
```python) - 表格 使用管道語法
- 任務列表 using
- [ ]and- [x] - 刪除線 using
~~text~~ - 自動連結 — 裸露 URL 變得可點選
將您的 Word 文件轉換為 WordToMD ,預設情況下您將獲得 GFM 相容的輸出。
Word樣式 → GFM 元素
| 詞元素 | GFM 輸出 |
|---|---|
| 標題 1 | # H1 |
| 標題 2 | ## H2 |
| 粗體 | **bold** |
| 斜體 | *italic* |
| 表 | 管道表 |
| 專案符號列表 | - item |
| 編號列表 | 1. item |
| 超連結 | [text](url) |
| 等寬字型 | `code` |
| 刪除線 | ~~text~~ |
轉換後新增的 GitHub 特定功能
任務列表
Word 沒有本機任務列表元素。如果您的 Word 文件中有核取方塊,它們會轉換為純文本。轉換後,將它們格式化為 GFM 任務列表:
- [x] Completed item
- [ ] Pending item
- [ ] Another pending item
這些在 GitHub 問題、拉取請求和專案自述檔案中呈現為互動式核取方塊。
具有語法突出顯示的防護程式碼塊
Word 中的等寬字型文本轉換為內聯程式碼。對於 GitHub 上的多行程式碼塊,請使用帶有語言識別符號的隔離語法:
```javascript
function greet(name) {
return `Hello, ${name}!`;
}
GitHub supports dozens of languages. See [Markdown Code Blocks Guide](/blog/markdown-code-blocks-guide) for the full language list and syntax rules.
### Alerts (GitHub-Specific Callouts)
GitHub renders special blockquote syntax as colored callout boxes:
```markdown
> [!NOTE]
> This is a note callout.
> [!WARNING]
> This is a warning.
> [!TIP]
> This is a helpful tip.
如果您的 Word 文件有標註框或突出顯示的註釋,請在初始轉換後將它們轉換為此 GFM 警報語法。
從 Word 文件構建自述檔案
典型的軟體自述檔案遵循以下結構:
# Project Name
Short description.
## Installation
## Usage
## Configuration
## Contributing
## License
如果您的 Word 文件是專案規範或文件草稿,請將其部分對映到這些自述檔案標題。使用 WordToMD 轉換原始內容,然後重新組織並新增 GitHub 特定的元素。
GitHub Markdown 中的表格
字表直接轉換為 GFM 管道表。轉換後的表如下所示:
| Feature | Status | Notes |
|---|---|---|
| Authentication | ✅ Done | JWT-based |
| File upload | 🚧 In progress | S3 target |
| API docs | ❌ Pending | — |
GitHub 還支援列對齊:
| Left | Center | Right |
|:---|:---:|---:|
| text | text | text |
有關 Markdown 表格的所有內容,請參閱 Markdown 表:完整指南.
GitHub 儲存庫中的影像
GitHub 從儲存庫中的相對路徑渲染影像:

如果 Word 文件包含受支援的圖片,請下載 Markdown + 影像 ZIP,將打包好的映象檔案移入 docs/images/,如果您的儲存庫使用不同的資料夾結構,請更新相對路徑。
對於 GitHub.com 託管的影像,您還可以使用絕對 URL: H1

GitHub 維基頁面
GitHub wiki 支援完整的 GFM 規範。轉換工作流程與自述檔案相同:
- 轉換您的 Word 文件 WordToMD
- 新增 GFM 特定格式(任務列表、程式碼圍欄、警報)
- 建立一個新的 wiki 頁面並貼上 Markdown
標題 ID 和錨鏈接
GitHub 從標題文本自動生成錨點 ID。標題 ## Installation 獲取 ID #installation. You can link to it from elsewhere in the same document:
See the [Installation section](#installation) below.
這對於帶有目錄的長自述檔案非常有用。轉換後,在頂部新增TOC:
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
FAQ
GitHub 是否在 Markdown 中呈現 HTML? GitHub 允許在 Markdown 中使用一些 HTML 標籤,但會去除大多數樣式屬性。堅持使用 Markdown 語法以獲得最佳結果。
我的表格列太多,在移動裝置上看起來很擁擠。我應該怎麼辦?
考慮將大表分成更小的集中表,或使用 HTML <details> 可摺疊部分的標籤。
我可以使用 Word 編寫 GitHub Issues 嗎? 是的!將您的 Word 文件轉換為 Markdown WordToMD 並將輸出直接貼上到 GitHub 問題或拉取請求描述中。
如何將整個 Word 文件集轉換為 GitHub wiki? 單獨轉換每個 Word 檔案併為每個文件建立一個 wiki 頁面。參見 批次將 Word 轉換為 Markdown 使用 Pandoc 編寫指令碼。
結論
將 Word 轉換為 GitHub Markdown 很簡單——使用 WordToMD 獲取基礎 Markdown,然後疊加 GFM 特定的功能,如任務列表、程式碼圍欄和標註警報。如果您的 Word 文件結構清晰(內建標題樣式、正確的表格),轉換輸出幾乎就可以推送到 GitHub。