markdown-documentation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkdown Documentation
Markdown 文档
Overview
概述
Master markdown syntax and best practices for creating well-formatted, readable documentation using standard Markdown and GitHub Flavored Markdown (GFM).
精通Markdown语法及最佳实践,使用标准Markdown和GitHub Flavored Markdown(GFM)创建格式规范、可读性强的文档。
When to Use
适用场景
- README files
- Documentation pages
- GitHub/GitLab wikis
- Blog posts
- Technical writing
- Project documentation
- Comment formatting
- README文件
- 文档页面
- GitHub/GitLab 维基
- 博客文章
- 技术写作
- 项目文档
- 注释格式化
Markdown Syntax Reference
Markdown语法参考
Headers
标题
markdown
undefinedmarkdown
undefinedH1 Header
H1 Header
H2 Header
H2 Header
H3 Header
H3 Header
H4 Header
H4 Header
H5 Header
H5 Header
H6 Header
H6 Header
Alternative H1
Alternative H2
undefinedAlternative H1
Alternative H2
undefinedText Formatting
文本格式化
markdown
**Bold text**
__Also bold__
*Italic text*
_Also italic_
***Bold and italic***
___Also bold and italic___
~~Strikethrough~~
`Inline code`
> Blockquote
> Multiple lines
> in blockquote
---
Horizontal rule (also ___ or ***)markdown
**Bold text**
__Also bold__
*Italic text*
_Also italic_
***Bold and italic***
___Also bold and italic___
~~Strikethrough~~
`Inline code`
> Blockquote
> Multiple lines
> in blockquote
---
Horizontal rule (also ___ or ***)Lists
列表
markdown
Unordered list:
- Item 1
- Item 2
- Nested item 2.1
- Nested item 2.2
- Item 3
Using asterisks:
* Item 1
* Item 2
Using plus:
+ Item 1
+ Item 2
Ordered list:
1. First item
2. Second item
1. Nested item 2.1
2. Nested item 2.2
3. Third item
Task list (GitHub Flavored Markdown):
- [x] Completed task
- [ ] Incomplete task
- [ ] Another taskmarkdown
Unordered list:
- Item 1
- Item 2
- Nested item 2.1
- Nested item 2.2
- Item 3
Using asterisks:
* Item 1
* Item 2
Using plus:
+ Item 1
+ Item 2
Ordered list:
1. First item
2. Second item
1. Nested item 2.1
2. Nested item 2.2
3. Third item
Task list (GitHub Flavored Markdown):
- [x] Completed task
- [ ] Incomplete task
- [ ] Another taskLinks and Images
链接与图片
markdown
[Link text](https://example.com)
[Link with title](https://example.com "Link title")
Reference-style link:
[Link text][reference]
[reference]: https://example.com
Automatic link:
<https://example.com>
<email@example.com>


Reference-style image:
![Alt text][image-ref]
[image-ref]: image.pngmarkdown
[Link text](https://example.com)
[Link with title](https://example.com "Link title")
Reference-style link:
[Link text][reference]
[reference]: https://example.com
Automatic link:
<https://example.com>
<email@example.com>


Reference-style image:
![Alt text][image-ref]
[image-ref]: image.pngCode Blocks
代码块
markdown
Inline code: `const x = 5;`
Code block with language:
```javascript
function hello(name) {
console.log(`Hello, ${name}!`);
}
```
```python
def hello(name):
print(f"Hello, {name}!")
```
```bash
npm install
npm start
```
Indented code block (4 spaces):
const x = 5;
console.log(x);markdown
Inline code: `const x = 5;`
Code block with language:
```javascript
function hello(name) {
console.log(`Hello, ${name}!`);
}
```
```python
def hello(name):
print(f"Hello, {name}!")
```
```bash
npm install
npm start
```
Indented code block (4 spaces):
const x = 5;
console.log(x);Tables
表格
markdown
Simple table:
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Aligned columns:
| Left | Center | Right |
|:-----|:------:|------:|
| Left | Center | Right |
| Text | Text | Text |
Minimal table:
Column 1 | Column 2
---------|----------
Data | Data
Data | Datamarkdown
Simple table:
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Aligned columns:
| Left | Center | Right |
|:-----|:------:|------:|
| Left | Center | Right |
| Text | Text | Text |
Minimal table:
Column 1 | Column 2
---------|----------
Data | Data
Data | DataExtended Syntax (GitHub Flavored Markdown)
扩展语法(GitHub Flavored Markdown)
markdown
Footnotes:
Here's a sentence with a footnote[^1].
[^1]: This is the footnote.
Definition list:
Term
: Definition
Emoji:
:smile: :rocket: :heart:
:+1: :-1: :eyes:
Automatic URL linking:
https://github.com
Task lists in issues:
- [x] #739
- [ ] https://github.com/octo-org/repo/issues/1
- [ ] Add tests
Mentioning users and teams:
@username
@org/team-name
Referencing issues and PRs:
#123
GH-123
username/repo#123markdown
Footnotes:
Here's a sentence with a footnote[^1].
[^1]: This is the footnote.
Definition list:
Term
: Definition
Emoji:
:smile: :rocket: :heart:
:+1: :-1: :eyes:
Automatic URL linking:
https://github.com
Task lists in issues:
- [x] #739
- [ ] https://github.com/octo-org/repo/issues/1
- [ ] Add tests
Mentioning users and teams:
@username
@org/team-name
Referencing issues and PRs:
#123
GH-123
username/repo#123README Template
README 模板
markdown
undefinedmarkdown
undefinedProject Name
Project Name
Table of Contents
Table of Contents
Features
Features
- Feature 1
- Feature 2
- Feature 3
- Feature 1
- Feature 2
- Feature 3
Demo
Demo

Try it live: https://demo.example.com

Try it live: https://demo.example.com
Installation
Installation
Prerequisites
Prerequisites
- Node.js 18+
- npm or yarn
- Node.js 18+
- npm or yarn
Install via npm
Install via npm
bash
npm install package-namebash
npm install package-nameInstall via yarn
Install via yarn
bash
yarn add package-namebash
yarn add package-nameFrom source
From source
bash
git clone https://github.com/user/repo.git
cd repo
npm install
npm run buildbash
git clone https://github.com/user/repo.git
cd repo
npm install
npm run buildUsage
Usage
Basic usage example:
javascript
import { Package } from 'package-name';
const instance = new Package({
option1: 'value1',
option2: 'value2'
});
instance.doSomething();Basic usage example:
javascript
import { Package } from 'package-name';
const instance = new Package({
option1: 'value1',
option2: 'value2'
});
instance.doSomething();Advanced Usage
Advanced Usage
More complex example:
javascript
const result = await instance.advancedMethod({
param1: 'value',
param2: 123
});
console.log(result);More complex example:
javascript
const result = await instance.advancedMethod({
param1: 'value',
param2: 123
});
console.log(result);API Reference
API Reference
Class.method(param1, param2)
Class.method(param1, param2)Class.method(param1, param2)
Class.method(param1, param2)Description of what this method does.
Parameters:
- (string): Description of param1
param1 - (number): Description of param2
param2
Returns: Description of return value
Example:
javascript
const result = instance.method('value', 42);Description of what this method does.
Parameters:
- (string): Description of param1
param1 - (number): Description of param2
param2
Returns: Description of return value
Example:
javascript
const result = instance.method('value', 42);Configuration
Configuration
Create a file:
.configrcjson
{
"setting1": "value1",
"setting2": true,
"setting3": {
"nested": "value"
}
}Create a file:
.configrcjson
{
"setting1": "value1",
"setting2": true,
"setting3": {
"nested": "value"
}
}Contributing
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch ()
git checkout -b feature/AmazingFeature - Commit your changes ()
git commit -m 'Add some AmazingFeature' - Push to the branch ()
git push origin feature/AmazingFeature - Open a Pull Request
Please read CONTRIBUTING.md for details on our code of conduct and development process.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch ()
git checkout -b feature/AmazingFeature - Commit your changes ()
git commit -m 'Add some AmazingFeature' - Push to the branch ()
git push origin feature/AmazingFeature - Open a Pull Request
Please read CONTRIBUTING.md for details on our code of conduct and development process.
Testing
Testing
bash
undefinedbash
undefinedRun all tests
Run all tests
npm test
npm test
Run with coverage
Run with coverage
npm run test:coverage
npm run test:coverage
Run in watch mode
Run in watch mode
npm run test:watch
undefinednpm run test:watch
undefinedDeployment
Deployment
bash
undefinedbash
undefinedBuild for production
Build for production
npm run build
npm run build
Deploy
Deploy
npm run deploy
undefinednpm run deploy
undefinedBuilt With
Built With
- Framework 1 - Description
- Library 2 - Description
- Tool 3 - Description
- Framework 1 - Description
- Library 2 - Description
- Tool 3 - Description
Versioning
Versioning
We use SemVer for versioning. For available versions, see the tags on this repository.
We use SemVer for versioning. For available versions, see the tags on this repository.
Authors
Authors
- Your Name - Initial work - YourUsername
See also the list of contributors who participated in this project.
- Your Name - Initial work - YourUsername
See also the list of contributors who participated in this project.
License
License
This project is licensed under the MIT License - see the LICENSE file for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- References
- Hat tip to anyone whose code was used
- Inspiration
- References
Support
Support
- Documentation: https://docs.example.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@example.com
- Documentation: https://docs.example.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@example.com
Roadmap
Roadmap
- Feature 1
- Feature 2
- Feature 3
- Feature 4
See the open issues for a full list of proposed features.
- Feature 1
- Feature 2
- Feature 3
- Feature 4
See the open issues for a full list of proposed features.
FAQ
FAQ
Question 1?
Question 1?
Answer to question 1.
Answer to question 1.
Question 2?
Question 2?
Answer to question 2.
Answer to question 2.
Changelog
Changelog
See CHANGELOG.md for a list of changes.
undefinedSee CHANGELOG.md for a list of changes.
undefinedDocumentation Best Practices
文档写作最佳实践
File Structure
文件结构
docs/
├── README.md
├── CONTRIBUTING.md
├── CHANGELOG.md
├── LICENSE
├── CODE_OF_CONDUCT.md
├── SECURITY.md
├── guides/
│ ├── getting-started.md
│ ├── installation.md
│ └── configuration.md
├── api/
│ ├── authentication.md
│ ├── endpoints.md
│ └── errors.md
└── examples/
├── basic-usage.md
└── advanced-usage.mddocs/
├── README.md
├── CONTRIBUTING.md
├── CHANGELOG.md
├── LICENSE
├── CODE_OF_CONDUCT.md
├── SECURITY.md
├── guides/
│ ├── getting-started.md
│ ├── installation.md
│ └── configuration.md
├── api/
│ ├── authentication.md
│ ├── endpoints.md
│ └── errors.md
└── examples/
├── basic-usage.md
└── advanced-usage.mdLinking Between Documents
文档间链接
markdown
Link to another doc:
[Installation Guide](guides/installation.md)
Link to section in current doc:
[See Configuration](#configuration)
Link to section in another doc:
[API Authentication](api/authentication.md#oauth2)
Link to external resource:
[GitHub Markdown Guide](https://guides.github.com/features/mastering-markdown/)markdown
Link to another doc:
[Installation Guide](guides/installation.md)
Link to section in current doc:
[See Configuration](#configuration)
Link to section in another doc:
[API Authentication](api/authentication.md#oauth2)
Link to external resource:
[GitHub Markdown Guide](https://guides.github.com/features/mastering-markdown/)Using Anchors
使用锚点
markdown
Create custom anchors:
<a name="custom-anchor"></a>markdown
Create custom anchors:
<a name="custom-anchor"></a>Section Title
Section Title
Link to it:
Jump to section
undefinedLink to it:
Jump to section
undefinedCollapsible Sections
可折叠区块
markdown
<details>
<summary>Click to expand</summary>
Hidden content goes here.
- Can include lists
- Code blocks
- Images
```javascript
const code = 'works too';markdown
<details>
<summary>Click to expand</summary>
Hidden content goes here.
- Can include lists
- Code blocks
- Images
```javascript
const code = 'works too';Syntax Highlighting
语法高亮
markdown
Common languages:
```javascript
```typescript
```python
```bash
```java
```go
```rust
```sql
```json
```yaml
```html
```css
```dockerfile
```graphql
```markdownmarkdown
Common languages:
```javascript
```typescript
```python
```bash
```java
```go
```rust
```sql
```json
```yaml
```html
```css
```dockerfile
```graphql
```markdownBadges
徽章
markdown





markdown





Alerts and Callouts
提示与注意事项
markdown
> **Note**
> This is a note
> **Warning**
> This is a warning
> **Important**
> This is important information
GitHub-style alerts (GFM):
> [!NOTE]
> Useful information
> [!TIP]
> Helpful advice
> [!IMPORTANT]
> Key information
> [!WARNING]
> Critical content
> [!CAUTION]
> Negative potential consequencesmarkdown
> **Note**
> This is a note
> **Warning**
> This is a warning
> **Important**
> This is important information
GitHub-style alerts (GFM):
> [!NOTE]
> Useful information
> [!TIP]
> Helpful advice
> [!IMPORTANT]
> Key information
> [!WARNING]
> Critical content
> [!CAUTION]
> Negative potential consequencesMermaid Diagrams
Mermaid 图表
markdown
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Do Something]
B -->|No| D[Do Something Else]
C --> E[End]
D --> E
```
```mermaid
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Hello Bob!
B->>A: Hello Alice!
```markdown
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Do Something]
B -->|No| D[Do Something Else]
C --> E[End]
D --> E
```
```mermaid
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Hello Bob!
B->>A: Hello Alice!
```Markdown Tools
Markdown 工具
Linters
代码检查工具
bash
undefinedbash
undefinedmarkdownlint
markdownlint
npm install -g markdownlint-cli
markdownlint '**/*.md'
npm install -g markdownlint-cli
markdownlint '**/*.md'
Configuration: .markdownlint.json
Configuration: .markdownlint.json
{
"default": true,
"MD013": false,
"MD033": false
}
undefined{
"default": true,
"MD013": false,
"MD033": false
}
undefinedFormatters
格式化工具
bash
undefinedbash
undefinedprettier
prettier
npm install -g prettier
prettier --write '**/*.md'
npm install -g prettier
prettier --write '**/*.md'
Configuration: .prettierrc
Configuration: .prettierrc
{
"proseWrap": "always",
"printWidth": 80
}
undefined{
"proseWrap": "always",
"printWidth": 80
}
undefinedPreview
预览工具
bash
undefinedbash
undefinedgrip - GitHub README preview
grip - GitHub README preview
pip install grip
grip README.md
pip install grip
grip README.md
undefinedundefinedBest Practices
最佳实践
✅ DO
✅ 建议
- Use descriptive link text
- Include table of contents for long documents
- Add alt text to images
- Use code blocks with language specification
- Keep lines under 80-100 characters
- Use relative links for internal docs
- Add badges for build status, coverage, etc.
- Include examples and screenshots
- Use semantic line breaks
- Test all links regularly
- 使用描述性链接文本
- 长文档添加目录
- 为图片添加替代文本
- 为代码块指定语言
- 每行长度控制在80-100字符以内
- 内部文档使用相对链接
- 添加构建状态、覆盖率等徽章
- 包含示例和截图
- 使用语义化换行
- 定期测试所有链接
❌ DON'T
❌ 不建议
- Use "click here" as link text
- Forget alt text on images
- Mix HTML and Markdown unnecessarily
- Use absolute paths for local files
- Create walls of text without breaks
- Skip language specification in code blocks
- Use images for text content (accessibility)
- 使用“点击这里”作为链接文本
- 不为图片添加替代文本
- 不必要地混合HTML和Markdown
- 本地文件使用绝对路径
- 无换行的大段文本
- 代码块不指定语言
- 使用图片代替文本内容(无障碍考虑)