Browse all lessons

Lesson 13 of 18 · 1:15 video · practice includedNot yet complete

Show a command. Do not run it.

Keep code examples separate from the explanation around them.

WATCH THE LESSON1:15 · narrated walkthrough
Read the descriptive transcript

Follow the complete narration and the changes shown in the video. Each example can be copied.

1. Code fences display text

A command in a document is an example, not an action. We will put this shell command in a fenced code block. This is a teaching canvas, not a terminal.

Source shown

# Command example


echo hello

Explain below.

On screen

The cursor points to the source or its result while the explanation is narrated.

2. 1. Open the fence

On the line above the command, type three backticks and the letters s h. The language label describes the example. It does not run it.

Source shown

# Command example

```sh
echo hello

Explain below.

On screen

The source changes one character at a time and the parsed preview updates.

3. The unfinished fence includes too much

Notice that Explain below is inside the code block too. An unfinished fence continues to the end of the document. We need a closing fence after the command.

Source shown

# Command example

```sh
echo hello

Explain below.

On screen

The cursor points to the source or its result while the explanation is narrated.

4. 2. Close the fence

On the next line, type three backticks, then Enter. Now the preview separates the code example from the explanation underneath.

Source shown

# Command example

```sh
echo hello
```

Explain below.

On screen

The source changes one character at a time and the parsed preview updates.

5. Displayed code is not command output

The preview displays echo hello. It has not printed hello as a command result. Markdown formats the text. Running it would require a separate tool, such as a terminal.

Source shown

# Command example

```sh
echo hello
```

Explain below.

On screen

The cursor points to the source or its result while the explanation is narrated.

6. Your turn: change the example

Pause here. Change hello to welcome inside the fence. Keep the explanation outside. Use the practice box below the video, then compare with the solution.

Source shown

# Command example

```sh
echo hello
```

Explain below.

On screen

The cursor points to the source or its result while the explanation is narrated.

Display text without executing it

A fenced code block keeps an example together. Markdown does not execute its contents. The optional language label can help a renderer highlight syntax; it is not a request to run a shell or an AI tool. Start with the headings lesson if Markdown is new to you.

Open, then close

Place a fence on its own line before the example, and another after it. This complete document uses sh to describe a shell example:

# Command example

```sh
echo hello
```

Explain below.

A fence contains at least three backticks or tildes. The closing fence uses the same character and at least as many of them. An unclosed fence continues to the end of its containing block; in this simple document that means the rest of the file. These are CommonMark fenced-code rules.

Repair the common mistake

In the starter, the closing fence is missing. Notice how the explanation appears inside the code block. Add the closing line, with a blank line before the explanation. The result should show one code example followed by one ordinary paragraph.

The preview should display echo welcome. It should not display welcome as if a command had run. Copying a command into a terminal is a separate action: understand the command and its environment first.

Try a different greeting

Change the supplied greeting to welcome, then repair the fence. The check looks for one closed sh block containing the example and the explanation outside it. It does not run anything.

When working with AI

Code fences help distinguish an example from surrounding prose. They do not establish a security boundary or permission to execute code. If you ask an assistant to review a command, say whether you want explanation, a suggested edit or execution. Review the actual tool action separately.

YOUR TURN

Make the idea your own.

Change hello to welcome. Close the sh fence before Explain below, so the explanation is an ordinary paragraph.

practice.mdText stays on this page

Readable result

Command example

echo hello

Explain below.

Compare with one possible answer
# Command example

```sh
echo welcome
```

Explain below.

This is one approach. Your writing can differ while meeting the same structural goal.

TAKE IT WITH YOU

A code block displays an example. It does not execute it.

Read the editor guide →
Agent-readable/learn/lessons/code-fences.md
Save .md