Markdown Syntax
Markdown is a lightweight markup language used to format documents, widely favored by developers and extensively used in open-source projects for writing README files, issue comments, Pull Request descriptions, etc. This document will introduce you to some commonly used syntax and techniques of Markdown.
1. Headers
Use the #
symbol to create headers, with the level of the header determined by the number of #
symbols, supporting up to three levels.
# This is a Level 1 Header
## This is a Level 2 Header
### This is a Level 3 Header
2. Text Formatting
Bold and Italic
Wrap text with **
or __
to create bold text, and use *
or _
to create italic text.
**This is bold**, *this is italic*
Blockquotes
Create blockquotes using the >
symbol.
> This is quoted text.
Inline Code
Wrap text with backticks (`
) to create inline code.
This is a text containing `inline code`.
3. Lists
Unordered Lists
Create unordered lists using -
, *
, or +
.
- Item 1
- Item 2
- Sub-item 2.1
- Sub-item 2.2
* Item 3
Ordered Lists
Create ordered lists using numbers followed by a period.
1. Item 1
2. Item 2
1. Sub-item 2.1
2. Sub-item 2.2
3. Item 3
Nested Lists
Unordered and ordered lists can be nested.
4. Links
Internal Links
Create links using [link text](link URL)
.
[GitCode](https://gitcode.com/)
External Links
Enter the full URL or email address directly to automatically create a link.
5. Images
Insert images using ![alternative text](image URL)
.
![GitCode Logo](https://gitcode.com/assets/gitcode-logo-bf8686e9.png)
6. Code Blocks
Create code blocks using three backticks (```
), and specify the programming language for syntax highlighting.
def hello_world():
print("Hello, World!")
7. Tables
Create tables using |
and -
, and specify the alignment of the table.
| Column 1 | Column 2 |
|----------|----------|
| Content 1 | Content 2 |
8. Task Lists
Create task lists using - [ ]
or - [x]
.
- [ ] Incomplete task
- [x] Completed task
9. Horizontal Rules
Create horizontal rules using three or more -
, *
, or _
.
---
10. Mentioning Other Users or Issues
Use the @
symbol in text to mention other users or issues, who will receive notifications.
@username mentioned you.
11. Emoji
Supports using emojis in text, such as :smile:
which displays as 😄.
12. Mathematical Formulas
Enclose mathematical formulas with two dollar signs ($$
) to render mathematical expressions.
$$
E = mc^2
$$
13. UML Syntax
UML syntax diagrams are standardized graphical representations used for visualizing, describing, and designing software systems.
@startuml
Alice -> "Bob()" : Hello
"Bob()" -> "This is very long" as Long
' You can also declare:
' "Bob()" -> Long as "This is very long"
Long --> "Bob()" : ok
@enduml
PlantUML provides a simple, clear, and user-friendly method for creating and editing sequence diagrams. For more help on using UML syntax, refer to Help.
The above are some commonly used Markdown syntax and techniques. Mastering them can help you create more expressive, clear, and readable documents and comments. Use these syntax flexibly according to your needs to improve the quality and understandability of your documents.