This is a short post on using backticks (
```) to quote code, with the intention of benefiting users who are confused by this feature of the site. The intention is to make it linkable when necessary.
By quoting your code, you get a monospaced font (which preserves indentation) and syntax highlighting. This helps people who read your code and want to help you.
Displayed code looks like this:
function displayed_code(x::Int, y::Int) if x < y println("x is smaller") else println("or not") end end
Discourse uses Markdown. Open and close displayed code with triple backticks
julia after the first
``` specifies the language: on this forum, you can omit it and it will default to Julia.
```julia function displayed_code(x::Int, y::Int) if x < y println("x is smaller") else println("or not") end end ```
The inline syntax uses single backticks:
`looks_like_this(c::Float64)` (you can’t specify the language here, no syntax highlighting).
This is all you need to do. When editing your post, the preview window on the right shows the result, and helps you make sure you did it right.
If you want to quote backticks themselves, enclose them in more backticks:
`` ` `` renders as
````julia """ This is how you use this function: ```julia 1+1 ``` """ ````
""" This is how you use this function: ```julia 1+1 ``` """
which is useful when quoting code with docstrings that have
``` in them.