typing about code or terminal text: please use backticks (and avoid screenshotting text)

Many topics here will involve code or terminal commands and output.

If at all possible, such code snippets (bits in line) or code blocks (multiline chunks) should be wrapped in backticks to make formatting more clearly readable. This will help with interpretability and understanding.

In general, code snippets should be placed between single backticks: `something something`. When interpreted and posted, this will end up looking like: something something.

Code blocks would be placed between triple backticks:
```
some line
another line
maybe more

etc.
```
When the above is interpreted, it will look like:

some line
another line
maybe more

etc.

Another way to accomplish this is to highlight text and click on the "Preformatted Text" button in the typing/entry interface. That button is in the top row of icons (where the speech bubble and emoji icons are...) and looks like </>. Highlighting text and clicking on that will lead to approriate ticks being wrapped around it. Or, you can highlight the text and type Ctrl+E. The Discourse page is almost as multifaceted as the AFNI GUI!

On a final note, it is also much better to copy+paste text, rather than to take photos or screenshots and paste it. Leaving it in text form means it is copy+pastable by people trying to read/check it, and it is also searchable (for error/failure messages, keywords, etc.).

1 Like

Also, a fun feature of the codeblock backticks is that you can specify the highlighting language within the codeblock. Just put the name of the available script/programming language in the top line, where the opening backticks are:

here, I started the codeblock with: ``` bash

#!/bin/bash

# comment
varA=$1
varB=$2

echo "++ The variables are: ${varA} ${varB}"

here, I started the codeblock with: ``` python


# comment
varA = 'some string'
varB = '''another string'''

print("++ The variables are: {varA} {varB}".format(varA=varA, varB=varB))

The current list of available names are:

The default color interpretation is 'auto', which may be more/less useful.

--pt

2 Likes