Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

81%
+7 −0
Q&A how do I get markdown to render # as a shell prompt and not a comment?

Instead of sh, use shell or console. So this: ```shell # echo hi ``` ```console # echo hi ``` Is rendered as: # echo hi # echo hi While this: ```bash # echo hi ``` ```sh #...

posted 6d ago by hkotsubo‭  ·  edited 2d ago by hkotsubo‭

Answer
#5: Post edited by user avatar hkotsubo‭ · 2024-12-09T21:19:33Z (2 days ago)
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case the highlight engine[^1] changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#` as the prompt.
  • [^1]: Currently, Codidact uses [highlight.js](https://highlightjs.org)
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case the highlight engine[^1] changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might be a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#` as the prompt.
  • [^1]: Currently, Codidact uses [highlight.js](https://highlightjs.org)
#4: Post edited by user avatar hkotsubo‭ · 2024-12-07T09:30:33Z (5 days ago)
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case highlight engine changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#` as the prompt.
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case the highlight engine[^1] changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#` as the prompt.
  • [^1]: Currently, Codidact uses [highlight.js](https://highlightjs.org)
#3: Post edited by user avatar hkotsubo‭ · 2024-12-06T12:46:27Z (6 days ago)
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case highlight engine changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#`as the prompt.
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case highlight engine changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#` as the prompt.
#2: Post edited by user avatar hkotsubo‭ · 2024-12-06T12:44:50Z (6 days ago)
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#`as the prompt.
  • Instead of `sh`, use `shell` or `console`.
  • So this:
  • ~~~markdown
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```shell
  • # echo hi
  • ```
  • ```console
  • # echo hi
  • ```
  • While this:
  • ~~~markdown
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ~~~
  • Is rendered as:
  • ```bash
  • # echo hi
  • ```
  • ```sh
  • # echo hi
  • ```
  • ---
  • Below are the same code blocks as images (just in case highlight engine changes in the future).
  • With `shell` and `console`:
  • ![code highlighted as shell console session](https://software.codidact.com/uploads/8syystrxcnewursbpxmjko28sgrr)
  • With `bash` and `sh`:
  • ![code highlighted as shell script](https://software.codidact.com/uploads/cdmu1e035kez8j85jd6ucfsavdjz)
  • ---
  • That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#`as the prompt.
#1: Initial revision by user avatar hkotsubo‭ · 2024-12-06T12:41:11Z (6 days ago)
Instead of `sh`, use `shell` or `console`.

So this:
~~~markdown
```shell
# echo hi
```

```console
# echo hi
```
~~~

Is rendered as:

```shell
# echo hi
```

```console
# echo hi
```

While this:
~~~markdown
```bash
# echo hi
```

```sh
# echo hi
```
~~~

Is rendered as:

```bash
# echo hi
```

```sh
# echo hi
```

---

That might a little bit confusing, but `bash` and `sh` refers to "shell script" (which treats `#` as a comment), while `shell` and `console` refers to a "shell session", hence they treat the initial `#`as the prompt.