Are there multiple ways? The code button doesn’t always work!
I usually paste the code in, highlight it, then click the button. It has always worked for me.
Its the single ticks that do it. Three single ticks will give you code, but literally three single ticks will not preserve three single ticks. And one single tick I believe is just stripped Honestly.
I’ve been using this forum for months, code is a problem to render
Besides manually typing in 3 back-ticks for opening and closing a code segment, you can just use the code button like @Mr_JimWest said.
If you highlight only one line before pressing the button, you’ll get single backticks.
If you highlight multiple lines before pressing the button, you’ll get a proper code block.
They will if the middle three are indented four or more spaces and the outer three back-ticks are each on their own line.
There is, though, no way I know of to show how the example above was typed, except by demonstating with single quotes instead of back-ticks (wrapped with three back-tick above and below them, which are not shown).
''' ''' '''
Here ` is a single back-tick. As long as it has no mate in the paragraph, it’s preserved, but the paragraphs have to be separated by an empty line.
AFAIK, there’s no way to represent three backticks in the middle of a line of text, but
``` you can put them at the beginning of a line indented by four spaces.The spaces used to indent them will be removed.
By using 4 ticks to open/close the code block instead of 3:
``` Code ```
So, like this:
```` ``` Code ``` ````
Which you can post like:
````` ```` ``` Code ``` ```` `````
`````` ````` ```` ``` Code ``` ```` ````` ``````
Could go on, but… you get the point
like this can be done with a single tick (so
`like this`). Can get confusing because MODX uses the same ticks in properties, in which case you could also use 2 ticks like this:
For what’s called a “fenced” code block, for longer code, you need an equal number of ticks (at least 3), on a line of their own, to open and to close what’s known as a “fenced” code block. https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks
This is also shown in the “About the Support category” topic, which is pinned and at the top of that category for new visitors.
4 ticks, aha! Why didn’t I think of that
I learned from Mark’s post that you can put three back-ticks inside a line of text like this:
Like this, but with back-ticks: ‘’’ ‘’’ ‘’’.
Hmm interesting, I was playing with three backticks a lot and didn’t see that. Maybe the line breaks change it, let me see
ok that didn't work at all
Yup the line breaks mess it up…hmm I guess that makes some sense, the processor doesn’t know where the brackets end…but haha does somehow within one line
To show 3 ticks formatted as code, you need to wrap it in 4 ticks, like this:
```` ``` ````