It’s not widely known, but there are two ways to add blocks of code on our forum, and the “code” </> button in the editor does only one of them.
If you have some code like this:
*fake_choice
#choice 1
#choice 2
You can paste it into the editor, select it, and click on the </> button in the editor, and it will indent it with four spaces per line, like this:
*fake_choice
#choice 1
#choice 2
That will make the code look like code. But you can also type three backtick marks on a line by themselves at the beginning and end of your code, like this:
```
*fake_choice
#choice 1
#choice 2
```
That will do the same thing as indenting it. Those backticks are called “code fences.”
If we change that setting, you’ll still be able to use four-space indents to write code, if you prefer it that way; it will only change the behavior of the code button.
What do you think?
EDIT: I turn on the setting. We can turn it off if folks don’t like it.
I didn’t know about the code fences, but I think I would prefer them as the default for the code formatting button–largely because they seem wonderfully useful. It’s easier for me to edit a large block of code, or one with complex indentation, if I’m not also handling four extra spaces at the beginning of lines.
OK, I’ve turned it on. Now if you paste some code, select it, and click the code button, it adds backtick code fences, or if you just click the code button without selecting anything, it adds this to your post:
```
type or paste code here
```
We can change it back if people don’t seem to like it. (Remember, four-space indent still works.)
I think that looks good. Your post doesn’t say what exactly happens when you click the code button, only that it will make your code look like code, which it still does.