---
title: "Show a command. Do not run it."
description: "Keep code examples separate from the explanation around them."
canonical: https://editmd.app/learn/lessons/code-fences/
markdown: https://editmd.app/learn/lessons/code-fences.md
status: pre-release, waiting list open
generated: editmd-website
---

# Show a command. Do not run it.

Lesson 13 of 18 in Markdown School. Keep code examples separate from the explanation around them.

## 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](/learn/lessons/headings/) 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:

````markdown
# 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](https://spec.commonmark.org/0.31.2/#fenced-code-blocks).

## 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.

## Exercise

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

## Takeaway

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

Related guide: https://editmd.app/docs/writing/. All lessons: https://editmd.app/learn.md
