How to use code fences

Great thanks

Using code fences does this by default

```
Really long code or logs go here
```
3 Likes

Here is a test post which I will delete once I am done :

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

Using the BB Formatting tool:

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

TABing wont work so I guess that must be correct before you copy

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                              //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                              //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

I often see complaints that people aren’t using code fences when requesting help.

I’m using Firefox (77.0.1 (64-bit)) on Ubuntu (18.04), and this is what my edit panel looks like:

All the code fence icons are gone! The links are still there (you can tell if you hover over them). Is this very specific to Firefox on Ubuntu?

Hi @hafniumzinc,

I see this behavior on MacOSX (10.15.4) with Chrome, Microsoft Edge, and other browsers. As mentioned above if I hover over where the icons should be, I get text indicating the usage of the code fences.

Regards,
Burzin

1 Like

Still there:

cf

Further information:

You’ve linked to the thread we’re currently in!

The icon you’ve circled is titled ‘code snippet’, and adds four spaces in front of text for pre-formatted text. I’m talking about the specific ones for items, rules, sitemaps etc which adds three backticks (`) at the start and end of code, also enabling vertical (and horizontal) scroll bars if the code gets long. Those are the code fences.

I know.
Again: use the preformatted text and you are good to go.

As I mentioned previously, the options for the fences actually exist, it’s just their icons have gone missing so they’re ‘hidden’.

The main point is as below:

If we’re asking people to use code fences, let’s make sure they can easily use them!

It could relate to the version of Discourse running on the site. I do not know if it is regularly updated.

EDIT: We are running Discourse 2.5.0-beta 6 that was released 9 days ago. It is missing for me too on chrome for Windows. Hovering brings up the tooltip but no icon. Clicking does work though.

    <meta name="generator" content="Discourse 2.5.0.beta6 - https://github.com/discourse/discourse version 75b1298e997ce7dda904cc88b668a55eb13b457f">

EDIT2: Perhaps somebody want to look for a solution on their forum?

This is the case since ages, there is an old post about it where Kai tried to fix it without success.

Just hit the damn preformatted text button and you have your code fences. Just the color highlighting is missing, so what.

Edit: here is the post about the missing icons (since at least May 2019) and also information on the not active maintainer who developed the plugin:

1 Like