How Can I Put Plain Text Before Code Blocks

I can create a code block like this:

```bash
cd .. && ls
```

It will end up like this:

cd .. && ls

What if I wanted to put plain text before the code block? When showing shell commands, sometimes you need to run them as the root user and sometimes as the regular user. The "#" sign is used for root users and the "$" sign is used for regular users. I tried this:

  ```bash
$ cd .. && ls
  ```

But it did not work. This is a weird thing to do, but there is probably no direct solution, just a workaround will be fine.

What did you try exactly ? This does not error

---
title: test
output: 
  html_document: default
---

```bash
$ cd .. && ls
```

Putting the "$" or "#" symbol in the code block changes the syntax. For example: the "#" symbol is seen as a comment, so it changes the color of the code. Is there a way I can insert that symbol without changing the syntax highlighting?

I don't think so as # in a bash script really means a comment. The highlight use is the one from bash script here. The highlighting parser will identify the # as a comment, hence the result you see.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.