Markdown Lists

Lists are an important way to organize information. Markdown supports ordered lists, unordered lists, and task lists. This chapter will detail various uses of lists.

Unordered Lists

Basic Syntax

Use -, +, or * to create unordered lists:

- Item one
- Item two
- Item three

Effect:

  • Item one
  • Item two
  • Item three

Different Markers

All three markers have the same effect:

- Using dash
+ Using plus
* Using asterisk

Effect:

  • Using dash
  • Using plus
  • Using asterisk

Best Practices

It's recommended to use the same symbol throughout the document:

✅ Recommended (unified use of -)
- Item one
- Item two
- Item three

❌ Not Recommended (mixed use)
- Item one
+ Item two
* Item three

Ordered Lists

Basic Syntax

Use numbers followed by . to create ordered lists:

1. First item
2. Second item
3. Third item

Effect:

  1. First item
  2. Second item
  3. Third item

Auto Numbering

Numbers don't need to be in order, Markdown will automatically number them:

1. First item
1. Second item
1. Third item

Effect:

  1. First item
  2. Second item
  3. Third item

Specify Starting Number

5. Fifth item
6. Sixth item
7. Seventh item

Effect:

  1. Fifth item
  2. Sixth item
  3. Seventh item

Nested Lists

Unordered List Nesting

Use indentation (2 or 4 spaces) to create nesting:

- Main item
  - Sub item 1
  - Sub item 2
    - Sub sub item 1
    - Sub sub item 2
- Another main item

Effect:

  • Main item
    • Sub item 1
    • Sub item 2
      • Sub sub item 1
      • Sub sub item 2
  • Another main item

Ordered List Nesting

1. First item
   1. Sub item 1.1
   2. Sub item 1.2
2. Second item
   1. Sub item 2.1
   2. Sub item 2.2

Effect:

  1. First item
    1. Sub item 1.1
    2. Sub item 1.2
  2. Second item
    1. Sub item 2.1
    2. Sub item 2.2

Mixed Nesting

1. Ordered item
   - Unordered sub item
   - Another unordered sub item
2. Another ordered item
   1. Ordered sub item
   2. Another ordered sub item

Effect:

  1. Ordered item
    • Unordered sub item
    • Another unordered sub item
  2. Another ordered item
    1. Ordered sub item
    2. Another ordered sub item

Paragraphs in Lists

Single Paragraph

Add a paragraph in a list item, use indentation:

- First item

  This is a detailed description paragraph of the first item.

- Second item

  This is a detailed description paragraph of the second item.

Multiple Paragraphs

1. First item

   First paragraph description.

   Second paragraph description.

2. Second item

   First paragraph description.

Code Blocks in Lists

Inline Code

- Use `git add` to add files
- Use `git commit` to commit changes
- Use `git push` to push to remote

Effect:

  • Use git add to add files
  • Use git commit to commit changes
  • Use git push to push to remote

Code Blocks

Use 8 spaces or 2 tabs for indentation:

1. Install dependencies

   ```bash
   npm install
   ```
2. Start service

   ```bash
   npm start
   ```

Quotes in Lists

- First item

  > This is a quoted text.
  > Can have multiple lines.

- Second item

Effect:

  • First item

    This is a quoted text. Can have multiple lines.

  • Second item

Images in Lists

1. First step

   ![Image description](Image URL)

2. Second step

   ![Another image](Image URL)

Task Lists

Basic Syntax

Use - [ ] and - [x] to create task lists:

- [x] Completed task
- [ ] Incomplete task
- [ ] Another incomplete task

Effect:

  • Completed task
  • Incomplete task
  • Another incomplete task

Nested Task Lists

- [x] Main task
  - [x] Subtask 1
  - [ ] Subtask 2
- [ ] Another main task
  - [ ] Subtask 1
  - [ ] Subtask 2

Effect:

  • Main task
    • Subtask 1
    • Subtask 2
  • Another main task
    • Subtask 1
    • Subtask 2

Task List Applications

## Project Todo List

- [x] Complete requirements analysis
- [x] Design database
- [ ] Develop backend API
  - [x] User module
  - [ ] Order module
  - [ ] Payment module
