Did you know you can embed your code with highlighting?
Okay, so I guess it is safe to assume that everyone knew you could do this, but do you know how to do it?
The simplest method is to use backticks `, three of them to be exact (well six… but I’m jumping ahead here) on a single line, like so:
```
Followed by your code
<a href=“mylink.htm”>My Link Text</a>
Followed by three more backticks ` on a separate line.
```
Put it all together and you get:
```
<a href=“mylink.htm”>My Link Text</a>
```
Which produces
<a href="mylink.htm">My Link Text</a>
Now the cool thing is, I didn’t have to tell it what language I was using. But if your language is similar to another, or you don’t have any characters that would help indicate what language it might be, you can tell it.
So given my prior example, if I wanted to tell the highlighter, this is HTML, I simply put html after the first three backticks like so:
```html
<a href=“mylink.htm”>My Link Text</a>
```
Which produces (identical, I know)
<a href="mylink.htm">My Link Text</a>
To find out what languages are supported, visit https://highlightjs.org/ and try their demo. Most of those should work here (as highlight.js is what Discourse bases their syntax highlighting on).
Are there alternative ways of providing my code? Yep!
If you are a desktop user, paste your code, highlight it, and press the </> button. That will automatically add 4 spaces to each of your code lines which is another way Markdown identifies code blocks. (please note, you must have an empty line between your text and the start of your code; you also need an empty line between the end of your code and any additional text you may want to write)
Example:
<a href="mylink.html">My Link Text</a>
Last but not least, feel free to use tools such as PasteBin, or send us a link to your project on GitHub (or whatever repo you are using).
So now you know how to format your code, spread the word!