Quoting code as code?


#1

I noticed this post where quoted code loses formatting. I made a few attempts on try.discourse.org to get quoted code right, but failed.

Is there a good way to quote code?


#2

Either this:

    code code code code

(indented by four spaces)
or this:

```
code code code code
```

(surrounded with triple back ticks)
With the second syntax, you can put a syntax highlighting language after the first set of back ticks, like this:

```js
var foo = bar();
```

#3

Do you mean that you have to select the code, click on quote reply and then manually indent the code?

It would be nice to have Discourse do that for me.


#4

Quotes do not support any kind of formatting at the moment other than plain text. Why not just mention a @name and then put in code instead?


#5

Fine with me, but I would have never thought of that. Either it is just me, or it should be mentioned somewhere.