Markdown Cheat Sheet

Markdown has a small syntax, yet a few details always slip: how table alignment works, how to get a code block highlighted, what goes inside a task-list bracket. This page tabulates the core syntax and the GitHub extensions separately for quick lookup.

Core Syntax

ElementSyntaxNote
Heading# H1 … ###### H6Six levels; a space follows the hashes
Bold**粗体**Bold text
Italic*斜体*Italic text
Bold italic***两者***Both bold and italic
Strikethrough~~删除线~~Struck-through text
Bullet list- 项目Bulleted list; nest by indenting
Numbered list1. 项目Auto-numbered list
Blockquote> 引用A block with a left bar
Inline code`code`Monospaced inline snippet
Code block```语言Fenced block with language hint
Link[文字](url)A clickable hyperlink
Image![说明](url)An embedded image
Horizontal rule---A horizontal divider

GitHub-Flavoured Extensions

FeatureSyntaxNote
Table| 列 A | 列 B | | --- | --- | | 1 | 2 |The delimiter row controls alignment
Task list- [x] 已完成 - [ ] 未完成An x inside the brackets marks it done
Autolinkhttps://example.comA bare URL becomes a link automatically
Left align| :--- |A colon on the left of the delimiter row
Centre align| :---: |Colons on both sides
Right align| ---: |A colon on the right

Frequently Asked Questions

What is the difference between Markdown and a rich-text editor?

The core difference is readability and control. Markdown is plain text with lightweight markup: it reads fine unrendered, opens in any editor, and suits version control naturally — Git shows a clean diff for every change, whereas rich text in binary or complex formats is nearly impossible to review. The cost is limited layout freedom; intricate text-and-image arrangements are out of reach. Rich text is WYSIWYG and powerful for layout, but content and styling are coupled, making migration and collaboration expensive. Markdown suits technical documentation, READMEs and blog drafts; rich text suits marketing pages and heavily designed material.

How do I control column alignment in a Markdown table?

Alignment is set by the delimiter row beneath the header. The default is left aligned; writing :--- left aligns explicitly; colons on both sides, :---:, centre the column; a colon on the right, ---:, right aligns it. The colon position maps directly onto the column, which makes it easy to remember. Two constraints: the delimiter row needs at least one hyphen, and its column count must match the header, otherwise the table is not recognised.

How do I get syntax highlighting in a code block?

Wrap the code in three backticks and put the language identifier immediately after the opening fence, such as ```python or ```javascript. That identifier tells the renderer which grammar to colour; omit or misspell it and you get a plain monospaced block. If the code itself contains backticks, use a longer fence — four backticks can safely wrap content containing three. For a single word or short expression, use a single pair of backticks for inline code instead.

Can Markdown be exported directly to PDF or Word?

Markdown is only a text format and has no export capability of its own, so a toolchain is required. The most common route converts to HTML and then prints or renders to PDF, which static site generators, editor plugins and command-line tools all handle; converting to Word usually means going through HTML or DOCX as an intermediate. The main difference is styling: default conversions look plain, and a good-looking PDF needs custom CSS. If the deliverable must be a beautifully typeset PDF, a layout tool may be less work than starting from Markdown.