- [ ] Develop frontend interface
- [ ] Testing
- [ ] Deployment

Definition Lists

Some Markdown extensions support definition lists:

Term1
: Definition1

Term2
: Definition2a
: Definition2b

Or use HTML:

<dl>
  <dt>Term1</dt>
  <dd>Definition1</dd>
  <dt>Term2</dt>
  <dd>Definition2</dd>
</dl>

List Styles

Use Emojis

- ✅ Completed
- ⏳ In Progress
- ❌ Cancelled
- 📝 Pending

Effect:

  • ✅ Completed
  • ⏳ In Progress
  • ❌ Cancelled
  • 📝 Pending

Use Icons

- 🎯 Goal
- 💡 Idea
- ⚠️ Warning
- 📌 Important

Effect:

  • 🎯 Goal
  • 💡 Idea
  • ⚠️ Warning
  • 📌 Important

List Best Practices

1. Keep Indentation Consistent

✅ Recommended
- Main item
  - Sub item (2 spaces)
    - Sub sub item (4 spaces)

❌ Not Recommended
- Main item
   - Sub item (3 spaces)
     - Sub sub item (5 spaces)

2. Blank Lines Before and After Lists

✅ Recommended
This is a paragraph.

- List item 1
- List item 2

This is another paragraph.

❌ Not Recommended
This is a paragraph.
- List item 1
- List item 2
This is another paragraph.

3. Keep it Concise

✅ Recommended
- Install Node.js
- Configure environment variables
- Run project

❌ Not Recommended
- First you need to download and install Node.js from the official website, then...

4. Use Nesting Reasonably

Don't nest too deep (recommended no more than 3 levels):

✅ Recommended
- Level 1
  - Level 2
    - Level 3

❌ Not Recommended
- Level 1
  - Level 2
    - Level 3
      - Level 4
        - Level 5 (too deep)

List Application Scenarios

1. Step Instructions

## Installation Steps

1. Download installation package
2. Extract files
3. Run installation program
4. Complete configuration

2. Feature Lists

## Main Features

- User management
- Permission control
- Data statistics
- Report export

3. Todo Items

## Today's Tasks

- [ ] Reply to emails
- [ ] Complete report
- [x] Attend meeting
- [ ] Code review

4. Pros and Cons Comparison

## Advantages

- Simple and easy to use
- Excellent performance
- Active community

## Disadvantages

- Steep learning curve
- Incomplete documentation

5. Directory Structure

## Project Structure

- src/
  - components/
  - utils/
  - styles/
- public/
- tests/
- README.md

Lists Combined with Other Elements

- [GitHub](https://github.com)
- [Stack Overflow](https://stackoverflow.com)
- [MDN](https://developer.mozilla.org)

Lists + Bold

- **Important**: This is important content
- **Note**: This needs attention
- **Tip**: This is a tip

Lists + Code

- Install: `npm install`
- Start: `npm start`
- Build: `npm run build`

Common Questions

Spacing Between List Items

If you need more spacing between list items, add blank lines between items:

- First item

- Second item

- Third item

List Number Reset

If a list is interrupted by other content, numbering will reset:

1. First item
2. Second item

This is a paragraph.

1. Numbering restarts
2. Second item

Special Characters in Lists

If a list item starts with a number and a dot, escape it:

- 1984\. This is a book
- 2024\. This is a year

Shortcuts

VS Code

  • Ctrl/Cmd + Shift + ]: Increase indentation
  • Ctrl/Cmd + Shift + [: Decrease indentation

Typora

  • Ctrl/Cmd + ]: Increase indentation
  • Ctrl/Cmd + [: Decrease indentation
  • Ctrl/Cmd + Shift + X: Toggle task status

Practice Exercises

Try creating the following lists:

  1. An unordered list with 3 items
  2. An ordered list with 5 steps
  3. A list with nested items
  4. A task list (with completed and incomplete items)
  5. A list containing code and links

Summary

Lists are one of the most commonly used features in Markdown. Mastering lists can:

  • Clearly organize information
  • Show steps and processes
  • Manage tasks and todo items
  • Create tables of contents and navigation

Next: Learn detailed usage of Markdown Blockquotes.